diff options
author | vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-01-06 22:55:39 +0000 |
---|---|---|
committer | vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-01-06 22:55:39 +0000 |
commit | d84044aec0956cf2ea92f1a666116e47a7a23bfd (patch) | |
tree | 049b942c9426111131651ffc8e6e0b9f44387896 | |
parent | cf6d18103fb50c0dafa2ea285fb0e29d6dea69d8 (diff) | |
parent | 9c3989cdeb15d8d5bf41abbf4cda8389f9e2a4ff (diff) | |
download | src-d84044aec0956cf2ea92f1a666116e47a7a23bfd.tar.gz |
Branch at r12682 for Chrome M33
git-svn-id: http://skia.googlecode.com/svn/branches/chrome/m33_1750/src@12932 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | core/SkCanvas.cpp | 53 | ||||
-rw-r--r-- | core/SkDraw.cpp | 45 | ||||
-rw-r--r-- | core/SkMatrix.cpp | 7 |
3 files changed, 55 insertions, 50 deletions
diff --git a/core/SkCanvas.cpp b/core/SkCanvas.cpp index 47d3cca8..feeba758 100644 --- a/core/SkCanvas.cpp +++ b/core/SkCanvas.cpp @@ -19,7 +19,6 @@ #include "SkPicture.h" #include "SkRasterClip.h" #include "SkRRect.h" -#include "SkScalarCompare.h" #include "SkSurface_Base.h" #include "SkTemplates.h" #include "SkTextFormatParams.h" @@ -485,8 +484,8 @@ private: SkBaseDevice* SkCanvas::init(SkBaseDevice* device) { fBounder = NULL; - fLocalBoundsCompareType.setEmpty(); - fLocalBoundsCompareTypeDirty = true; + fCachedLocalClipBounds.setEmpty(); + fCachedLocalClipBoundsDirty = true; fAllowSoftClip = true; fAllowSimplifyClip = false; fDeviceCMDirty = false; @@ -897,7 +896,7 @@ void SkCanvas::internalRestore() { SkASSERT(fMCStack.count() != 0); fDeviceCMDirty = true; - fLocalBoundsCompareTypeDirty = true; + fCachedLocalClipBoundsDirty = true; if (SkCanvas::kClip_SaveFlag & fMCRec->fFlags) { fClipStack.restore(); @@ -1056,37 +1055,37 @@ void SkCanvas::drawSprite(const SkBitmap& bitmap, int x, int y, bool SkCanvas::translate(SkScalar dx, SkScalar dy) { fDeviceCMDirty = true; - fLocalBoundsCompareTypeDirty = true; + fCachedLocalClipBoundsDirty = true; return fMCRec->fMatrix->preTranslate(dx, dy); } bool SkCanvas::scale(SkScalar sx, SkScalar sy) { fDeviceCMDirty = true; - fLocalBoundsCompareTypeDirty = true; + fCachedLocalClipBoundsDirty = true; return fMCRec->fMatrix->preScale(sx, sy); } bool SkCanvas::rotate(SkScalar degrees) { fDeviceCMDirty = true; - fLocalBoundsCompareTypeDirty = true; + fCachedLocalClipBoundsDirty = true; return fMCRec->fMatrix->preRotate(degrees); } bool SkCanvas::skew(SkScalar sx, SkScalar sy) { fDeviceCMDirty = true; - fLocalBoundsCompareTypeDirty = true; + fCachedLocalClipBoundsDirty = true; return fMCRec->fMatrix->preSkew(sx, sy); } bool SkCanvas::concat(const SkMatrix& matrix) { fDeviceCMDirty = true; - fLocalBoundsCompareTypeDirty = true; + fCachedLocalClipBoundsDirty = true; return fMCRec->fMatrix->preConcat(matrix); } void SkCanvas::setMatrix(const SkMatrix& matrix) { fDeviceCMDirty = true; - fLocalBoundsCompareTypeDirty = true; + fCachedLocalClipBoundsDirty = true; *fMCRec->fMatrix = matrix; } @@ -1110,7 +1109,7 @@ bool SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { if (this->quickReject(rect)) { fDeviceCMDirty = true; - fLocalBoundsCompareTypeDirty = true; + fCachedLocalClipBoundsDirty = true; fClipStack.clipEmpty(); return fMCRec->fRasterClip->setEmpty(); @@ -1121,7 +1120,7 @@ bool SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { AutoValidateClip avc(this); fDeviceCMDirty = true; - fLocalBoundsCompareTypeDirty = true; + fCachedLocalClipBoundsDirty = true; doAA &= fAllowSoftClip; if (fMCRec->fMatrix->rectStaysRect()) { @@ -1206,7 +1205,7 @@ bool SkCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) { if (this->quickReject(path.getBounds())) { fDeviceCMDirty = true; - fLocalBoundsCompareTypeDirty = true; + fCachedLocalClipBoundsDirty = true; fClipStack.clipEmpty(); return fMCRec->fRasterClip->setEmpty(); @@ -1217,7 +1216,7 @@ bool SkCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) { AutoValidateClip avc(this); fDeviceCMDirty = true; - fLocalBoundsCompareTypeDirty = true; + fCachedLocalClipBoundsDirty = true; doAA &= fAllowSoftClip; SkPath devPath; @@ -1350,7 +1349,7 @@ bool SkCanvas::clipRegion(const SkRegion& rgn, SkRegion::Op op) { AutoValidateClip avc(this); fDeviceCMDirty = true; - fLocalBoundsCompareTypeDirty = true; + fCachedLocalClipBoundsDirty = true; // todo: signal fClipStack that we have a region, and therefore (I guess) // we have to ignore it, and use the region directly? @@ -1423,19 +1422,6 @@ void SkCanvas::replayClips(ClipVisitor* visitor) const { /////////////////////////////////////////////////////////////////////////////// -void SkCanvas::computeLocalClipBoundsCompareType() const { - SkRect r; - - if (!this->getClipBounds(&r)) { - fLocalBoundsCompareType.setEmpty(); - } else { - fLocalBoundsCompareType.set(SkScalarToCompareType(r.fLeft), - SkScalarToCompareType(r.fTop), - SkScalarToCompareType(r.fRight), - SkScalarToCompareType(r.fBottom)); - } -} - bool SkCanvas::quickReject(const SkRect& rect) const { if (!rect.isFinite()) @@ -1452,17 +1438,14 @@ bool SkCanvas::quickReject(const SkRect& rect) const { dst.roundOut(&idst); return !SkIRect::Intersects(idst, fMCRec->fRasterClip->getBounds()); } else { - const SkRectCompareType& clipR = this->getLocalClipBoundsCompareType(); + const SkRect& clipR = this->getLocalClipBounds(); // for speed, do the most likely reject compares first - SkScalarCompareType userT = SkScalarToCompareType(rect.fTop); - SkScalarCompareType userB = SkScalarToCompareType(rect.fBottom); - if (userT >= clipR.fBottom || userB <= clipR.fTop) { + // TODO: should we use | instead, or compare all 4 at once? + if (rect.fTop >= clipR.fBottom || rect.fBottom <= clipR.fTop) { return true; } - SkScalarCompareType userL = SkScalarToCompareType(rect.fLeft); - SkScalarCompareType userR = SkScalarToCompareType(rect.fRight); - if (userL >= clipR.fRight || userR <= clipR.fLeft) { + if (rect.fLeft >= clipR.fRight || rect.fRight <= clipR.fLeft) { return true; } return false; diff --git a/core/SkDraw.cpp b/core/SkDraw.cpp index 52891ea5..ccab56ca 100644 --- a/core/SkDraw.cpp +++ b/core/SkDraw.cpp @@ -1841,19 +1841,16 @@ void SkDraw::drawText(const char text[], size_t byteLength, // e.g. subpixel doesn't round typedef void (*AlignProc)(const SkPoint&, const SkGlyph&, SkIPoint*); -static void leftAlignProc(const SkPoint& loc, const SkGlyph& glyph, - SkIPoint* dst) { +static void leftAlignProc(const SkPoint& loc, const SkGlyph& glyph, SkIPoint* dst) { dst->set(SkScalarToFixed(loc.fX), SkScalarToFixed(loc.fY)); } -static void centerAlignProc(const SkPoint& loc, const SkGlyph& glyph, - SkIPoint* dst) { +static void centerAlignProc(const SkPoint& loc, const SkGlyph& glyph, SkIPoint* dst) { dst->set(SkScalarToFixed(loc.fX) - (glyph.fAdvanceX >> 1), SkScalarToFixed(loc.fY) - (glyph.fAdvanceY >> 1)); } -static void rightAlignProc(const SkPoint& loc, const SkGlyph& glyph, - SkIPoint* dst) { +static void rightAlignProc(const SkPoint& loc, const SkGlyph& glyph, SkIPoint* dst) { dst->set(SkScalarToFixed(loc.fX) - glyph.fAdvanceX, SkScalarToFixed(loc.fY) - glyph.fAdvanceY); } @@ -1868,6 +1865,32 @@ static AlignProc pick_align_proc(SkPaint::Align align) { return gProcs[align]; } +typedef void (*AlignProc_scalar)(const SkPoint&, const SkGlyph&, SkPoint*); + +static void leftAlignProc_scalar(const SkPoint& loc, const SkGlyph& glyph, SkPoint* dst) { + dst->set(loc.fX, loc.fY); +} + +static void centerAlignProc_scalar(const SkPoint& loc, const SkGlyph& glyph, SkPoint* dst) { + dst->set(loc.fX - SkFixedToScalar(glyph.fAdvanceX >> 1), + loc.fY - SkFixedToScalar(glyph.fAdvanceY >> 1)); +} + +static void rightAlignProc_scalar(const SkPoint& loc, const SkGlyph& glyph, SkPoint* dst) { + dst->set(loc.fX - SkFixedToScalar(glyph.fAdvanceX), + loc.fY - SkFixedToScalar(glyph.fAdvanceY)); +} + +static AlignProc_scalar pick_align_proc_scalar(SkPaint::Align align) { + static const AlignProc_scalar gProcs[] = { + leftAlignProc_scalar, centerAlignProc_scalar, rightAlignProc_scalar + }; + + SkASSERT((unsigned)align < SK_ARRAY_COUNT(gProcs)); + + return gProcs[align]; +} + class TextMapState { public: mutable SkPoint fLoc; @@ -1944,7 +1967,7 @@ void SkDraw::drawPosText_asPaths(const char text[], size_t byteLength, SkGlyphCache* cache = autoCache.getCache(); const char* stop = text + byteLength; - AlignProc alignProc = pick_align_proc(paint.getTextAlign()); + AlignProc_scalar alignProc = pick_align_proc_scalar(paint.getTextAlign()); TextMapState tms(SkMatrix::I(), constY); TextMapState::Proc tmsProc = tms.pickProc(scalarsPerPosition); @@ -1954,11 +1977,11 @@ void SkDraw::drawPosText_asPaths(const char text[], size_t byteLength, const SkPath* path = cache->findPath(glyph); if (path) { tmsProc(tms, pos); - SkIPoint fixedLoc; - alignProc(tms.fLoc, glyph, &fixedLoc); + SkPoint loc; + alignProc(tms.fLoc, glyph, &loc); - matrix[SkMatrix::kMTransX] = SkFixedToScalar(fixedLoc.fX); - matrix[SkMatrix::kMTransY] = SkFixedToScalar(fixedLoc.fY); + matrix[SkMatrix::kMTransX] = loc.fX; + matrix[SkMatrix::kMTransY] = loc.fY; if (fDevice) { fDevice->drawPath(*this, *path, paint, &matrix, false); } else { diff --git a/core/SkMatrix.cpp b/core/SkMatrix.cpp index 474f2722..d9c2677a 100644 --- a/core/SkMatrix.cpp +++ b/core/SkMatrix.cpp @@ -9,7 +9,6 @@ #include "Sk64.h" #include "SkFloatBits.h" #include "SkOnce.h" -#include "SkScalarCompare.h" #include "SkString.h" #ifdef SK_SCALAR_IS_FLOAT @@ -251,7 +250,7 @@ bool SkMatrix::preservesRightAngles(SkScalar tol) const { /////////////////////////////////////////////////////////////////////////////// void SkMatrix::setTranslate(SkScalar dx, SkScalar dy) { - if (SkScalarToCompareType(dx) || SkScalarToCompareType(dy)) { + if (dx || dy) { fMat[kMTransX] = dx; fMat[kMTransY] = dy; @@ -273,7 +272,7 @@ bool SkMatrix::preTranslate(SkScalar dx, SkScalar dy) { return this->preConcat(m); } - if (SkScalarToCompareType(dx) || SkScalarToCompareType(dy)) { + if (dx || dy) { fMat[kMTransX] += SkScalarMul(fMat[kMScaleX], dx) + SkScalarMul(fMat[kMSkewX], dy); fMat[kMTransY] += SkScalarMul(fMat[kMSkewY], dx) + @@ -291,7 +290,7 @@ bool SkMatrix::postTranslate(SkScalar dx, SkScalar dy) { return this->postConcat(m); } - if (SkScalarToCompareType(dx) || SkScalarToCompareType(dy)) { + if (dx || dy) { fMat[kMTransX] += dx; fMat[kMTransY] += dy; this->setTypeMask(kUnknown_Mask | kOnlyPerspectiveValid_Mask); |