add src-rect-constraint to drawImageRect
authorreed <reed@google.com>
Tue, 14 Jul 2015 17:54:12 +0000 (10:54 -0700)
committerCommit bot <commit-bot@chromium.org>
Tue, 14 Jul 2015 17:54:12 +0000 (10:54 -0700)
Follow-on work
- unify around SrcRectConstraint (i.e. drawBitmapRect)
- remove silly drawBitmapRectToRect alias
- clean-up (possibly remove) alias problems around drawBitmapRect + IRect parameter

BUG=skia:

Review URL: https://codereview.chromium.org/1228083004

49 files changed:
gm/bigtileimagefilter.cpp
gm/bitmaprect.cpp
gm/bitmaprecttest.cpp
gm/bleed.cpp
gm/convexpolyclip.cpp
include/core/SkBitmapDevice.h
include/core/SkCanvas.h
include/core/SkDevice.h
include/utils/SkDeferredCanvas.h
include/utils/SkDumpCanvas.h
include/utils/SkLuaCanvas.h
include/utils/SkNWayCanvas.h
include/utils/SkPaintFilterCanvas.h
src/core/SkBitmapDevice.cpp
src/core/SkCanvas.cpp
src/core/SkDevice.cpp
src/core/SkMiniRecorder.cpp
src/core/SkMiniRecorder.h
src/core/SkPictureFlat.h
src/core/SkPicturePlayback.cpp
src/core/SkPictureRecord.cpp
src/core/SkPictureRecord.h
src/core/SkRecordDraw.cpp
src/core/SkRecorder.cpp
src/core/SkRecorder.h
src/core/SkRecords.h
src/effects/SkBitmapSource.cpp
src/gpu/GrRecordReplaceDraw.cpp
src/gpu/SkGpuDevice.cpp
src/gpu/SkGpuDevice.h
src/pdf/SkPDFDevice.cpp
src/pdf/SkPDFDevice.h
src/pipe/SkGPipePriv.h
src/pipe/SkGPipeRead.cpp
src/pipe/SkGPipeWrite.cpp
src/svg/SkSVGDevice.cpp
src/svg/SkSVGDevice.h
src/utils/SkDeferredCanvas.cpp
src/utils/SkDumpCanvas.cpp
src/utils/SkLuaCanvas.cpp
src/utils/SkNWayCanvas.cpp
src/utils/SkPaintFilterCanvas.cpp
src/utils/android/SkAndroidSDKCanvas.cpp
src/utils/android/SkAndroidSDKCanvas.h
src/utils/debugger/SkDebugCanvas.cpp
src/utils/debugger/SkDebugCanvas.h
src/utils/debugger/SkDrawCommand.cpp
src/utils/debugger/SkDrawCommand.h
tests/RecordDrawTest.cpp

index f465fe4d38c0a5a67f14d207ecb2a1dc8cc21202..e4855ba9aa5a0bd20e64ffd52d30a3878a1e29fb 100644 (file)
@@ -84,7 +84,8 @@ protected:
             SkRect bound3 = SkRect::MakeXYWH(320, 320,
                                              SkIntToScalar(kBitmapSize),
                                              SkIntToScalar(kBitmapSize));
-            canvas->drawBitmapRectToRect(fGreenBitmap, &bound2, bound3);
+            canvas->drawBitmapRect(fGreenBitmap, &bound2, bound3, NULL,
+                                   SkCanvas::kStrict_SrcRectConstraint);
             canvas->restore();
         }
     }
index aa71f48eb09ae115f82b0388ff40bcd83f424086..ff52c15e5d9963cf570ced85c7c0a284c2b8c0ef 100644 (file)
@@ -70,7 +70,8 @@ protected:
 
             canvas->drawBitmap(bitmap, 0, 0, &paint);
             if (!fUseIRect) {
-                canvas->drawBitmapRectToRect(bitmap, &srcR, dstR, &paint);
+                canvas->drawBitmapRect(bitmap, &srcR, dstR, &paint,
+                                       SkCanvas::kStrict_SrcRectConstraint);
             } else {
                 canvas->drawBitmapRect(bitmap, &src[i], dstR, &paint);
             }
@@ -110,7 +111,7 @@ static void make_3x3_bitmap(SkBitmap* bitmap) {
     }
 }
 
-// This GM attempts to make visible any issues drawBitmapRectToRect may have
+// This GM attempts to make visible any issues drawBitmapRect may have
 // with partial source rects. In this case the eight pixels on the border
 // should be half the width/height of the central pixel, i.e.:
 //                         __|____|__
index eaa7a3a7439da890a9f59f62bdc6d59a567a81fd..6f2ccf211ea759b33efe0201d3c6eef9f91aa24d 100644 (file)
@@ -42,7 +42,7 @@ static void test_bitmaprect(SkCanvas* canvas) {
     SkScalar scale = 0.472560018f;
     canvas->save();
     canvas->scale(scale, scale);
-    canvas->drawBitmapRectToRect(bm, NULL, SkRect::MakeXYWH(100, 100, 128, 128), NULL);
+    canvas->drawBitmapRect(bm, SkRect::MakeXYWH(100, 100, 128, 128));
     canvas->restore();
 
     canvas->scale(-1, 1);
index a96917baa227439e26c18d50b2db13d477037b0f..5bef31dfc1f9c2bdfaeb3209c90b87f82c75bb06 100644 (file)
@@ -9,12 +9,39 @@
 #include "SkBlurMask.h"
 #include "SkBlurMaskFilter.h"
 #include "SkCanvas.h"
+#include "SkImage.h"
 
 #if SK_SUPPORT_GPU
 #include "GrContext.h"
 #include "GrContextOptions.h"
 #endif
 
+static void draw_bitmap_rect(SkCanvas* canvas, const SkBitmap& bitmap, const SkImage*,
+                             const SkRect* src, const SkRect& dst,
+                             const SkPaint* paint, SkCanvas::SrcRectConstraint constraint) {
+    canvas->drawBitmapRect(bitmap, src, dst, paint, constraint);
+}
+
+static void draw_image_rect(SkCanvas* canvas, const SkBitmap&, const SkImage* image,
+                            const SkRect* src, const SkRect& dst,
+                            const SkPaint* paint, SkCanvas::SrcRectConstraint constraint) {
+    canvas->drawImageRect(image, src, dst, paint, constraint);
+}
+
+enum BleedTest {
+    kUseBitmap_BleedTest,
+    kUseImage_BleedTest,
+};
+
+const struct {
+    const char* fName;
+    void (*fDraw)(SkCanvas*, const SkBitmap&, const SkImage*, const SkRect*, const SkRect&,
+                  const SkPaint*, SkCanvas::SrcRectConstraint);
+} gBleedRec[] = {
+    { "bleed",          draw_bitmap_rect },
+    { "bleed_image",    draw_image_rect },
+};
+
 // Create a black&white checked texture with 2 1-pixel rings
 // around the outside edge. The inner ring is red and the outer ring is blue.
 static void make_ringed_bitmap(SkBitmap* result, int width, int height) {
@@ -80,15 +107,15 @@ static void make_ringed_bitmap(SkBitmap* result, int width, int height) {
     result->setImmutable();
 }
 
-// This GM exercises the drawBitmapRectToRect "bleed" flag
+// This GM exercises the drawBitmapRect constraints
 class BleedGM : public skiagm::GM {
 public:
-    BleedGM() {}
+    BleedGM(BleedTest bt) : fBT(bt) {}
 
 protected:
 
     SkString onShortName() override {
-        return SkString("bleed");
+        return SkString(gBleedRec[fBT].fName);
     }
 
     SkISize onISize() override {
@@ -97,81 +124,75 @@ protected:
 
     void onOnceBeforeDraw() override {
         make_ringed_bitmap(&fBitmapSmall, kSmallTextureSize, kSmallTextureSize);
+        fImageSmall.reset(SkImage::NewFromBitmap(fBitmapSmall));
 
         // To exercise the GPU's tiling path we need a texture
         // too big for the GPU to handle in one go
         make_ringed_bitmap(&fBitmapBig, 2*kMaxTextureSize, 2*kMaxTextureSize);
+        fImageBig.reset(SkImage::NewFromBitmap(fBitmapBig));
     }
 
     // Draw only the center of the small bitmap
     void drawCase1(SkCanvas* canvas, int transX, int transY,
-                   SkCanvas::DrawBitmapRectFlags flags, SkFilterQuality filter) {
+                   SkCanvas::SrcRectConstraint constraint, SkFilterQuality filter) {
         SkRect src = SkRect::MakeXYWH(2, 2,
                                       SkIntToScalar(kSmallTextureSize-4),
                                       SkIntToScalar(kSmallTextureSize-4));
-        SkRect dst = SkRect::MakeXYWH(0, 0, SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize));
+        SkRect dst = SkRect::MakeXYWH(SkIntToScalar(transX), SkIntToScalar(transY),
+                                      SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize));
 
         SkPaint paint;
         paint.setFilterQuality(filter);
 
-        canvas->save();
-        canvas->translate(SkIntToScalar(transX), SkIntToScalar(transY));
-        canvas->drawBitmapRectToRect(fBitmapSmall, &src, dst, &paint, flags);
-        canvas->restore();
+        gBleedRec[fBT].fDraw(canvas, fBitmapSmall, fImageSmall, &src, dst, &paint, constraint);
     }
 
     // Draw almost all of the large bitmap
     void drawCase2(SkCanvas* canvas, int transX, int transY,
-                   SkCanvas::DrawBitmapRectFlags flags, SkFilterQuality filter) {
+                   SkCanvas::SrcRectConstraint constraint, SkFilterQuality filter) {
         SkRect src = SkRect::MakeXYWH(2, 2,
                                       SkIntToScalar(fBitmapBig.width()-4),
                                       SkIntToScalar(fBitmapBig.height()-4));
-        SkRect dst = SkRect::MakeXYWH(0, 0, SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize));
+        SkRect dst = SkRect::MakeXYWH(SkIntToScalar(transX), SkIntToScalar(transY),
+                                      SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize));
 
         SkPaint paint;
         paint.setFilterQuality(filter);
 
-        canvas->save();
-        canvas->translate(SkIntToScalar(transX), SkIntToScalar(transY));
-        canvas->drawBitmapRectToRect(fBitmapBig, &src, dst, &paint, flags);
-        canvas->restore();
+        gBleedRec[fBT].fDraw(canvas, fBitmapBig, fImageBig, &src, dst, &paint, constraint);
     }
 
     // Draw ~1/4 of the large bitmap
     void drawCase3(SkCanvas* canvas, int transX, int transY,
-                   SkCanvas::DrawBitmapRectFlags flags, SkFilterQuality filter) {
+                   SkCanvas::SrcRectConstraint constraint, SkFilterQuality filter) {
         SkRect src = SkRect::MakeXYWH(2, 2,
                                       SkIntToScalar(fBitmapBig.width()/2-2),
                                       SkIntToScalar(fBitmapBig.height()/2-2));
-        SkRect dst = SkRect::MakeXYWH(0, 0, SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize));
+        SkRect dst = SkRect::MakeXYWH(SkIntToScalar(transX), SkIntToScalar(transY),
+                                      SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize));
 
         SkPaint paint;
         paint.setFilterQuality(filter);
 
-        canvas->save();
-        canvas->translate(SkIntToScalar(transX), SkIntToScalar(transY));
-        canvas->drawBitmapRectToRect(fBitmapBig, &src, dst, &paint, flags);
-        canvas->restore();
+        gBleedRec[fBT].fDraw(canvas, fBitmapBig, fImageBig, &src, dst, &paint, constraint);
     }
 
     // Draw the center of the small bitmap with a mask filter
     void drawCase4(SkCanvas* canvas, int transX, int transY,
-                   SkCanvas::DrawBitmapRectFlags flags, SkFilterQuality filter) {
+                   SkCanvas::SrcRectConstraint constraint, SkFilterQuality filter) {
         SkRect src = SkRect::MakeXYWH(2, 2,
                                       SkIntToScalar(kSmallTextureSize-4),
                                       SkIntToScalar(kSmallTextureSize-4));
-        SkRect dst = SkRect::MakeXYWH(0, 0, SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize));
+        SkRect dst = SkRect::MakeXYWH(SkIntToScalar(transX), SkIntToScalar(transY),
+                                      SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize));
 
         SkPaint paint;
         paint.setFilterQuality(filter);
         SkMaskFilter* mf = SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
