diff options
-rw-r--r-- | debugger/SkDebugCanvas.h | 2 | ||||
-rw-r--r-- | src/core/SkMatrix.cpp | 16 | ||||
-rw-r--r-- | src/core/SkMatrixUtils.h | 2 | ||||
-rw-r--r-- | tests/DrawBitmapRectTest.cpp | 8 |
4 files changed, 14 insertions, 14 deletions
diff --git a/debugger/SkDebugCanvas.h b/debugger/SkDebugCanvas.h index dc047c5d6d..a94663dcb2 100644 --- a/debugger/SkDebugCanvas.h +++ b/debugger/SkDebugCanvas.h @@ -165,7 +165,7 @@ public: const SkPoint pos[], const SkPaint&) SK_OVERRIDE; virtual void drawPosTextH(const void* text, size_t byteLength, - const SkScalar xpos[], SkScalar constY, + const SkScalar xpos[], SkScalar constY, const SkPaint&) SK_OVERRIDE; virtual void drawRect(const SkRect& rect, const SkPaint&) SK_OVERRIDE; diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp index 4845f59592..15d295cc27 100644 --- a/src/core/SkMatrix.cpp +++ b/src/core/SkMatrix.cpp @@ -1812,41 +1812,41 @@ bool SkTreatAsSprite(const SkMatrix& mat, const SkRect& src, if (mat.getType() & ~(SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask)) { return false; } - + // quick success check if (!subpixelBits && !(mat.getType() & ~SkMatrix::kTranslate_Mask)) { return true; } - + // mapRect supports negative scales, so we eliminate those first if (mat.getScaleX() < 0 || mat.getScaleY() < 0) { return false; } - + SkRect dst; SkIRect isrc, idst; - + mat.mapRect(&dst, src); - + { SkRect tmp = src; tmp.offset(mat.getTranslateX(), mat.getTranslateY()); tmp.round(&isrc); } - + if (subpixelBits) { isrc.fLeft <<= subpixelBits; isrc.fTop <<= subpixelBits; isrc.fRight <<= subpixelBits; isrc.fBottom <<= subpixelBits; - + const float scale = 1 << subpixelBits; dst.fLeft *= scale; dst.fTop *= scale; dst.fRight *= scale; dst.fBottom *= scale; } - + dst.round(&idst); return isrc == idst; } diff --git a/src/core/SkMatrixUtils.h b/src/core/SkMatrixUtils.h index db7370c97c..04c0892776 100644 --- a/src/core/SkMatrixUtils.h +++ b/src/core/SkMatrixUtils.h @@ -27,6 +27,6 @@ * of subpixel-bits to simulate filtering. */ bool SkTreatAsSprite(const SkMatrix&, const SkRect& src, unsigned subpixelBits); - + #endif diff --git a/tests/DrawBitmapRectTest.cpp b/tests/DrawBitmapRectTest.cpp index 0a8d730a97..df5f2f5a41 100644 --- a/tests/DrawBitmapRectTest.cpp +++ b/tests/DrawBitmapRectTest.cpp @@ -50,7 +50,7 @@ static void test_treatAsSprite(skiatest::Reporter* reporter) { REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, r, 0)); } } - + // assert: rotate/perspect is never treated as sprite for (int i = 0; i < 1000; ++i) { rand_matrix(&mat, rand, SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask); @@ -74,19 +74,19 @@ static void test_treatAsSprite(skiatest::Reporter* reporter) { REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, r, bilerBits)); mat.setTranslate(0, tinySubPixel); REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, r, bilerBits)); - + const SkScalar twoThirds = SK_Scalar1 * 2 / 3; const SkScalar bigScale = SkScalarDiv(r.width() + twoThirds, r.width()); mat.setScale(bigScale, bigScale); REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, r, false)); REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, r, bilerBits)); - + const SkScalar oneThird = SK_Scalar1 / 3; const SkScalar smallScale = SkScalarDiv(r.width() + oneThird, r.width()); mat.setScale(smallScale, smallScale); REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, r, false)); REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, r, bilerBits)); - + const SkScalar oneFortyth = SK_Scalar1 / 40; const SkScalar tinyScale = SkScalarDiv(r.width() + oneFortyth, r.width()); mat.setScale(tinyScale, tinyScale); |