diff options
-rw-r--r-- | gm/bitmaprecttest.cpp | 12 | ||||
-rw-r--r-- | src/core/SkBitmapProcState.cpp | 8 |
2 files changed, 19 insertions, 1 deletions
diff --git a/gm/bitmaprecttest.cpp b/gm/bitmaprecttest.cpp index 54e0a28267..cade0a7193 100644 --- a/gm/bitmaprecttest.cpp +++ b/gm/bitmaprecttest.cpp @@ -15,6 +15,13 @@ static void make_bm(SkBitmap* bm) { SkCanvas canvas(*bm); SkPaint paint; + + SkPath path; + path.moveTo(6, 6); + path.lineTo(6, 54); + path.lineTo(30, 54); + canvas.drawPath(path, paint); + paint.setStyle(SkPaint::kStroke_Style); canvas.drawRect(SkRect::MakeLTRB(0.5f, 0.5f, 59.5f, 59.5f), paint); } @@ -34,8 +41,13 @@ static void test_bitmaprect(SkCanvas* canvas) { canvas->drawBitmap(bm, 150, 45, NULL); SkScalar scale = 0.472560018f; + canvas->save(); canvas->scale(scale, scale); canvas->drawBitmapRectToRect(bm, NULL, SkRect::MakeXYWH(100, 100, 128, 128), NULL); + canvas->restore(); + + canvas->scale(-1, 1); + canvas->drawBitmap(bm, -310, 45, NULL); } class BitmapRectTestGM : public skiagm::GM { diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp index 5a4cf177fc..7d081d4ee5 100644 --- a/src/core/SkBitmapProcState.cpp +++ b/src/core/SkBitmapProcState.cpp @@ -45,7 +45,13 @@ static bool just_trans_clamp(const SkMatrix& matrix, const SkBitmap& bitmap) { if (matrix.getType() & SkMatrix::kScale_Mask) { SkRect src, dst; bitmap.getBounds(&src); - matrix.mapRect(&dst, src); + + // Can't call mapRect(), since that will fix up inverted rectangles, + // e.g. when scale is negative, and we don't want to return true for + // those. + matrix.mapPoints(SkTCast<SkPoint*>(&dst), + SkTCast<const SkPoint*>(&src), + 2); // Now round all 4 edges to device space, and then compare the device // width/height to the original. Note: we must map all 4 and subtract |