-                                         SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(3)));
+                                         SkBlurMask::ConvertRadiusToSigma(3));
         paint.setMaskFilter(mf)->unref();
 
-        canvas->save();
-        canvas->translate(SkIntToScalar(transX), SkIntToScalar(transY));
-        canvas->drawBitmapRectToRect(fBitmapSmall, &src, dst, &paint, flags);
-        canvas->restore();
+        gBleedRec[fBT].fDraw(canvas, fBitmapSmall, fImageSmall, &src, dst, &paint, constraint);
     }
 
     void onDraw(SkCanvas* canvas) override {
@@ -190,40 +211,40 @@ protected:
             }
 
             // First draw a column with no bleeding and no filtering
-            this->drawCase1(canvas, kCol0X, kRow0Y, SkCanvas::kNone_DrawBitmapRectFlag, kNone_SkFilterQuality);
-            this->drawCase2(canvas, kCol0X, kRow1Y, SkCanvas::kNone_DrawBitmapRectFlag, kNone_SkFilterQuality);
-            this->drawCase3(canvas, kCol0X, kRow2Y, SkCanvas::kNone_DrawBitmapRectFlag, kNone_SkFilterQuality);
-            this->drawCase4(canvas, kCol0X, kRow3Y, SkCanvas::kNone_DrawBitmapRectFlag, kNone_SkFilterQuality);
+            this->drawCase1(canvas, kCol0X, kRow0Y, SkCanvas::kStrict_SrcRectConstraint, kNone_SkFilterQuality);
+            this->drawCase2(canvas, kCol0X, kRow1Y, SkCanvas::kStrict_SrcRectConstraint, kNone_SkFilterQuality);
+            this->drawCase3(canvas, kCol0X, kRow2Y, SkCanvas::kStrict_SrcRectConstraint, kNone_SkFilterQuality);
+            this->drawCase4(canvas, kCol0X, kRow3Y, SkCanvas::kStrict_SrcRectConstraint, kNone_SkFilterQuality);
 
             // Then draw a column with no bleeding and low filtering
-            this->drawCase1(canvas, kCol1X, kRow0Y, SkCanvas::kNone_DrawBitmapRectFlag, kLow_SkFilterQuality);
-            this->drawCase2(canvas, kCol1X, kRow1Y, SkCanvas::kNone_DrawBitmapRectFlag, kLow_SkFilterQuality);
-            this->drawCase3(canvas, kCol1X, kRow2Y, SkCanvas::kNone_DrawBitmapRectFlag, kLow_SkFilterQuality);
-            this->drawCase4(canvas, kCol1X, kRow3Y, SkCanvas::kNone_DrawBitmapRectFlag, kLow_SkFilterQuality);
+            this->drawCase1(canvas, kCol1X, kRow0Y, SkCanvas::kStrict_SrcRectConstraint, kLow_SkFilterQuality);
+            this->drawCase2(canvas, kCol1X, kRow1Y, SkCanvas::kStrict_SrcRectConstraint, kLow_SkFilterQuality);
+            this->drawCase3(canvas, kCol1X, kRow2Y, SkCanvas::kStrict_SrcRectConstraint, kLow_SkFilterQuality);
+            this->drawCase4(canvas, kCol1X, kRow3Y, SkCanvas::kStrict_SrcRectConstraint, kLow_SkFilterQuality);
 
             // Then draw a column with no bleeding and high filtering
-            this->drawCase1(canvas, kCol2X, kRow0Y, SkCanvas::kNone_DrawBitmapRectFlag, kHigh_SkFilterQuality);
-            this->drawCase2(canvas, kCol2X, kRow1Y, SkCanvas::kNone_DrawBitmapRectFlag, kHigh_SkFilterQuality);
-            this->drawCase3(canvas, kCol2X, kRow2Y, SkCanvas::kNone_DrawBitmapRectFlag, kHigh_SkFilterQuality);
-            this->drawCase4(canvas, kCol2X, kRow3Y, SkCanvas::kNone_DrawBitmapRectFlag, kHigh_SkFilterQuality);
+            this->drawCase1(canvas, kCol2X, kRow0Y, SkCanvas::kStrict_SrcRectConstraint, kHigh_SkFilterQuality);
+            this->drawCase2(canvas, kCol2X, kRow1Y, SkCanvas::kStrict_SrcRectConstraint, kHigh_SkFilterQuality);
+            this->drawCase3(canvas, kCol2X, kRow2Y, SkCanvas::kStrict_SrcRectConstraint, kHigh_SkFilterQuality);
+            this->drawCase4(canvas, kCol2X, kRow3Y, SkCanvas::kStrict_SrcRectConstraint, kHigh_SkFilterQuality);
 
             // Then draw a column with bleeding and no filtering (bleed should have no effect w/out blur)
-            this->drawCase1(canvas, kCol3X, kRow0Y, SkCanvas::kBleed_DrawBitmapRectFlag, kNone_SkFilterQuality);
-            this->drawCase2(canvas, kCol3X, kRow1Y, SkCanvas::kBleed_DrawBitmapRectFlag, kNone_SkFilterQuality);
-            this->drawCase3(canvas, kCol3X, kRow2Y, SkCanvas::kBleed_DrawBitmapRectFlag, kNone_SkFilterQuality);
-            this->drawCase4(canvas, kCol3X, kRow3Y, SkCanvas::kBleed_DrawBitmapRectFlag, kNone_SkFilterQuality);
+            this->drawCase1(canvas, kCol3X, kRow0Y, SkCanvas::kFast_SrcRectConstraint, kNone_SkFilterQuality);
+            this->drawCase2(canvas, kCol3X, kRow1Y, SkCanvas::kFast_SrcRectConstraint, kNone_SkFilterQuality);
+            this->drawCase3(canvas, kCol3X, kRow2Y, SkCanvas::kFast_SrcRectConstraint, kNone_SkFilterQuality);
+            this->drawCase4(canvas, kCol3X, kRow3Y, SkCanvas::kFast_SrcRectConstraint, kNone_SkFilterQuality);
 
             // Then draw a column with bleeding and low filtering
-            this->drawCase1(canvas, kCol4X, kRow0Y, SkCanvas::kBleed_DrawBitmapRectFlag, kLow_SkFilterQuality);
-            this->drawCase2(canvas, kCol4X, kRow1Y, SkCanvas::kBleed_DrawBitmapRectFlag, kLow_SkFilterQuality);
-            this->drawCase3(canvas, kCol4X, kRow2Y, SkCanvas::kBleed_DrawBitmapRectFlag, kLow_SkFilterQuality);
-            this->drawCase4(canvas, kCol4X, kRow3Y, SkCanvas::kBleed_DrawBitmapRectFlag, kLow_SkFilterQuality);
+            this->drawCase1(canvas, kCol4X, kRow0Y, SkCanvas::kFast_SrcRectConstraint, kLow_SkFilterQuality);
+            this->drawCase2(canvas, kCol4X, kRow1Y, SkCanvas::kFast_SrcRectConstraint, kLow_SkFilterQuality);
+            this->drawCase3(canvas, kCol4X, kRow2Y, SkCanvas::kFast_SrcRectConstraint, kLow_SkFilterQuality);
+            this->drawCase4(canvas, kCol4X, kRow3Y, SkCanvas::kFast_SrcRectConstraint, kLow_SkFilterQuality);
 
             // Finally draw a column with bleeding and high filtering
-            this->drawCase1(canvas, kCol5X, kRow0Y, SkCanvas::kBleed_DrawBitmapRectFlag, kHigh_SkFilterQuality);
-            this->drawCase2(canvas, kCol5X, kRow1Y, SkCanvas::kBleed_DrawBitmapRectFlag, kHigh_SkFilterQuality);
-            this->drawCase3(canvas, kCol5X, kRow2Y, SkCanvas::kBleed_DrawBitmapRectFlag, kHigh_SkFilterQuality);
-            this->drawCase4(canvas, kCol5X, kRow3Y, SkCanvas::kBleed_DrawBitmapRectFlag, kHigh_SkFilterQuality);
+            this->drawCase1(canvas, kCol5X, kRow0Y, SkCanvas::kFast_SrcRectConstraint, kHigh_SkFilterQuality);
+            this->drawCase2(canvas, kCol5X, kRow1Y, SkCanvas::kFast_SrcRectConstraint, kHigh_SkFilterQuality);
+            this->drawCase3(canvas, kCol5X, kRow2Y, SkCanvas::kFast_SrcRectConstraint, kHigh_SkFilterQuality);
+            this->drawCase4(canvas, kCol5X, kRow3Y, SkCanvas::kFast_SrcRectConstraint, kHigh_SkFilterQuality);
 
             canvas->restore();
         }
@@ -257,8 +278,12 @@ private:
 
     SkBitmap fBitmapSmall;
     SkBitmap fBitmapBig;
+    SkAutoTUnref<SkImage> fImageSmall;
+    SkAutoTUnref<SkImage> fImageBig;
+    const BleedTest fBT;
 
     typedef GM INHERITED;
 };
 
-DEF_GM( return new BleedGM(); )
+DEF_GM( return new BleedGM(kUseBitmap_BleedTest); )
+DEF_GM( return new BleedGM(kUseImage_BleedTest); )
index 2eabebac62ba3b2de2b160d820bdc53861636d04..c1df69e3b7c8bd8c062f15d9f51b6b0b420b600a 100644 (file)
@@ -144,9 +144,7 @@ protected:
         SkPaint bgPaint;
         bgPaint.setAlpha(0x15);
         SkISize size = canvas->getDeviceSize();
-        SkRect dstRect = SkRect::MakeWH(SkIntToScalar(size.fWidth),
-                                        SkIntToScalar(size.fHeight));
-        canvas->drawBitmapRectToRect(fBmp, NULL, dstRect, &bgPaint);
+        canvas->drawBitmapRect(fBmp, SkRect::MakeIWH(size.fWidth, size.fHeight), &bgPaint);
 
         static const char kTxt[] = "Clip Me!";
         SkPaint txtPaint;
index db088ad0fa3d65c945936a51577235f1429e0bb7..ff33ebee714fbe2925db6d236be3d4e10c4fa95a 100644 (file)
@@ -81,10 +81,8 @@ protected:
      *  The default impl. will create a bitmap-shader from the bitmap,
      *  and call drawRect with it.
      */
-    virtual void drawBitmapRect(const SkDraw&, const SkBitmap&,
-                                const SkRect* srcOrNull, const SkRect& dst,
-                                const SkPaint& paint,
-                                SkCanvas::DrawBitmapRectFlags flags) override;
+    void drawBitmapRect(const SkDraw&, const SkBitmap&, const SkRect*, const SkRect&,
+                        const SkPaint&, SK_VIRTUAL_CONSTRAINT_TYPE) override;
 
     /**
      *  Does not handle text decoration.
index 9a46801a98bb3fe638f9ef5cd5eacb33ad30d982..ca6818518d74078401d0d73a1b3cfdc61d842010 100644 (file)
@@ -35,8 +35,22 @@ class SkTextBlob;
 class GrContext;
 class GrRenderTarget;
 
+//#define SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
+
 class SkCanvasState;
 
+#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
+    #define SK_VIRTUAL_CONSTRAINT_TYPE          SkCanvas::DrawBitmapRectFlags
+    #define SRC_RECT_CONSTRAINT_PARAM(param)
+    #define SRC_RECT_CONSTRAINT_ARG(arg)
+    #define SRC_RECT_CONSTRAINT_LOCAL_DEFAULT(var)  SkCanvas::SrcRectConstraint var = SkCanvas::kStrict_SrcRectConstraint;
+#else
+    #define SK_VIRTUAL_CONSTRAINT_TYPE          SkCanvas::SrcRectConstraint
+    #define SRC_RECT_CONSTRAINT_PARAM(param)    , SrcRectConstraint param
+    #define SRC_RECT_CONSTRAINT_ARG(arg)        , arg
+    #define SRC_RECT_CONSTRAINT_LOCAL_DEFAULT(var)
+#endif
+
 /** \class SkCanvas
 
     A Canvas encapsulates all of the state about drawing into a device (bitmap).
@@ -778,17 +792,59 @@ public:
         @param paint    The paint used to draw the image, or NULL
      */
     void drawImage(const SkImage* image, SkScalar left, SkScalar top, const SkPaint* paint = NULL);
-    /** Draw the specified image, with the specified matrix applied (before the
-        canvas' matrix is applied).
 
-        @param image   The image to be drawn
-        @param src      Optional: specify the subset of the image to be drawn
-        @param dst      The destination rectangle where the scaled/translated
-                        image will be drawn
-        @param paint    The paint used to draw the image, or NULL
-    */
+    /**
+     *  Controls the behavior at the edge of the src-rect, when specified in drawImageRect,
+     *  trading off speed for exactness.
+     *
+     *  When filtering is enabled (in the Paint), skia may need to sample in a neighborhood around
+     *  the pixels in the image. If there is a src-rect specified, it is intended to restrict the
+     *  pixels that will be read. However, for performance reasons, some implementations may slow
+     *  down if they cannot read 1-pixel past the src-rect boundary at times.
+     *
+     *  This enum allows the caller to specify if such a 1-pixel "slop" will be visually acceptable.
+     *  If it is, the caller should pass kFast, and it may result in a faster draw. If the src-rect
+     *  must be strictly respected, the caller should pass kStrict.
+     */
+    enum SrcRectConstraint {
+        /**
+         *  If kStrict is specified, the implementation must respect the src-rect
+         *  (if specified) strictly, and will never sample outside of those bounds during sampling
+         *  even when filtering. This may be slower than kFast.
+         */
+        kStrict_SrcRectConstraint,
+
+        /**
+         *  If kFast is specified, the implementation may sample outside of the src-rect
+         *  (if specified) by at most 1 pixel when filtering. This allows greater flexibility
+         *  to the implementation and can make the draw much faster.
+         */
+        kFast_SrcRectConstraint,
+    };
+
+    /** Draw the specified image, scaling and translating so that it fills the specified
+     *  dst rect. If the src rect is non-null, only that subset of the image is transformed
+     *  and drawn.
+     *
+     *  @param image      The image to be drawn
+     *  @param src        Optional: specify the subset of the image to be drawn
+     *  @param dst        The destination rectangle where the scaled/translated
+     *                    image will be drawn
+     *  @param paint      The paint used to draw the image, or NULL
+     *  @param constraint Control the tradeoff between speed and exactness w.r.t. the src-rect.
+     */
     void drawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
-                       const SkPaint* paint = NULL);
+                       const SkPaint* paint, SrcRectConstraint);
+
+    void drawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
+                       const SkPaint* paint = NULL) {
+        this->drawImageRect(image, src, dst, paint, kStrict_SrcRectConstraint);
+    }
+
+    void drawImageRect(const SkImage* image, const SkRect& dst, const SkPaint* paint = NULL) {
+        // With no src-rect, the constraint value is ignored, so we just use the default.
+        this->drawImageRect(image, NULL, dst, paint, kStrict_SrcRectConstraint);
+    }
 
     /**
      *  Draw the image stretched differentially to fit into dst.
@@ -826,6 +882,25 @@ public:
     void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
                     const SkPaint* paint = NULL);
 
+    /** Draw the specified bitmap, scaling and translating so that it fills the specified
+     *  dst rect. If the src rect is non-null, only that subset of the bitmap is transformed
+     *  and drawn.
+     *
+     *  @param bitmap     The bitmap to be drawn
+     *  @param src        Optional: specify the subset of the bitmap to be drawn
+     *  @param dst        The destination rectangle where the scaled/translated
+     *                    bitmap will be drawn
+     *  @param paint      The paint used to draw the bitmap, or NULL
+     *  @param constraint Control the tradeoff between speed and exactness w.r.t. the src-rect.
+     */
+    void drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
+                        const SkPaint* paint, SrcRectConstraint);
+
+    void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint* paint = NULL) {
+        this->drawBitmapRect(bitmap, NULL, dst, paint, kStrict_SrcRectConstraint);
+    }
+
+    // IMPORTANT that thse be value-equal with SrcRectConstraint (during transition period)
     enum DrawBitmapRectFlags {
         kNone_DrawBitmapRectFlag            = 0x0,
         /**
@@ -848,11 +923,6 @@ public:
                               const SkPaint* paint = NULL,
                               DrawBitmapRectFlags flags = kNone_DrawBitmapRectFlag);
 
-    void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst,
-                        const SkPaint* paint = NULL) {
-        this->drawBitmapRectToRect(bitmap, NULL, dst, paint, kNone_DrawBitmapRectFlag);
-    }
-
     void drawBitmapRect(const SkBitmap& bitmap, const SkIRect* isrc,
                         const SkRect& dst, const SkPaint* paint = NULL,
                         DrawBitmapRectFlags flags = kNone_DrawBitmapRectFlag) {
@@ -1245,13 +1315,14 @@ protected:
                              int count, SkXfermode::Mode, const SkRect* cull, const SkPaint*);
     virtual void onDrawPath(const SkPath&, const SkPaint&);
     virtual void onDrawImage(const SkImage*, SkScalar dx, SkScalar dy, const SkPaint*);
-    virtual void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*);
+    virtual void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*
+                                 SRC_RECT_CONSTRAINT_PARAM(constraint));
     virtual void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst,
                                  const SkPaint*);
 
     virtual void onDrawBitmap(const SkBitmap&, SkScalar dx, SkScalar dy, const SkPaint*);
     virtual void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*,
-                                  DrawBitmapRectFlags);
+                                  SK_VIRTUAL_CONSTRAINT_TYPE);
     virtual void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
                                   const SkPaint*);
     virtual void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*);
@@ -1365,7 +1436,7 @@ private:
     void internalDrawBitmap(const SkBitmap&, const SkMatrix& m, const SkPaint* paint);
     void internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
                                 const SkRect& dst, const SkPaint* paint,
-                                DrawBitmapRectFlags flags);
+                                SrcRectConstraint);
     void internalDrawPaint(const SkPaint& paint);
     void internalSaveLayer(const SkRect* bounds, const SkPaint*, SaveFlags, SaveLayerStrategy);
     void internalDrawDevice(SkBaseDevice*, int x, int y, const SkPaint*, bool isBitmapDevice);
index 3f556f6939cca93bf0926f66d18044cc2095e171..7be49e323bacfc9d862fa1a397cd2e8c8566e9a1 100644 (file)
@@ -217,13 +217,13 @@ protected:
     virtual void drawBitmapRect(const SkDraw&, const SkBitmap&,
                                 const SkRect* srcOrNull, const SkRect& dst,
                                 const SkPaint& paint,
-                                SkCanvas::DrawBitmapRectFlags flags) = 0;
+                                SK_VIRTUAL_CONSTRAINT_TYPE) = 0;
     virtual void drawBitmapNine(const SkDraw&, const SkBitmap&, const SkIRect& center,
                                const SkRect& dst, const SkPaint&);
 
     virtual void drawImage(const SkDraw&, const SkImage*, SkScalar x, SkScalar y, const SkPaint&);
     virtual void drawImageRect(const SkDraw&, const SkImage*, const SkRect* src, const SkRect& dst,
-                               const SkPaint&);
+                               const SkPaint&, SkCanvas::SrcRectConstraint);
     virtual void drawImageNine(const SkDraw&, const SkImage*, const SkIRect& center,
                                const SkRect& dst, const SkPaint&);
 
index 1f5b12a4175596ca30a818dae56da9ed13bfc291..60a3cb397a2d94ade46de413f457114fff7d912e 100644 (file)
@@ -174,10 +174,10 @@ protected:
     void onDrawPath(const SkPath&, const SkPaint&) override;
     void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
     void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
-                          DrawBitmapRectFlags flags) override;
+                          SK_VIRTUAL_CONSTRAINT_TYPE) override;
     void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
     void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
-                         const SkPaint*) override;
+                         const SkPaint* SRC_RECT_CONSTRAINT_PARAM(constraint)) override;
     void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst,
                          const SkPaint*) override;
     void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
index b825b39adfc278f43fbc1dfa0ecd4e3b384ea8de..8204c8b95b029702aadaea620e5fff33101b2e14 100644 (file)
@@ -102,10 +102,10 @@ protected:
     void onDrawPath(const SkPath&, const SkPaint&) override;
     void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
     void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
-                          DrawBitmapRectFlags flags) override;
+                          SK_VIRTUAL_CONSTRAINT_TYPE) override;
     void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
     void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
-                         const SkPaint*) override;
+                         const SkPaint* SRC_RECT_CONSTRAINT_PARAM(constraint)) override;
     void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
                           const SkPaint*) override;
     void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*) override;
index 0fd37daca1a7024fdc9e2040d40a638c59a30e42..4c4e92ec5040920829d88cec4799abdc6431a2ef 100644 (file)
@@ -48,10 +48,10 @@ protected:
     void onDrawPath(const SkPath&, const SkPaint&) override;
     void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
     void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
-                          DrawBitmapRectFlags flags) override;
+                          SK_VIRTUAL_CONSTRAINT_TYPE) override;
     void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
     void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
-                         const SkPaint*) override;
+                         const SkPaint* SRC_RECT_CONSTRAINT_PARAM(constraint)) override;
     void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
                           const SkPaint*) override;
     void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*) override;
index f478e1a1b6de69292e8d910fc95684fb1ec30728..18290d635f880a4ecc48e7da362ac9364fbdc72d 100644 (file)
@@ -58,10 +58,10 @@ protected:
     void onDrawPath(const SkPath&, const SkPaint&) override;
     void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
     void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
-                          DrawBitmapRectFlags flags) override;
+                          SK_VIRTUAL_CONSTRAINT_TYPE) override;
     void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
     void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
-                         const SkPaint*) override;
+                         const SkPaint* SRC_RECT_CONSTRAINT_PARAM(constraint)) override;
     void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
                           const SkPaint*) override;
     void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*) override;
index 942fbda8763d2cbaa7c623893748d1671aa91496..206e694b0e23e91aec9d36f48fb1eb08996e7055 100644 (file)
@@ -56,10 +56,10 @@ protected:
     void onDrawPath(const SkPath&, const SkPaint&) override;
     void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
     void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
-                          DrawBitmapRectFlags flags) override;
+                          SK_VIRTUAL_CONSTRAINT_TYPE) override;
     void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
     void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
-                         const SkPaint*) override;
+                         const SkPaint* SRC_RECT_CONSTRAINT_PARAM(constraint)) override;
     void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
                           const SkPaint*) override;
     void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*) override;
index b94daef41e635338888c1fd06dec7a394dcdde2b..388708d4751407a0097cc9b960226114f9801ba4 100644 (file)
@@ -237,8 +237,7 @@ void SkBitmapDevice::drawBitmap(const SkDraw& draw, const SkBitmap& bitmap,
 
 void SkBitmapDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap,
                                     const SkRect* src, const SkRect& dst,
-                                    const SkPaint& paint,
-                                    SkCanvas::DrawBitmapRectFlags flags) {
+                                    const SkPaint& paint, SK_VIRTUAL_CONSTRAINT_TYPE) {
     SkMatrix    matrix;
     SkRect      bitmapBounds, tmpSrc, tmpDst;
     SkBitmap    tmpBitmap;
index 09bfa4593588a3ca41880e87d87fc09f56cab10a..35551e7e9a1e88b64537369c190fbcfd4d0b9ec2 100644 (file)
@@ -1765,11 +1765,11 @@ void SkCanvas::drawImage(const SkImage* image, SkScalar x, SkScalar y, const SkP
 }
 
 void SkCanvas::drawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
-                             const SkPaint* paint) {
+                             const SkPaint* paint, SrcRectConstraint constraint) {
     if (dst.isEmpty()) {
         return;
     }
-    this->onDrawImageRect(image, src, dst, paint);
+    this->onDrawImageRect(image, src, dst, paint SRC_RECT_CONSTRAINT_ARG(constraint));
 }
 
 void SkCanvas::drawImageNine(const SkImage* image, const SkIRect& center, const SkRect& dst,
@@ -1795,7 +1795,15 @@ void SkCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, c
     if (bitmap.drawsNothing() || dst.isEmpty()) {
         return;
     }
-    this->onDrawBitmapRect(bitmap, src, dst, paint, flags);
+    this->onDrawBitmapRect(bitmap, src, dst, paint, (SK_VIRTUAL_CONSTRAINT_TYPE)flags);
+}
+
+void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
+                              const SkPaint* paint, SrcRectConstraint constraint) {
+    if (bitmap.drawsNothing() || dst.isEmpty()) {
+        return;
+    }
+    this->onDrawBitmapRect(bitmap, src, dst, paint, (SK_VIRTUAL_CONSTRAINT_TYPE)constraint);
 }
 
 void SkCanvas::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, const SkRect& dst,
@@ -1804,7 +1812,7 @@ void SkCanvas::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, con
         return;
     }
     if (!SkNinePatchIter::Valid(bitmap.width(), bitmap.height(), center)) {
-        this->drawBitmapRectToRect(bitmap, NULL, dst, paint);
+        this->drawBitmapRect(bitmap, dst, paint);
     }
     this->onDrawBitmapNine(bitmap, center, dst, paint);
 }
@@ -2042,8 +2050,9 @@ void SkCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, const S
 }
 
 void SkCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
-                               const SkPaint* paint) {
+                               const SkPaint* paint SRC_RECT_CONSTRAINT_PARAM(constraint)) {
     TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImageRect()");
+    SRC_RECT_CONSTRAINT_LOCAL_DEFAULT(constraint)
     SkRect storage;
     const SkRect* bounds = &dst;
     if (NULL == paint || paint->canComputeFastBounds()) {
@@ -2062,7 +2071,7 @@ void SkCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const Sk
     LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, bounds)
     
     while (iter.next()) {
-        iter.fDevice->drawImageRect(iter, image, src, dst, looper.paint());
+        iter.fDevice->drawImageRect(iter, image, src, dst, looper.paint(), constraint);
     }
     
     LOOPER_END
@@ -2094,7 +2103,7 @@ void SkCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, cons
 // this one is non-virtual, so it can be called safely by other canvas apis
 void SkCanvas::internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
                                       const SkRect& dst, const SkPaint* paint,
-                                      DrawBitmapRectFlags flags) {
+                                      SrcRectConstraint constraint) {
     if (bitmap.drawsNothing() || dst.isEmpty()) {
         return;
     }
@@ -2118,17 +2127,18 @@ void SkCanvas::internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
     LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, bounds)
 
     while (iter.next()) {
-        iter.fDevice->drawBitmapRect(iter, bitmap, src, dst, looper.paint(), flags);
+        iter.fDevice->drawBitmapRect(iter, bitmap, src, dst, looper.paint(),
+                                     (SK_VIRTUAL_CONSTRAINT_TYPE)constraint);
     }
 
     LOOPER_END
 }
 
 void SkCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
-                                const SkPaint* paint, DrawBitmapRectFlags flags) {
+                                const SkPaint* paint, SK_VIRTUAL_CONSTRAINT_TYPE constraint) {
     TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawBitmapRectToRect()");
     SkDEBUGCODE(bitmap.validate();)
-    this->internalDrawBitmapRect(bitmap, src, dst, paint, flags);
+    this->internalDrawBitmapRect(bitmap, src, dst, paint, (SrcRectConstraint)constraint);
 }
 
 void SkCanvas::onDrawImageNine(const SkImage* image, const SkIRect& center, const SkRect& dst,
index 90161b4eb386d3db240b1cc67e19f7fc572ba5b8..6922e0d7ce04e3e9d724728d81b02c0e4f207dce 100644 (file)
@@ -154,11 +154,12 @@ void SkBaseDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar
 }
 
 void SkBaseDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const SkRect* src,
-                                 const SkRect& dst, const SkPaint& paint) {
+                                 const SkRect& dst, const SkPaint& paint,
+                                 SkCanvas::SrcRectConstraint constraint) {
     // Default impl : turns everything into raster bitmap
     SkBitmap bm;
     if (as_IB(image)->getROPixels(&bm)) {
-        this->drawBitmapRect(draw, bm, src, dst, paint, SkCanvas::kNone_DrawBitmapRectFlag);
+        this->drawBitmapRect(draw, bm, src, dst, paint, (SK_VIRTUAL_CONSTRAINT_TYPE)constraint);
     }
 }
 
@@ -168,7 +169,7 @@ void SkBaseDevice::drawImageNine(const SkDraw& draw, const SkImage* image, const
 
     SkRect srcR, dstR;
     while (iter.next(&srcR, &dstR)) {
-        this->drawImageRect(draw, image, &srcR, dstR, paint);
+        this->drawImageRect(draw, image, &srcR, dstR, paint, SkCanvas::kStrict_SrcRectConstraint);
     }
 }
 
@@ -178,7 +179,8 @@ void SkBaseDevice::drawBitmapNine(const SkDraw& draw, const SkBitmap& bitmap, co
     
     SkRect srcR, dstR;
     while (iter.next(&srcR, &dstR)) {
-        this->drawBitmapRect(draw, bitmap, &srcR, dstR, paint, SkCanvas::kNone_DrawBitmapRectFlag);
+        this->drawBitmapRect(draw, bitmap, &srcR, dstR, paint,
+                             (SK_VIRTUAL_CONSTRAINT_TYPE)SkCanvas::kStrict_SrcRectConstraint);
     }
 }
 
index 538db087bf244294c301bde6047d84045bee60f8..916c47730b02510820bb618a1c66b02c7136f126 100644 (file)
@@ -72,8 +72,8 @@ SkMiniRecorder::~SkMiniRecorder() {
     new (fBuffer.get()) Type(__VA_ARGS__);         \
     return true
 
-bool SkMiniRecorder::drawBitmapRectToRect(const SkBitmap& bm, const SkRect* src, const SkRect& dst,
-                                          const SkPaint* p, SkCanvas::DrawBitmapRectFlags flags) {
+bool SkMiniRecorder::drawBitmapRect(const SkBitmap& bm, const SkRect* src, const SkRect& dst,
+                                    const SkPaint* p, SkCanvas::SrcRectConstraint constraint) {
     SkRect bounds;
     if (!src) {
         bm.getBounds(&bounds);
@@ -83,7 +83,7 @@ bool SkMiniRecorder::drawBitmapRectToRect(const SkBitmap& bm, const SkRect* src,
     if (!p) {
         p = defaultPaint.init();
     }
-    TRY_TO_STORE(DrawBitmapRectToRectFixedSize, *p, bm, *src, dst, flags);
+    TRY_TO_STORE(DrawBitmapRectFixedSize, *p, bm, *src, dst, constraint);
 }
 
 bool SkMiniRecorder::drawRect(const SkRect& rect, const SkPaint& paint) {
@@ -108,7 +108,7 @@ SkPicture* SkMiniRecorder::detachAsPicture(const SkRect& cull) {
 
     switch (fState) {
         case State::kEmpty: return SkRef(gEmptyPicture.get());
-        CASE(DrawBitmapRectToRectFixedSize);
+        CASE(DrawBitmapRectFixedSize);
         CASE(DrawPath);
         CASE(DrawRect);
         CASE(DrawTextBlob);
@@ -129,7 +129,7 @@ void SkMiniRecorder::flushAndReset(SkCanvas* canvas) {
 
     switch (fState) {
         case State::kEmpty: return;
-        CASE(DrawBitmapRectToRectFixedSize);
+        CASE(DrawBitmapRectFixedSize);
         CASE(DrawPath);
         CASE(DrawRect);
         CASE(DrawTextBlob);
index 023e2ad55a73d64aff7e9547f066c739105a350e..5b68fc22f843e4947462a2a7fba32e390f5b5c02 100644 (file)
@@ -20,8 +20,8 @@ public:
     ~SkMiniRecorder();
 
     // Try to record an op.  Returns false on failure.
-    bool drawBitmapRectToRect(const SkBitmap&, const SkRect* src, const SkRect& dst,
-                              const SkPaint*, SkCanvas::DrawBitmapRectFlags);
+    bool drawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst,
+                        const SkPaint*, SkCanvas::SrcRectConstraint);
     bool drawPath(const SkPath&, const SkPaint&);
     bool drawRect(const SkRect&, const SkPaint&);
     bool drawTextBlob(const SkTextBlob*, SkScalar x, SkScalar y, const SkPaint&);
@@ -38,7 +38,7 @@ public:
 private:
     enum class State {
         kEmpty,
-        kDrawBitmapRectToRectFixedSize,
+        kDrawBitmapRectFixedSize,
         kDrawPath,
         kDrawRect,
         kDrawTextBlob,
@@ -50,7 +50,7 @@ private:
     struct Max { static const size_t val = A > B ? A : B; };
 
     static const size_t kInlineStorage =
-        Max<sizeof(SkRecords::DrawBitmapRectToRectFixedSize),
+        Max<sizeof(SkRecords::DrawBitmapRectFixedSize),
         Max<sizeof(SkRecords::DrawPath),
         Max<sizeof(SkRecords::DrawRect),
             sizeof(SkRecords::DrawTextBlob)>::val>::val>::val;
index af6c1b4fcb52a61e2fc3ec9c6bd966a5c18644a6..64e51b740ed5b0987f7e3bb133a205d93b233be0 100644 (file)
@@ -29,7 +29,7 @@ enum DrawType {
     DRAW_BITMAP,
     DRAW_BITMAP_MATRIX, // deprecated, M41 was last Chromium version to write this to an .skp
     DRAW_BITMAP_NINE,
-    DRAW_BITMAP_RECT_TO_RECT,
+    DRAW_BITMAP_RECT,
     DRAW_CLEAR,
     DRAW_DATA,
     DRAW_OVAL,
@@ -70,11 +70,12 @@ enum DrawType {
     DRAW_PICTURE_MATRIX_PAINT,
     DRAW_TEXT_BLOB,
     DRAW_IMAGE,
-    DRAW_IMAGE_RECT,
+    DRAW_IMAGE_RECT_STRICT, // deprecated (M45)
     DRAW_ATLAS,
     DRAW_IMAGE_NINE,
+    DRAW_IMAGE_RECT,
 
-    LAST_DRAWTYPE_ENUM = DRAW_IMAGE_NINE
+    LAST_DRAWTYPE_ENUM = DRAW_IMAGE_RECT
 };
 
 // In the 'match' method, this constant will match any flavor of DRAW_BITMAP*
index 1cf1a1bfb4726c15fe35edec2aec903bc0a09d9d..23383740c75236d4eb27b4e4be62526e7c60bf9f 100644 (file)
@@ -182,14 +182,13 @@ void SkPicturePlayback::handleOp(SkReader32* reader,
             const SkPoint& loc = reader->skipT<SkPoint>();
             canvas->drawBitmap(bitmap, loc.fX, loc.fY, paint);
         } break;
-        case DRAW_BITMAP_RECT_TO_RECT: {
+        case DRAW_BITMAP_RECT: {
             const SkPaint* paint = fPictureData->getPaint(reader);
             const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader));
             const SkRect* src = get_rect_ptr(reader);   // may be null
             const SkRect& dst = reader->skipT<SkRect>();     // required
-            SkCanvas::DrawBitmapRectFlags flags;
-            flags = (SkCanvas::DrawBitmapRectFlags) reader->readInt();
-            canvas->drawBitmapRectToRect(bitmap, src, dst, paint, flags);
+            SkCanvas::SrcRectConstraint constraint = (SkCanvas::SrcRectConstraint)reader->readInt();
+            canvas->drawBitmapRect(bitmap, src, dst, paint, constraint);
         } break;
         case DRAW_BITMAP_MATRIX: {
             const SkPaint* paint = fPictureData->getPaint(reader);
@@ -249,12 +248,19 @@ void SkPicturePlayback::handleOp(SkReader32* reader,
             const SkRect& dst = reader->skipT<SkRect>();
             canvas->drawImageNine(image, center, dst, paint);
         } break;
+        case DRAW_IMAGE_RECT_STRICT:
         case DRAW_IMAGE_RECT: {
             const SkPaint* paint = fPictureData->getPaint(reader);
             const SkImage* image = fPictureData->getImage(reader);
             const SkRect* src = get_rect_ptr(reader);   // may be null
             const SkRect& dst = reader->skipT<SkRect>();     // required
-            canvas->drawImageRect(image, src, dst, paint);
+            // DRAW_IMAGE_RECT_STRICT assumes this constraint, and doesn't store it
+            SkCanvas::SrcRectConstraint constraint = SkCanvas::kStrict_SrcRectConstraint;
+            if (DRAW_IMAGE_RECT == op) {
+                // newer op-code stores the constraint explicitly
+                constraint = (SkCanvas::SrcRectConstraint)reader->readInt();
+            }
+            canvas->drawImageRect(image, src, dst, paint, constraint);
         } break;
         case DRAW_OVAL: {
             const SkPaint& paint = *fPictureData->getPaint(reader);
index 5f85b47aac27cb6558506c75e3893d8809f50cb0..60996dbba407843cd3438e3cab516bd816fa6c87 100644 (file)
@@ -61,7 +61,7 @@ static inline size_t get_paint_offset(DrawType op, size_t opSize) {
         1,  // DRAW_BITMAP - right after op code
         1,  // DRAW_BITMAP_MATRIX - right after op code, deprecated
         1,  // DRAW_BITMAP_NINE - right after op code
-        1,  // DRAW_BITMAP_RECT_TO_RECT - right after op code
+        1,  // DRAW_BITMAP_RECT - right after op code
         0,  // DRAW_CLEAR - no paint
         0,  // DRAW_DATA - no paint
         1,  // DRAW_OVAL - right after op code
@@ -99,9 +99,10 @@ static inline size_t get_paint_offset(DrawType op, size_t opSize) {
         1,  // DRAW_PICTURE_MATRIX_PAINT - right after op code
         1,  // DRAW_TEXT_BLOB- right after op code
         1,  // DRAW_IMAGE - right after op code
-        1,  // DRAW_IMAGE_RECT - right after op code
+        1,  // DRAW_IMAGE_RECT_STRICT - right after op code
         1,  // DRAW_ATLAS - right after op code
         1,  // DRAW_IMAGE_NINE - right after op code
+        1,  // DRAW_IMAGE_RECT - right after op code
     };
 
     SK_COMPILE_ASSERT(sizeof(gPaintOffsets) == LAST_DRAWTYPE_ENUM + 1,
@@ -551,7 +552,8 @@ void SkPictureRecord::onDrawBitmap(const SkBitmap& bitmap, SkScalar left, SkScal
 }
 
 void SkPictureRecord::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
-                                       const SkPaint* paint, DrawBitmapRectFlags flags) {
+                                       const SkPaint* paint,
+                                       SK_VIRTUAL_CONSTRAINT_TYPE constraint) {
     // id + paint index + bitmap index + bool for 'src' + flags
     size_t size = 5 * kUInt32Size;
     if (src) {
@@ -559,14 +561,13 @@ void SkPictureRecord::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src
     }
     size += sizeof(dst);        // + rect
 
-    size_t initialOffset = this->addDraw(DRAW_BITMAP_RECT_TO_RECT, &size);
-    SkASSERT(initialOffset+get_paint_offset(DRAW_BITMAP_RECT_TO_RECT, size)
-             == fWriter.bytesWritten());
+    size_t initialOffset = this->addDraw(DRAW_BITMAP_RECT, &size);
+    SkASSERT(initialOffset+get_paint_offset(DRAW_BITMAP_RECT, size) == fWriter.bytesWritten());
     this->addPaintPtr(paint);
     this->addBitmap(bitmap);
     this->addRectPtr(src);  // may be null
     this->addRect(dst);
-    this->addInt(flags);
+    this->addInt(constraint);
     this->validate(initialOffset, size);
 }
 
@@ -584,9 +585,10 @@ void SkPictureRecord::onDrawImage(const SkImage* image, SkScalar x, SkScalar y,
 }
 
 void SkPictureRecord::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
-                                      const SkPaint* paint) {
-    // id + paint_index + image_index + bool_for_src
-    size_t size = 4 * kUInt32Size;
+                                      const SkPaint* paint SRC_RECT_CONSTRAINT_PARAM(constraint)) {
+    SRC_RECT_CONSTRAINT_LOCAL_DEFAULT(constraint)
+    // id + paint_index + image_index + bool_for_src + constraint
+    size_t size = 5 * kUInt32Size;
     if (src) {
         size += sizeof(*src);   // + rect
     }
@@ -599,6 +601,7 @@ void SkPictureRecord::onDrawImageRect(const SkImage* image, const SkRect* src, c
     this->addImage(image);
     this->addRectPtr(src);  // may be null
     this->addRect(dst);
+    this->addInt(constraint);
     this->validate(initialOffset, size);
 }
 
index ed5d065b1724bdd1fc37cc0fcdcb82a4c54b1f70..cb6f32418cdfef79e3516d78b03dae444726e745 100644 (file)
@@ -182,10 +182,10 @@ protected:
     void onDrawPath(const SkPath&, const SkPaint&) override;
     void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
     void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
-                          DrawBitmapRectFlags flags) override;
+                          SK_VIRTUAL_CONSTRAINT_TYPE) override;
     void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
     void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
-                         const SkPaint*) override;
+                         const SkPaint* SRC_RECT_CONSTRAINT_PARAM(constraint)) override;
     void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst,
                          const SkPaint*) override;
     void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
index 7ef2eafda8c3c93c46cfe4016e679436e4d2f6c0..8ceb9c1337ed0c7b05e27c4ba45be307588f5d37 100644 (file)
@@ -88,14 +88,14 @@ DRAW(ClipRegion, clipRegion(r.region, r.op));
 
 DRAW(DrawBitmap, drawBitmap(r.bitmap.shallowCopy(), r.left, r.top, r.paint));
 DRAW(DrawBitmapNine, drawBitmapNine(r.bitmap.shallowCopy(), r.center, r.dst, r.paint));
-DRAW(DrawBitmapRectToRect,
-        drawBitmapRectToRect(r.bitmap.shallowCopy(), r.src, r.dst, r.paint,
-                             SkCanvas::kNone_DrawBitmapRectFlag));
-DRAW(DrawBitmapRectToRectBleed,
-        drawBitmapRectToRect(r.bitmap.shallowCopy(), r.src, r.dst, r.paint,
-                             SkCanvas::kBleed_DrawBitmapRectFlag));
-DRAW(DrawBitmapRectToRectFixedSize,
-        drawBitmapRectToRect(r.bitmap.shallowCopy(), &r.src, r.dst, &r.paint, r.flags));
+DRAW(DrawBitmapRect,
+        drawBitmapRect(r.bitmap.shallowCopy(), r.src, r.dst, r.paint,
+                             SkCanvas::kStrict_SrcRectConstraint));
+DRAW(DrawBitmapRectFast,
+        drawBitmapRect(r.bitmap.shallowCopy(), r.src, r.dst, r.paint,
+                       SkCanvas::kFast_SrcRectConstraint));
+DRAW(DrawBitmapRectFixedSize,
+        drawBitmapRect(r.bitmap.shallowCopy(), &r.src, r.dst, &r.paint, r.constraint));
 DRAW(DrawDRRect, drawDRRect(r.outer, r.inner, r.paint));
 DRAW(DrawImage, drawImage(r.image, r.left, r.top, r.paint));
 DRAW(DrawImageRect, drawImageRect(r.image, r.src, r.dst, r.paint));
@@ -419,13 +419,13 @@ private:
     Bounds bounds(const DrawImageNine& op) const {
         return this->adjustAndMap(op.dst, op.paint);
     }
-    Bounds bounds(const DrawBitmapRectToRect& op) const {
+    Bounds bounds(const DrawBitmapRect& op) const {
         return this->adjustAndMap(op.dst, op.paint);
     }
-    Bounds bounds(const DrawBitmapRectToRectBleed& op) const {
+    Bounds bounds(const DrawBitmapRectFast& op) const {
         return this->adjustAndMap(op.dst, op.paint);
     }
-    Bounds bounds(const DrawBitmapRectToRectFixedSize& op) const {
+    Bounds bounds(const DrawBitmapRectFixedSize& op) const {
         return this->adjustAndMap(op.dst, &op.paint);
     }
     Bounds bounds(const DrawBitmapNine& op) const {
index 0413860e9dc1ff26f9ca8b424bec1fb22625fa7b..41164bd8a26d30982e21f449efc6bbf7c492f883 100644 (file)
@@ -186,7 +186,9 @@ void SkRecorder::onDrawBitmapRect(const SkBitmap& bitmap,
                                   const SkRect* src,
                                   const SkRect& dst,
                                   const SkPaint* paint,
-                                  DrawBitmapRectFlags flags) {
+                                  SK_VIRTUAL_CONSTRAINT_TYPE legacyConstraint) {
+    SrcRectConstraint constraint = (SrcRectConstraint)legacyConstraint;
+
 #ifdef WRAP_BITMAP_AS_IMAGE
     // TODO: need a way to support the flags for images...
     SkAutoTUnref<SkImage> image(SkImage::NewFromBitmap(bitmap));
@@ -194,15 +196,13 @@ void SkRecorder::onDrawBitmapRect(const SkBitmap& bitmap,
         this->onDrawImageRect(image, src, dst, paint);
     }
 #else
-    TRY_MINIRECORDER(drawBitmapRectToRect, bitmap, src, dst, paint, flags);
-    if (kBleed_DrawBitmapRectFlag == flags) {
-        APPEND(DrawBitmapRectToRectBleed,
-               this->copy(paint), bitmap, this->copy(src), dst);
+    TRY_MINIRECORDER(drawBitmapRect, bitmap, src, dst, paint, constraint);
+    if (kFast_SrcRectConstraint == constraint) {
+        APPEND(DrawBitmapRectFast, this->copy(paint), bitmap, this->copy(src), dst);
         return;
     }
-    SkASSERT(kNone_DrawBitmapRectFlag == flags);
-    APPEND(DrawBitmapRectToRect,
-           this->copy(paint), bitmap, this->copy(src), dst);
+    SkASSERT(kStrict_SrcRectConstraint == constraint);
+    APPEND(DrawBitmapRect, this->copy(paint), bitmap, this->copy(src), dst);
 #endif
 }
 
@@ -227,8 +227,11 @@ void SkRecorder::onDrawImage(const SkImage* image, SkScalar left, SkScalar top,
 
 void SkRecorder::onDrawImageRect(const SkImage* image, const SkRect* src,
                                  const SkRect& dst,
-                                 const SkPaint* paint) {
-    APPEND(DrawImageRect, this->copy(paint), image, this->copy(src), dst);
+                                 const SkPaint* paint SRC_RECT_CONSTRAINT_PARAM(constraint)) {
+#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
+    SrcRectConstraint constraint = kStrict_SrcRectConstraint;
+#endif
+    APPEND(DrawImageRect, this->copy(paint), image, this->copy(src), dst, constraint);
 }
 
 void SkRecorder::onDrawImageNine(const SkImage* image, const SkIRect& center,
index b1515783975dfcea0895bcc122db0227ff4542ba..404d54c803eee35d7b13389f57ab6c85ec8c69a7 100644 (file)
@@ -98,10 +98,10 @@ public:
     void onDrawPath(const SkPath&, const SkPaint&) override;
     void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
     void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
-                          DrawBitmapRectFlags flags) override;
+                          SK_VIRTUAL_CONSTRAINT_TYPE) override;
     void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
     void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
-                         const SkPaint*) override;
+                         const SkPaint* SRC_RECT_CONSTRAINT_PARAM(constraint)) override;
     void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst,
                          const SkPaint*) override;
     void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
index 074a560c04f7f1ce6dbc8c2fe16b9cc5c8bbbb02..9ab04c91e488d337866978999ecf68496fc8f911 100644 (file)
@@ -40,9 +40,9 @@ namespace SkRecords {
     M(ClipRegion)                                                   \
     M(DrawBitmap)                                                   \
     M(DrawBitmapNine)                                               \
-    M(DrawBitmapRectToRect)                                         \
-    M(DrawBitmapRectToRectBleed)                                    \
-    M(DrawBitmapRectToRectFixedSize)                                \
+    M(DrawBitmapRect)                                               \
+    M(DrawBitmapRectFast)                                           \
+    M(DrawBitmapRectFixedSize)                                      \
     M(DrawDrawable)                                                 \
     M(DrawImage)                                                    \
     M(DrawImageRect)                                                \
@@ -276,29 +276,30 @@ RECORD4(DrawBitmapNine, Optional<SkPaint>, paint,
                         ImmutableBitmap, bitmap,
                         SkIRect, center,
                         SkRect, dst);
-RECORD4(DrawBitmapRectToRect, Optional<SkPaint>, paint,
-                              ImmutableBitmap, bitmap,
-                              Optional<SkRect>, src,
-                              SkRect, dst);
-RECORD4(DrawBitmapRectToRectBleed, Optional<SkPaint>, paint,
-                                   ImmutableBitmap, bitmap,
-                                   Optional<SkRect>, src,
-                                   SkRect, dst);
-RECORD5(DrawBitmapRectToRectFixedSize, SkPaint, paint,
-                                       ImmutableBitmap, bitmap,
-                                       SkRect, src,
-                                       SkRect, dst,
-                                       SkCanvas::DrawBitmapRectFlags, flags);
+RECORD4(DrawBitmapRect, Optional<SkPaint>, paint,
+                        ImmutableBitmap, bitmap,
+                        Optional<SkRect>, src,
+                        SkRect, dst);
+RECORD4(DrawBitmapRectFast, Optional<SkPaint>, paint,
+                            ImmutableBitmap, bitmap,
+                            Optional<SkRect>, src,
+                            SkRect, dst);
+RECORD5(DrawBitmapRectFixedSize, SkPaint, paint,
+                                 ImmutableBitmap, bitmap,
+                                 SkRect, src,
+                                 SkRect, dst,
+                                 SkCanvas::SrcRectConstraint, constraint);
 RECORD3(DrawDRRect, SkPaint, paint, SkRRect, outer, SkRRect, inner);
 RECORD3(DrawDrawable, Optional<SkMatrix>, matrix, SkRect, worstCaseBounds, int32_t, index);
 RECORD4(DrawImage, Optional<SkPaint>, paint,
                    RefBox<const SkImage>, image,
                    SkScalar, left,
                    SkScalar, top);
-RECORD4(DrawImageRect, Optional<SkPaint>, paint,
+RECORD5(DrawImageRect, Optional<SkPaint>, paint,
                        RefBox<const SkImage>, image,
                        Optional<SkRect>, src,
-                       SkRect, dst);
+                       SkRect, dst,
+                       SkCanvas::SrcRectConstraint, constraint);
 RECORD4(DrawImageNine, Optional<SkPaint>, paint,
                        RefBox<const SkImage>, image,
                        SkIRect, center,
index ed9521fd2c215bce1e3d80aa4c3f21b7f4b737b6..859e8aff62ac67ad4d1d3a78e817125aca4e50d0 100644 (file)
@@ -79,12 +79,12 @@ bool SkBitmapSource::onFilterImage(Proxy* proxy, const SkBitmap&, const Context&
     // Subtract off the integer component of the translation (will be applied in loc, below).
     dstRect.offset(-SkIntToScalar(dstIRect.fLeft), -SkIntToScalar(dstIRect.fTop));
     paint.setXfermodeMode(SkXfermode::kSrc_Mode);
-    // FIXME: this probably shouldn't be necessary, but drawBitmapRectToRect asserts
+    // FIXME: this probably shouldn't be necessary, but drawBitmapRect asserts
     // None filtering when it's translate-only
     paint.setFilterQuality(
         fSrcRect.width() == dstRect.width() && fSrcRect.height() == dstRect.height() ?
                kNone_SkFilterQuality : fFilterQuality);
-    canvas.drawBitmapRectToRect(fBitmap, &fSrcRect, dstRect, &paint);
+    canvas.drawBitmapRect(fBitmap, &fSrcRect, dstRect, &paint, SkCanvas::kStrict_SrcRectConstraint);
 
     *result = device.get()->accessBitmap(false);
     offset->fX = dstIRect.fLeft;
index 6f05206dcc69b7cea899bd4a066aa62d86393c67..e3936de48e6b452dab1de08eaa13877af30e3d82 100644 (file)
@@ -43,7 +43,7 @@ static inline void draw_replacement_bitmap(GrCachedLayer* layer, SkCanvas* canva
 
         canvas->save();
         canvas->setMatrix(SkMatrix::I());
-        canvas->drawBitmapRectToRect(bm, &src, dst, layer->paint());
+        canvas->drawBitmapRect(bm, &src, dst, layer->paint(), SkCanvas::kStrict_SrcRectConstraint);
         canvas->restore();
     } else {
         canvas->drawSprite(bm,
index e0658b30f6ed6ae2003e4d66db01daf7f8ef2dad..9cf5b25d7814a2063f378e4ac47603e73c06abe1 100644 (file)
@@ -791,7 +791,7 @@ void SkGpuDevice::drawBitmap(const SkDraw& origDraw,
         concat.setConcat(*draw->fMatrix, m);
         draw.writable()->fMatrix = &concat;
     }
-    this->drawBitmapCommon(*draw, bitmap, NULL, NULL, paint, SkCanvas::kNone_DrawBitmapRectFlag);
+    this->drawBitmapCommon(*draw, bitmap, NULL, NULL, paint, SkCanvas::kStrict_SrcRectConstraint);
 }
 
 // This method outsets 'iRect' by 'outset' all around and then clamps its extents to
@@ -903,7 +903,7 @@ void SkGpuDevice::drawBitmapCommon(const SkDraw& draw,
                                    const SkRect* srcRectPtr,
                                    const SkSize* dstSizePtr,
                                    const SkPaint& paint,
-                                   SkCanvas::DrawBitmapRectFlags flags) {
+                                   SkCanvas::SrcRectConstraint constraint) {
     CHECK_SHOULD_DRAW(draw);
 
     SkRect srcRect;
@@ -926,7 +926,7 @@ void SkGpuDevice::drawBitmapCommon(const SkDraw& draw,
     int height = tex ? tex->height() : bitmap.height();
     if (srcRect.fLeft <= 0 && srcRect.fTop <= 0 &&
         srcRect.fRight >= width && srcRect.fBottom >= height) {
-        flags = (SkCanvas::DrawBitmapRectFlags) (flags | SkCanvas::kBleed_DrawBitmapRectFlag);
+        constraint = SkCanvas::kFast_SrcRectConstraint;
     }
 
     // If the render target is not msaa and draw is antialiased, we call
@@ -976,7 +976,7 @@ void SkGpuDevice::drawBitmapCommon(const SkDraw& draw,
             // already accounted for in 'm' and 'srcRect'. In clamp mode we need to chop out
             // the desired portion of the bitmap and then update 'm' and 'srcRect' to
             // compensate.
-            if (!(SkCanvas::kBleed_DrawBitmapRectFlag & flags)) {
+            if (SkCanvas::kStrict_SrcRectConstraint == constraint) {
                 SkIRect iSrc;
                 srcRect.roundOut(&iSrc);
 
@@ -1064,7 +1064,7 @@ void SkGpuDevice::drawBitmapCommon(const SkDraw& draw,
     SkIRect clippedSrcRect;
     if (this->shouldTileBitmap(bitmap, viewM, params, srcRectPtr, maxTileSize, &tileSize,
                                &clippedSrcRect)) {
-        this->drawTiledBitmap(bitmap, viewM, srcRect, clippedSrcRect, params, paint, flags,
+        this->drawTiledBitmap(bitmap, viewM, srcRect, clippedSrcRect, params, paint, constraint,
                               tileSize, doBicubic);
     } else {
         // take the simple case
@@ -1078,7 +1078,7 @@ void SkGpuDevice::drawBitmapCommon(const SkDraw& draw,
                                  srcRect,
                                  params,
                                  paint,
-                                 flags,
+                                 constraint,
                                  doBicubic,
                                  needsTextureDomain);
     }
@@ -1092,7 +1092,7 @@ void SkGpuDevice::drawTiledBitmap(const SkBitmap& bitmap,
                                   const SkIRect& clippedSrcIRect,
                                   const GrTextureParams& params,
                                   const SkPaint& paint,
-                                  SkCanvas::DrawBitmapRectFlags flags,
+                                  SkCanvas::SrcRectConstraint constraint,
                                   int tileSize,
                                   bool bicubic) {
     // The following pixel lock is technically redundant, but it is desirable
@@ -1135,7 +1135,7 @@ void SkGpuDevice::drawTiledBitmap(const SkBitmap& bitmap,
             if (GrTextureParams::kNone_FilterMode != params.filterMode() || bicubic) {
                 SkIRect iClampRect;
 
-                if (SkCanvas::kBleed_DrawBitmapRectFlag & flags) {
+                if (SkCanvas::kFast_SrcRectConstraint == constraint) {
                     // In bleed mode we want to always expand the tile on all edges
                     // but stay within the bitmap bounds
                     iClampRect = SkIRect::MakeWH(bitmap.width(), bitmap.height());
@@ -1163,7 +1163,7 @@ void SkGpuDevice::drawTiledBitmap(const SkBitmap& bitmap,
                                          tileR,
                                          paramsTemp,
                                          paint,
-                                         flags,
+                                         constraint,
                                          bicubic,
                                          needsTextureDomain);
             }
@@ -1184,7 +1184,7 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
                                      const SkRect& srcRect,
                                      const GrTextureParams& params,
                                      const SkPaint& paint,
-                                     SkCanvas::DrawBitmapRectFlags flags,
+                                     SkCanvas::SrcRectConstraint constraint,
                                      bool bicubic,
                                      bool needsTextureDomain) {
     SkASSERT(bitmap.width() <= fContext->caps()->maxTextureSize() &&
@@ -1212,7 +1212,7 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
     GrPaint grPaint;
     SkAutoTUnref<GrFragmentProcessor> fp;
 
-    if (needsTextureDomain && !(flags & SkCanvas::kBleed_DrawBitmapRectFlag)) {
+    if (needsTextureDomain && (SkCanvas::kStrict_SrcRectConstraint == constraint)) {
         // Use a constrained texture domain to avoid color bleeding
         SkScalar left, top, right, bottom;
         if (srcRect.width() > SK_Scalar1) {
@@ -1351,7 +1351,9 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
 void SkGpuDevice::drawBitmapRect(const SkDraw& origDraw, const SkBitmap& bitmap,
                                  const SkRect* src, const SkRect& dst,
                                  const SkPaint& paint,
-                                 SkCanvas::DrawBitmapRectFlags flags) {
+                                 SK_VIRTUAL_CONSTRAINT_TYPE legacyConstraint) {
+    SkCanvas::SrcRectConstraint constraint = (SkCanvas::SrcRectConstraint)legacyConstraint;
+
     SkMatrix    matrix;
     SkRect      bitmapBounds, tmpSrc;
 
@@ -1391,7 +1393,7 @@ void SkGpuDevice::drawBitmapRect(const SkDraw& origDraw, const SkBitmap& bitmap,
     dstSize.fWidth = tmpDst.width();
     dstSize.fHeight = tmpDst.height();
 
-    this->drawBitmapCommon(*draw, bitmap, &tmpSrc, &dstSize, paint, flags);
+    this->drawBitmapCommon(*draw, bitmap, &tmpSrc, &dstSize, paint, constraint);
 }
 
 void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
@@ -1512,10 +1514,11 @@ void SkGpuDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar x
 }
 
 void SkGpuDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const SkRect* src,
-                                const SkRect& dst, const SkPaint& paint) {
+                                const SkRect& dst, const SkPaint& paint,
+                                SkCanvas::SrcRectConstraint constraint) {
     SkBitmap bm;
     if (wrap_as_bm(image, &bm)) {
-        this->drawBitmapRect(draw, bm, src, dst, paint, SkCanvas::kNone_DrawBitmapRectFlag);
+        this->drawBitmapRect(draw, bm, src, dst, paint, (SK_VIRTUAL_CONSTRAINT_TYPE)constraint);
     }
 }
 
index 86507657cd32b9182945d036eac191e6b106b0a0..ec3bfbdaab591229235add1466f135e9dd46a9a6 100644 (file)
@@ -96,7 +96,7 @@ public:
     virtual void drawBitmapRect(const SkDraw&, const SkBitmap&,
                                 const SkRect* srcOrNull, const SkRect& dst,
                                 const SkPaint& paint,
-                                SkCanvas::DrawBitmapRectFlags flags) override;
+                                SK_VIRTUAL_CONSTRAINT_TYPE) override;
     virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap,
                             int x, int y, const SkPaint& paint) override;
     virtual void drawText(const SkDraw&, const void* text, size_t len,
@@ -117,7 +117,7 @@ public:
                             const SkPaint&) override;
     void drawImage(const SkDraw&, const SkImage*, SkScalar x, SkScalar y, const SkPaint&) override;
     void drawImageRect(const SkDraw&, const SkImage*, const SkRect* src, const SkRect& dst,
-                       const SkPaint&) override;
+                       const SkPaint&, SkCanvas::SrcRectConstraint) override;
 
     void flush() override;
 
@@ -187,7 +187,7 @@ private:
                           const SkRect* srcRectPtr,
                           const SkSize* dstSizePtr,      // ignored iff srcRectPtr == NULL
                           const SkPaint&,
-                          SkCanvas::DrawBitmapRectFlags flags);
+                          SkCanvas::SrcRectConstraint);
 
     /**
      * Helper functions called by drawBitmapCommon. By the time these are called the SkDraw's
@@ -207,7 +207,7 @@ private:
                             const SkRect&,
                             const GrTextureParams& params,
                             const SkPaint& paint,
-                            SkCanvas::DrawBitmapRectFlags flags,
+                            SkCanvas::SrcRectConstraint,
                             bool bicubic,
                             bool needsTextureDomain);
     void drawTiledBitmap(const SkBitmap& bitmap,
@@ -216,7 +216,7 @@ private:
                          const SkIRect& clippedSrcRect,
                          const GrTextureParams& params,
                          const SkPaint& paint,
-                         SkCanvas::DrawBitmapRectFlags flags,
+                         SkCanvas::SrcRectConstraint,
                          int tileSize,
                          bool bicubic);
 
index 422a895419b0e2ef0b23e5d5573f8d7ac50c2c96..7ca6c2200e9a021ff1c2881e080bd82b141b65d9 100644 (file)
@@ -1001,7 +1001,7 @@ void SkPDFDevice::drawPath(const SkDraw& d,
 void SkPDFDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap,
                                  const SkRect* src, const SkRect& dst,
                                  const SkPaint& srcPaint,
-                                 SkCanvas::DrawBitmapRectFlags flags) {
+                                 SK_VIRTUAL_CONSTRAINT_TYPE) {
     SkPaint paint = srcPaint;
     if (bitmap.isOpaque()) {
         replace_srcmode_on_opaque_paint(&paint);
index f58e74cc88a37d4c73a615472725bcc341275ba7..bb12a3f6dc473fd868d8ef917a399dbf47388299 100644 (file)
@@ -96,7 +96,7 @@ public:
     void drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap,
                         const SkRect* src, const SkRect& dst,
                         const SkPaint& paint,
-                        SkCanvas::DrawBitmapRectFlags flags) override;
+                        SK_VIRTUAL_CONSTRAINT_TYPE) override;
     void drawBitmap(const SkDraw&, const SkBitmap& bitmap,
                     const SkMatrix& matrix, const SkPaint&) override;
     void drawSprite(const SkDraw&, const SkBitmap& bitmap, int x, int y,
index 614853dd92b74819796a4bc95ed9b745ae6b67fe..c86e6fb3046e9e8b93396ae6e4108bbe5f444fd9 100644 (file)
@@ -42,7 +42,7 @@ enum DrawOps {
     kDrawAtlas_DrawOp,
     kDrawBitmap_DrawOp,
     kDrawBitmapNine_DrawOp,
-    kDrawBitmapRectToRect_DrawOp,
+    kDrawBitmapRect_DrawOp,
     kDrawDRRect_DrawOp,
     kDrawImage_DrawOp,
     kDrawImageRect_DrawOp,
index 48e0c0641baa2370bd0996c5c521b6d1a41863ae..ef1eeb303b4b4f86bf0266e78254a18ebefaf7a3 100644 (file)
@@ -643,15 +643,14 @@ static void drawBitmapRect_rp(SkCanvas* canvas, SkReader32* reader,
     } else {
         src = NULL;
     }
-    SkCanvas::DrawBitmapRectFlags dbmrFlags = SkCanvas::kNone_DrawBitmapRectFlag;
+    SkCanvas::SrcRectConstraint constraint = SkCanvas::kStrict_SrcRectConstraint;
     if (flags & kDrawBitmap_Bleed_DrawOpFlag) {
-        dbmrFlags = (SkCanvas::DrawBitmapRectFlags)(dbmrFlags|SkCanvas::kBleed_DrawBitmapRectFlag);
+        constraint = SkCanvas::kFast_SrcRectConstraint;
     }
     const SkRect* dst = skip<SkRect>(reader);
     const SkBitmap* bitmap = holder.getBitmap();
     if (state->shouldDraw()) {
-        canvas->drawBitmapRectToRect(*bitmap, src, *dst,
-                                     hasPaint ? &state->paint() : NULL, dbmrFlags);
+        canvas->drawBitmapRect(*bitmap, src, *dst, hasPaint ? &state->paint() : NULL, constraint);
     }
 }
 
@@ -689,9 +688,11 @@ static void drawImageRect_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32
         src = skip<SkRect>(reader);
     }
     const SkRect* dst = skip<SkRect>(reader);
+    SkCanvas::SrcRectConstraint constraint = (SkCanvas::SrcRectConstraint)reader->readInt();
+
     const SkImage* image = state->getImage(slot);
     if (state->shouldDraw()) {
-        canvas->drawImageRect(image, src, *dst, hasPaint ? &state->paint() : NULL);
+        canvas->drawImageRect(image, src, *dst, hasPaint ? &state->paint() : NULL, constraint);
     }
 }
 
index 4dbb5b536c8f852a7116a5604ba40c1876b2579f..60a63b090a6f50b31f600a08a95e83f4570a6a2b 100644 (file)
@@ -276,10 +276,10 @@ protected:
     void onDrawPath(const SkPath&, const SkPaint&) override;
     void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
     void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
-                          DrawBitmapRectFlags flags) override;
+                          SK_VIRTUAL_CONSTRAINT_TYPE) override;
     void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
     void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
-                         const SkPaint*) override;
+                         const SkPaint* SRC_RECT_CONSTRAINT_PARAM(constraint)) override;
     void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst,
                          const SkPaint*) override;
     void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
@@ -791,7 +791,10 @@ void SkGPipeCanvas::onDrawBitmap(const SkBitmap& bm, SkScalar left, SkScalar top
 }
 
 void SkGPipeCanvas::onDrawBitmapRect(const SkBitmap& bm, const SkRect* src, const SkRect& dst,
-                                     const SkPaint* paint, DrawBitmapRectFlags dbmrFlags) {
+                                     const SkPaint* paint,
+                                     SK_VIRTUAL_CONSTRAINT_TYPE legacyConstraint) {
+    SrcRectConstraint constraint = (SrcRectConstraint)legacyConstraint;
+
     NOTIFY_SETUP(this);
     size_t opBytesNeeded = sizeof(SkRect);
     bool hasSrc = src != NULL;
@@ -802,11 +805,11 @@ void SkGPipeCanvas::onDrawBitmapRect(const SkBitmap& bm, const SkRect* src, cons
     } else {
         flags = 0;
     }
-    if (dbmrFlags & kBleed_DrawBitmapRectFlag) {
+    if (kFast_SrcRectConstraint == constraint) {
         flags |= kDrawBitmap_Bleed_DrawOpFlag;
     }
 
-    if (this->commonDrawBitmap(bm, kDrawBitmapRectToRect_DrawOp, flags, opBytesNeeded, paint)) {
+    if (this->commonDrawBitmap(bm, kDrawBitmapRect_DrawOp, flags, opBytesNeeded, paint)) {
         if (hasSrc) {
             fWriter.writeRect(*src);
         }
@@ -869,8 +872,10 @@ void SkGPipeCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y,
 }
 
 void SkGPipeCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
-                                    const SkPaint* paint) {
+                                    const SkPaint* paint SRC_RECT_CONSTRAINT_PARAM(constraint)) {
     NOTIFY_SETUP(this);
+
+    SRC_RECT_CONSTRAINT_LOCAL_DEFAULT(constraint)
     unsigned flags = 0;
     size_t opBytesNeeded = sizeof(SkRect);  // dst
     if (src) {
@@ -882,6 +887,7 @@ void SkGPipeCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, con
             fWriter.writeRect(*src);
         }
         fWriter.writeRect(dst);
+        fWriter.writeInt(constraint);
     }
 }
 
index 6038353c9cf53b3579b200fa5e9546c4414a4321..af565a04bd7fd901f396ebda6d0c4c2c60ef52eb 100644 (file)
@@ -716,7 +716,7 @@ void SkSVGDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
 
 void SkSVGDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bm, const SkRect* srcOrNull,
                                  const SkRect& dst, const SkPaint& paint,
-                                 SkCanvas::DrawBitmapRectFlags) {
+                                 SK_VIRTUAL_CONSTRAINT_TYPE) {
     SkMatrix adjustedMatrix;
     adjustedMatrix.setRectToRect(srcOrNull ? *srcOrNull : SkRect::Make(bm.bounds()),
                                  dst,
index e3691a957fc11a21413b608284032f29b6e83c9f..58fb5d4e93f8593ef2c7d967dc5906112b4f035a 100644 (file)
@@ -37,7 +37,7 @@ protected:
     void drawBitmapRect(const SkDraw&, const SkBitmap&,
                         const SkRect* srcOrNull, const SkRect& dst,
                         const SkPaint& paint,
-                        SkCanvas::DrawBitmapRectFlags flags) override;
+                        SK_VIRTUAL_CONSTRAINT_TYPE) override;
 
     void drawText(const SkDraw&, const void* text, size_t len,
                   SkScalar x, SkScalar y, const SkPaint& paint) override;
index 8e3423584857b0217f8da6759bec4435af4949d3..343d0c45d7c6fcf102396983c512580ecb5e77f3 100644 (file)
@@ -219,7 +219,7 @@ protected:
         {SkASSERT(0);}
     void drawBitmapRect(const SkDraw&, const SkBitmap&, const SkRect*,
                         const SkRect&, const SkPaint&,
-                        SkCanvas::DrawBitmapRectFlags) override
+                        SK_VIRTUAL_CONSTRAINT_TYPE) override
         {SkASSERT(0);}
     void drawSprite(const SkDraw&, const SkBitmap& bitmap,
                     int x, int y, const SkPaint& paint) override
@@ -227,7 +227,7 @@ protected:
     void drawImage(const SkDraw&, const SkImage*, SkScalar, SkScalar, const SkPaint&) override
         {SkASSERT(0);}
     void drawImageRect(const SkDraw&, const SkImage*, const SkRect*, const SkRect&,
-                       const SkPaint&) override
+                       const SkPaint&, SkCanvas::SrcRectConstraint) override
         {SkASSERT(0);}
     void drawImageNine(const SkDraw&, const SkImage*, const SkIRect&, const SkRect&,
                        const SkPaint&) override
@@ -865,8 +865,8 @@ void SkDeferredCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar left,
 }
 
 void SkDeferredCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
-                                        const SkRect& dst,
-                                        const SkPaint* paint, DrawBitmapRectFlags flags) {
+                                        const SkRect& dst, const SkPaint* paint,
+                                        SK_VIRTUAL_CONSTRAINT_TYPE constraint) {
     if (fDeferredDrawing &&
         this->isFullFrame(&dst, paint) &&
         isPaintOpaque(paint, &bitmap)) {
@@ -874,7 +874,7 @@ void SkDeferredCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* sr
     }
 
     AutoImmediateDrawIfNeeded autoDraw(*this, &bitmap, paint);
-    this->drawingCanvas()->drawBitmapRectToRect(bitmap, src, dst, paint, flags);
+    this->drawingCanvas()->drawBitmapRect(bitmap, src, dst, paint, (SrcRectConstraint)constraint);
     this->recordedDrawCommand();
 }
 
@@ -894,7 +894,7 @@ void SkDeferredCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y,
     this->recordedDrawCommand();
 }
 void SkDeferredCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
-                                       const SkPaint* paint) {
+                                       const SkPaint* paint SRC_RECT_CONSTRAINT_PARAM(constraint)) {
     if (fDeferredDrawing &&
         this->isFullFrame(&dst, paint) &&
         isPaintOpaque(paint, image)) {
@@ -902,7 +902,8 @@ void SkDeferredCanvas::onDrawImageRect(const SkImage* image, const SkRect* src,
     }
     
     AutoImmediateDrawIfNeeded autoDraw(*this, image, paint);
-    this->drawingCanvas()->drawImageRect(image, src, dst, paint);
+    this->drawingCanvas()->drawImageRect(image, src, dst, paint
+                                         SRC_RECT_CONSTRAINT_ARG(constraint));
     this->recordedDrawCommand();
 }
 
index 5cbf2f4bcc6282d9345e4dec39c6aa6dce5b9135..e20aea4e02372fccbe1b81b9ba33003174936228 100644 (file)
@@ -346,7 +346,7 @@ void SkDumpCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
 }
 
 void SkDumpCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
-                                    const SkPaint* paint, DrawBitmapRectFlags flags) {
+                                    const SkPaint* paint, SK_VIRTUAL_CONSTRAINT_TYPE) {
     SkString bs, rs;
     bitmap.toString(&bs);
     toString(dst, &rs);
@@ -359,8 +359,7 @@ void SkDumpCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, c
         rs.prependf("%s ", ss.c_str());
     }
 
-    this->dump(kDrawBitmap_Verb, paint, "drawBitmapRectToRect(%s %s)",
-               bs.c_str(), rs.c_str());
+    this->dump(kDrawBitmap_Verb, paint, "drawBitmapRect(%s %s)", bs.c_str(), rs.c_str());
 }
 
 void SkDumpCanvas::onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
@@ -381,7 +380,7 @@ void SkDumpCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, con
 }
 
 void SkDumpCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
-                                   const SkPaint* paint) {
+                                   const SkPaint* paint SRC_RECT_CONSTRAINT_PARAM(constraint)) {
     SkString bs, rs;
     image->toString(&bs);
     toString(dst, &rs);
index 68094f2ca0e2344f49e43f4c66204b33436bbe29..b8921310a6eb7122dfe0e4d48f0e04f68f189ee7 100644 (file)
@@ -215,7 +215,7 @@ void SkLuaCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
 }
 
 void SkLuaCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
-                                   const SkPaint* paint, DrawBitmapRectFlags flags) {
+                                   const SkPaint* paint, SK_VIRTUAL_CONSTRAINT_TYPE) {
     AUTO_LUA("drawBitmapRect");
     if (paint) {
         lua.pushPaint(*paint, "paint");
@@ -238,7 +238,7 @@ void SkLuaCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, cons
 }
 
 void SkLuaCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
-                                  const SkPaint* paint) {
+                                  const SkPaint* paint SRC_RECT_CONSTRAINT_PARAM(constraint)) {
     AUTO_LUA("drawImageRect");
     if (paint) {
         lua.pushPaint(*paint, "paint");
index 8ae842237ffa34830ada900505e727edd5bd581c..706c769d7b423a668efda5c77d99a76acbc018eb 100644 (file)
@@ -170,8 +170,7 @@ void SkNWayCanvas::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) {
     }
 }
 
-void SkNWayCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner,
-                                const SkPaint& paint) {
+void SkNWayCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint& paint) {
     Iter iter(fList);
     while (iter.next()) {
         iter->drawDRRect(outer, inner, paint);
@@ -194,10 +193,10 @@ void SkNWayCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
 }
 
 void SkNWayCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
-                                    const SkPaint* paint, DrawBitmapRectFlags flags) {
+                                    const SkPaint* paint, SK_VIRTUAL_CONSTRAINT_TYPE constraint) {
     Iter iter(fList);
     while (iter.next()) {
-        iter->drawBitmapRectToRect(bitmap, src, dst, paint, flags);
+        iter->drawBitmapRect(bitmap, src, dst, paint, (SrcRectConstraint)constraint);
     }
 }
 
@@ -218,10 +217,10 @@ void SkNWayCanvas::onDrawImage(const SkImage* image, SkScalar left, SkScalar top
 }
 
 void SkNWayCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
-                                   const SkPaint* paint) {
+                                   const SkPaint* paint SRC_RECT_CONSTRAINT_PARAM(constraint)) {
     Iter iter(fList);
     while (iter.next()) {
-        iter->drawImageRect(image, src, dst, paint);
+        iter->drawImageRect(image, src, dst, paint SRC_RECT_CONSTRAINT_ARG(constraint));
     }
 }
 
index 1abebef8cad5e517da186c9dc945d7ed22a15a3f..3e589e6146151e925c43c0967e955fe82787e9c6 100644 (file)
@@ -74,9 +74,10 @@ void SkPaintFilterCanvas::onDrawBitmap(const SkBitmap& bm, SkScalar left, SkScal
 }
 
 void SkPaintFilterCanvas::onDrawBitmapRect(const SkBitmap& bm, const SkRect* src, const SkRect& dst,
-                                           const SkPaint* paint, DrawBitmapRectFlags flags) {
+                                           const SkPaint* paint,
+                                           SK_VIRTUAL_CONSTRAINT_TYPE constraint) {
     AutoPaintFilter apf(this, kBitmap_Type, paint);
-    this->INHERITED::onDrawBitmapRect(bm, src, dst, apf.paint(), flags);
+    this->INHERITED::onDrawBitmapRect(bm, src, dst, apf.paint(), constraint);
 }
 
 void SkPaintFilterCanvas::onDrawImage(const SkImage* image, SkScalar left, SkScalar top,
@@ -86,9 +87,11 @@ void SkPaintFilterCanvas::onDrawImage(const SkImage* image, SkScalar left, SkSca
 }
 
 void SkPaintFilterCanvas::onDrawImageRect(const SkImage* image, const SkRect* src,
-                                          const SkRect& dst, const SkPaint* paint) {
+                                          const SkRect& dst, const SkPaint* paint
+                                          SRC_RECT_CONSTRAINT_PARAM(constraint)) {
     AutoPaintFilter apf(this, kBitmap_Type, paint);
-    this->INHERITED::onDrawImageRect(image, src, dst, apf.paint());
+    this->INHERITED::onDrawImageRect(image, src, dst, apf.paint()
+                                     SRC_RECT_CONSTRAINT_ARG(constraint));
 }
 
 void SkPaintFilterCanvas::onDrawBitmapNine(const SkBitmap& bm, const SkIRect& center,
index 26baaf2954d16eed0f02d5a40fcc3187315b1241..2f988919d83df431ae638e9bf05b66541ace0002 100644 (file)
@@ -143,9 +143,10 @@ void SkAndroidSDKCanvas::onDrawBitmapRect(const SkBitmap& bitmap,
                                                    const SkRect* src,
                                                    const SkRect& dst,
                                                    const SkPaint* paint,
-                                                   DrawBitmapRectFlags flags) {
+                                                   SK_VIRTUAL_CONSTRAINT_TYPE constraint) {
     FILTER_PTR(paint);
-    fProxyTarget->drawBitmapRectToRect(bitmap, src, dst, filteredPaint, flags);
+    fProxyTarget->drawBitmapRect(bitmap, src, dst, filteredPaint,
+                                 (SrcRectConstraint)constraint);
 }
 void SkAndroidSDKCanvas::onDrawBitmapNine(const SkBitmap& bitmap,
                                                    const SkIRect& center,
index a54315d4786a7028db0ede22d2a7c69ed3083bf3..d22931d4c97cb8929364c05be7e4609d886b0bb0 100644 (file)
@@ -43,7 +43,7 @@ protected:
     void onDrawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
                       const SkPaint* paint) override;
     void onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
-                          const SkPaint* paint, DrawBitmapRectFlags flags) override;
+                          const SkPaint* paint, SK_VIRTUAL_CONSTRAINT_TYPE) override;
     void onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
                           const SkRect& dst, const SkPaint* paint) override;
     void onDrawSprite(const SkBitmap& bitmap, int left, int top,
index 3c166b73daf93d7d4511da87edb07d220072e99d..00923db40588590df3b00d049ebc5d27b223b507 100644 (file)
@@ -415,8 +415,9 @@ void SkDebugCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar left,
 }
 
 void SkDebugCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
-                                     const SkPaint* paint, DrawBitmapRectFlags flags) {
-    this->addDrawCommand(new SkDrawBitmapRectCommand(bitmap, src, dst, paint, flags));
+                                     const SkPaint* paint, SK_VIRTUAL_CONSTRAINT_TYPE constraint) {
+    this->addDrawCommand(new SkDrawBitmapRectCommand(bitmap, src, dst, paint,
+                                                     (SrcRectConstraint)constraint));
 }
 
 void SkDebugCanvas::onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
@@ -430,7 +431,7 @@ void SkDebugCanvas::onDrawImage(const SkImage* image, SkScalar left, SkScalar to
 }
 
 void SkDebugCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
-                                    const SkPaint* paint) {
+                                    const SkPaint* paint SRC_RECT_CONSTRAINT_PARAM(constraint)) {
     SkDebugf("SkDebugCanvas::onDrawImageRect unimplemented\n");
 }
 
index ceaaa784138967ab438cb8fd2b330194e16d6bd8..4f5f226e82ef1e7953df05cc3d1c15e1ad16c903 100644 (file)
@@ -198,10 +198,10 @@ protected:
     void onDrawPath(const SkPath&, const SkPaint&) override;
     void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
     void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
-                          DrawBitmapRectFlags flags) override;
+                          SK_VIRTUAL_CONSTRAINT_TYPE) override;
     void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
     void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
-                         const SkPaint*) override;
+                         const SkPaint* SRC_RECT_CONSTRAINT_PARAM(constraint)) override;
     void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
                           const SkPaint*) override;
     void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*) override;
index 7e2af084f2036c26b599a67d2bc3071a826a2411..5f0f74ffc0051ac30062d9460dc73bb40bdeca49 100644 (file)
@@ -320,7 +320,7 @@ bool SkDrawBitmapNineCommand::render(SkCanvas* canvas) const {
 
 SkDrawBitmapRectCommand::SkDrawBitmapRectCommand(const SkBitmap& bitmap, const SkRect* src,
                                                  const SkRect& dst, const SkPaint* paint,
-                                                 SkCanvas::DrawBitmapRectFlags flags)
+                                                 SkCanvas::SrcRectConstraint constraint)
     : INHERITED(kDrawBitmapRect_OpType) {
     fBitmap = bitmap;
     if (src) {
@@ -336,7 +336,7 @@ SkDrawBitmapRectCommand::SkDrawBitmapRectCommand(const SkBitmap& bitmap, const S
     } else {
         fPaintPtr = NULL;
     }
-    fFlags = flags;
+    fConstraint = constraint;
 
     fInfo.push(SkObjectParser::BitmapToString(bitmap));
     if (src) {
@@ -346,11 +346,11 @@ SkDrawBitmapRectCommand::SkDrawBitmapRectCommand(const SkBitmap& bitmap, const S
     if (paint) {
         fInfo.push(SkObjectParser::PaintToString(*paint));
     }
-    fInfo.push(SkObjectParser::IntToString(fFlags, "Flags: "));
+    fInfo.push(SkObjectParser::IntToString(fConstraint, "Constraint: "));
 }
 
 void SkDrawBitmapRectCommand::execute(SkCanvas* canvas) const {
-    canvas->drawBitmapRectToRect(fBitmap, this->srcRect(), fDst, fPaintPtr, fFlags);
+    canvas->drawBitmapRect(fBitmap, this->srcRect(), fDst, fPaintPtr, fConstraint);
 }
 
 bool SkDrawBitmapRectCommand::render(SkCanvas* canvas) const {
index 307599fdb725a8e2efc0bed5e2f237f9bfb9bf6f..99e3eea457530f93112aa615b9a66ba1472a8741 100644 (file)
@@ -229,7 +229,7 @@ class SkDrawBitmapRectCommand : public SkDrawCommand {
 public:
     SkDrawBitmapRectCommand(const SkBitmap& bitmap, const SkRect* src,
                             const SkRect& dst, const SkPaint* paint,
-                            SkCanvas::DrawBitmapRectFlags flags);
+                            SkCanvas::SrcRectConstraint);
     void execute(SkCanvas* canvas) const override;
     bool render(SkCanvas* canvas) const override;
 
@@ -250,8 +250,8 @@ public:
     const SkRect& dstRect() const { return fDst; }
     void setDstRect(const SkRect& dst) { fDst = dst; }
 
-    SkCanvas::DrawBitmapRectFlags flags() const { return fFlags; }
-    void setFlags(SkCanvas::DrawBitmapRectFlags flags) { fFlags = flags; }
+    SkCanvas::SrcRectConstraint constraint() const { return fConstraint; }
+    void setConstraint(SkCanvas::SrcRectConstraint constraint) { fConstraint = constraint; }
 
 private:
     SkBitmap                      fBitmap;
@@ -259,7 +259,7 @@ private:
     SkRect                        fDst;
     SkPaint                       fPaint;
     SkPaint*                      fPaintPtr;
-    SkCanvas::DrawBitmapRectFlags fFlags;
+    SkCanvas::SrcRectConstraint   fConstraint;
 
     typedef SkDrawCommand INHERITED;
 };
index 1e365bce30390e40e7c971ca5bdd463bb4e6949c..8d6007c6eed4ba23169fa22025e85f5bd26589ea 100644 (file)
@@ -295,7 +295,7 @@ DEF_TEST(RecordDraw_drawImage, r){
         }
 
         void onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
-                             const SkPaint* paint) override {
+                             const SkPaint* paint SRC_RECT_CONSTRAINT_PARAM(constraint)) override {
             fDrawImageRectCalled = true;
         }