guard to remove DrawBitmapRectFlags

BUG=skia:

Review URL: https://codereview.chromium.org/1235393003
diff --git a/bench/BitmapRectBench.cpp b/bench/BitmapRectBench.cpp
index d3a7574..596c18f 100644
--- a/bench/BitmapRectBench.cpp
+++ b/bench/BitmapRectBench.cpp
@@ -96,7 +96,7 @@
         paint.setAlpha(fAlpha);
 
         for (int i = 0; i < loops; i++) {
-            canvas->drawBitmapRectToRect(fBitmap, &fSrcR, fDstR, &paint);
+            canvas->drawBitmapRect(fBitmap, &fSrcR, fDstR, &paint);
         }
     }
 
diff --git a/bench/GameBench.cpp b/bench/GameBench.cpp
index d9a397e..3d9885f 100644
--- a/bench/GameBench.cpp
+++ b/bench/GameBench.cpp
@@ -204,11 +204,11 @@
                                          4, verts, uvs, NULL, NULL,
                                          indices, 6, p2);
                 } else {
-                    canvas->drawBitmapRect(fAtlas, &src, dst, &p,
-                                           SkCanvas::kBleed_DrawBitmapRectFlag);
+                    canvas->drawBitmapRect(fAtlas, src, dst, &p,
+                                           SkCanvas::kFast_SrcRectConstraint);
                 }
             } else {
-                canvas->drawBitmapRect(fCheckerboard, NULL, dst, &p);
+                canvas->drawBitmapRect(fCheckerboard, dst, &p);
             }
         }
     }
diff --git a/gm/bitmaprect.cpp b/gm/bitmaprect.cpp
index ff52c15..7e833cb 100644
--- a/gm/bitmaprect.cpp
+++ b/gm/bitmaprect.cpp
@@ -73,7 +73,7 @@
                 canvas->drawBitmapRect(bitmap, &srcR, dstR, &paint,
                                        SkCanvas::kStrict_SrcRectConstraint);
             } else {
-                canvas->drawBitmapRect(bitmap, &src[i], dstR, &paint);
+                canvas->drawBitmapRect(bitmap, src[i], dstR, &paint);
             }
 
             canvas->drawRect(dstR, paint);
@@ -143,7 +143,7 @@
         SkRect srcR = { 0.5f, 0.5f, 2.5f, 2.5f };
         SkRect dstR = { 100, 100, 300, 200 };
 
-        canvas->drawBitmapRectToRect(bitmap, &srcR, dstR, NULL);
+        canvas->drawBitmapRect(bitmap, &srcR, dstR, NULL);
     }
 
 private:
@@ -213,16 +213,16 @@
         SkRect dstR2 = { 10, 410, 30, 430 };
 
         if (!fUseIRect) {
-            canvas->drawBitmapRectToRect(fBigBitmap, &srcR1, dstR1, &paint);
-            canvas->drawBitmapRectToRect(fBigBitmap, &srcR2, dstR2, &paint);
+            canvas->drawBitmapRect(fBigBitmap, &srcR1, dstR1, &paint);
+            canvas->drawBitmapRect(fBigBitmap, &srcR2, dstR2, &paint);
         } else {
             SkIRect iSrcR1, iSrcR2;
 
             srcR1.roundOut(&iSrcR1);
             srcR2.roundOut(&iSrcR2);
 
-            canvas->drawBitmapRect(fBigBitmap, &iSrcR1, dstR1, &paint);
-            canvas->drawBitmapRect(fBigBitmap, &iSrcR2, dstR2, &paint);
+            canvas->drawBitmapRect(fBigBitmap, iSrcR1, dstR1, &paint);
+            canvas->drawBitmapRect(fBigBitmap, iSrcR2, dstR2, &paint);
         }
     }
 
diff --git a/gm/drawbitmaprect.cpp b/gm/drawbitmaprect.cpp
index 715f45b..9db5ca7 100644
--- a/gm/drawbitmaprect.cpp
+++ b/gm/drawbitmaprect.cpp
@@ -79,30 +79,25 @@
     return image_from_bitmap(*bm);
 }
 
-static void canvasproc(SkCanvas* canvas, SkImage*, const SkBitmap& bm, const SkIRect* srcR,
+static void canvasproc(SkCanvas* canvas, SkImage*, const SkBitmap& bm, const SkIRect& srcR,
                        const SkRect& dstR) {
-    canvas->drawBitmapRect(bm, srcR, dstR);
+    canvas->drawBitmapRect(bm, srcR, dstR, NULL);
 }
 
-static void imageproc(SkCanvas* canvas, SkImage* image, const SkBitmap&, const SkIRect* srcIR,
+static void imageproc(SkCanvas* canvas, SkImage* image, const SkBitmap&, const SkIRect& srcR,
                       const SkRect& dstR) {
-    SkRect storage, *srcR = NULL;
-    if (srcIR) {
-        storage.set(*srcIR);
-        srcR = &storage;
-    }
-    canvas->drawImageRect(image, srcR, dstR);
+    canvas->drawImageRect(image, srcR, dstR, NULL);
 }
 
-static void imagescaleproc(SkCanvas* canvas, SkImage* image, const SkBitmap&, const SkIRect* srcIR,
+static void imagescaleproc(SkCanvas* canvas, SkImage* image, const SkBitmap&, const SkIRect& srcIR,
                            const SkRect& dstR) {
     const int newW = SkScalarRoundToInt(dstR.width());
     const int newH = SkScalarRoundToInt(dstR.height());
-    SkAutoTUnref<SkImage> newImage(image->newImage(newW, newH, srcIR));
+    SkAutoTUnref<SkImage> newImage(image->newImage(newW, newH, &srcIR));
 
 #ifdef SK_DEBUG
     const SkIRect baseR = SkIRect::MakeWH(image->width(), image->height());
-    const bool containsSubset = !srcIR || baseR.contains(*srcIR);
+    const bool containsSubset = baseR.contains(srcIR);
 #endif
 
     if (newImage) {
@@ -121,7 +116,7 @@
     }
 }
 
-typedef void DrawRectRectProc(SkCanvas*, SkImage*, const SkBitmap&, const SkIRect*, const SkRect&);
+typedef void DrawRectRectProc(SkCanvas*, SkImage*, const SkBitmap&, const SkIRect&, const SkRect&);
 
 static const int gSize = 1024;
 static const int gBmpSize = 2048;
@@ -181,7 +176,7 @@
             for (int h = 1; h <= kMaxSrcRectSize; h *= 4) {
 
                 SkIRect srcRect = SkIRect::MakeXYWH((gBmpSize - w) / 2, (gBmpSize - h) / 2, w, h);
-                fProc(canvas, fImage, fLargeBitmap, &srcRect, dstRect);
+                fProc(canvas, fImage, fLargeBitmap, srcRect, dstRect);
 
                 SkString label;
                 label.appendf("%d x %d", w, h);
@@ -226,7 +221,7 @@
                 SkBlurMaskFilter::kHighQuality_BlurFlag |
                 SkBlurMaskFilter::kIgnoreTransform_BlurFlag);
             paint.setMaskFilter(mf)->unref();
-            canvas->drawBitmapRect(bm, &srcRect, dstRect, &paint);
+            canvas->drawBitmapRect(bm, srcRect, dstRect, &paint);
         }
     }
 
diff --git a/gm/tallstretchedbitmaps.cpp b/gm/tallstretchedbitmaps.cpp
index 424aa3a..4581f10 100644
--- a/gm/tallstretchedbitmaps.cpp
+++ b/gm/tallstretchedbitmaps.cpp
@@ -88,7 +88,7 @@
             SkRect dstRect = SkRect::MakeWH(SkIntToScalar(bmp.width()), 10.f * itemHeight);
             SkPaint paint;
             paint.setFilterQuality(kLow_SkFilterQuality);
-            canvas->drawBitmapRect(bmp, &subRect, dstRect, &paint);
+            canvas->drawBitmapRect(bmp, subRect, dstRect, &paint);
             canvas->translate(SkIntToScalar(bmp.width() + 10), 0);
         }
     }
diff --git a/gm/verylargebitmap.cpp b/gm/verylargebitmap.cpp
index 753786b..0dca1d7 100644
--- a/gm/verylargebitmap.cpp
+++ b/gm/verylargebitmap.cpp
@@ -45,7 +45,7 @@
 
     r.offset(SkIntToScalar(150), 0);
     // exercises extract bitmap, but not shader
-    canvas->drawBitmapRect(bm, &ir, r, NULL);
+    canvas->drawBitmapRect(bm, ir, r, NULL);
     canvas->drawRect(r, paint);
 
     r.offset(SkIntToScalar(150), 0);
diff --git a/gyp/skia_for_android_framework_defines.gypi b/gyp/skia_for_android_framework_defines.gypi
index 8545551..928d73c 100644
--- a/gyp/skia_for_android_framework_defines.gypi
+++ b/gyp/skia_for_android_framework_defines.gypi
@@ -21,6 +21,7 @@
       'SK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS',
       'SK_SUPPORT_LEGACY_SCALAR_DIV',
       'SK_SUPPORT_LEGACY_ONDRAWIMAGERECT',
+      'SK_SUPPORT_LEGACY_DRAWBITMAPRECTFLAGS_TYPE',
     ],
   },
 }
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index ca68185..c7d5089 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -35,7 +35,7 @@
 class GrContext;
 class GrRenderTarget;
 
-//#define SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
+//#define SK_SUPPORT_LEGACY_DRAWBITMAPRECTFLAGS_TYPE
 
 class SkCanvasState;
 
@@ -834,11 +834,10 @@
      *  @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, SrcRectConstraint);
+                       const SkPaint* paint, SrcRectConstraint = kStrict_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* src, const SkRect& dst) {
+        this->drawImageRect(image, src, dst, NULL, kStrict_SrcRectConstraint);
     }
 
     void drawImageRect(const SkImage* image, const SkRect& dst, const SkPaint* paint = NULL) {
@@ -846,6 +845,9 @@
         this->drawImageRect(image, NULL, dst, paint, kStrict_SrcRectConstraint);
     }
 
+    void drawImageRect(const SkImage* image, const SkIRect& isrc, const SkRect& dst,
+                       const SkPaint* paint, SrcRectConstraint = kStrict_SrcRectConstraint);
+
     /**
      *  Draw the image stretched differentially to fit into dst.
      *  center is a rect within the image, and logically divides the image
@@ -893,13 +895,22 @@
      *  @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.
      */
+#ifdef SK_SUPPORT_LEGACY_DRAWBITMAPRECTFLAGS_TYPE
     void drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
                         const SkPaint* paint, SrcRectConstraint);
+#else
+    void drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
+                        const SkPaint* paint, SrcRectConstraint = kStrict_SrcRectConstraint);
+#endif
 
     void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint* paint = NULL) {
         this->drawBitmapRect(bitmap, NULL, dst, paint, kStrict_SrcRectConstraint);
     }
 
+    void drawBitmapRect(const SkBitmap& bitmap, const SkIRect& isrc, const SkRect& dst,
+                        const SkPaint* paint, SrcRectConstraint = kStrict_SrcRectConstraint);
+
+#ifdef SK_SUPPORT_LEGACY_DRAWBITMAPRECTFLAGS_TYPE
     // IMPORTANT that thse be value-equal with SrcRectConstraint (during transition period)
     enum DrawBitmapRectFlags {
         kNone_DrawBitmapRectFlag            = 0x0,
@@ -934,6 +945,7 @@
         }
         this->drawBitmapRectToRect(bitmap, realSrcPtr, dst, paint, flags);
     }
+#endif
 
     /**
      *  Draw the bitmap stretched differentially to fit into dst.
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index a80ccd9..508ff63 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -1116,7 +1116,7 @@
         // Clear the background behind our zoomed in view
         paint.setColor(SK_ColorWHITE);
         canvas->drawRect(dest, paint);
-        canvas->drawBitmapRect(bitmap, &src, dest);
+        canvas->drawBitmapRect(bitmap, src, dest, NULL);
         paint.setColor(SK_ColorBLACK);
         paint.setStyle(SkPaint::kStroke_Style);
         // Draw a border around the pixel in the middle
diff --git a/samplecode/SampleBitmapRect.cpp b/samplecode/SampleBitmapRect.cpp
index 123bfb8..b6e629c 100644
--- a/samplecode/SampleBitmapRect.cpp
+++ b/samplecode/SampleBitmapRect.cpp
@@ -131,7 +131,7 @@
 
         for (int i = 0; i < 2; ++i) {
             paint.setFilterQuality(1 == i ? kLow_SkFilterQuality : kNone_SkFilterQuality);
-            canvas->drawBitmapRectToRect(bitmap, &srcR, fDstR[i], &paint);
+            canvas->drawBitmapRect(bitmap, &srcR, fDstR[i], &paint);
             canvas->drawRect(fDstR[i], paint);
         }
     }
@@ -225,7 +225,7 @@
 
         for (int i = 0; i < 2; ++i) {
             paint.setFilterQuality(1 == i ? kLow_SkFilterQuality : kNone_SkFilterQuality);
-            canvas->drawBitmapRectToRect(fBitmap, &fSrcR, fDstR[i], &paint);
+            canvas->drawBitmapRect(fBitmap, &fSrcR, fDstR[i], &paint);
             canvas->drawRect(fDstR[i], paint);
         }
     }
diff --git a/samplecode/SampleTextureDomain.cpp b/samplecode/SampleTextureDomain.cpp
index 2794a06..c798f42 100644
--- a/samplecode/SampleTextureDomain.cpp
+++ b/samplecode/SampleTextureDomain.cpp
@@ -53,7 +53,7 @@
         // the constrained texture domain.
         srcRect.setXYWH(1, 1, 3, 3);
         dstRect.setXYWH(5, 5, 305, 305);
-        canvas->drawBitmapRectToRect(fBM, &srcRect, dstRect, &paint);
+        canvas->drawBitmapRect(fBM, &srcRect, dstRect, &paint);
 
         // Test that bitmap draws across separate devices also respect
         // the constrainted texture domain.
@@ -64,8 +64,7 @@
 
         srcRect.setXYWH(1, 1, 3, 3);
         dstRect.setXYWH(1, 1, 3, 3);
-        surface->getCanvas()->drawBitmapRectToRect(fBM, &srcRect, dstRect,
-                                                   &paint);
+        surface->getCanvas()->drawBitmapRect(fBM, &srcRect, dstRect, &paint);
 
         SkAutoTUnref<SkImage> image(surface->newImageSnapshot());
 
@@ -98,7 +97,7 @@
         dstRect.setXYWH(-150, -150, 300, 300);
         canvas->translate(550, 550);
         canvas->rotate(45);
-        canvas->drawBitmapRectToRect(fBM, NULL, dstRect, &paint);
+        canvas->drawBitmapRect(fBM, dstRect, &paint);
     }
 private:
     typedef SkView INHERITED;
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 35551e7..941d868 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1772,6 +1772,12 @@
     this->onDrawImageRect(image, src, dst, paint SRC_RECT_CONSTRAINT_ARG(constraint));
 }
 
+void SkCanvas::drawImageRect(const SkImage* image, const SkIRect& isrc, const SkRect& dst,
+                             const SkPaint* paint, SrcRectConstraint constraint) {
+    SkRect src = SkRect::Make(isrc);
+    this->drawImageRect(image, &src, dst, paint, constraint);
+}
+
 void SkCanvas::drawImageNine(const SkImage* image, const SkIRect& center, const SkRect& dst,
                              const SkPaint* paint) {
     if (dst.isEmpty()) {
@@ -1790,6 +1796,7 @@
     this->onDrawBitmap(bitmap, dx, dy, paint);
 }
 
+#ifdef SK_SUPPORT_LEGACY_DRAWBITMAPRECTFLAGS_TYPE
 void SkCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
                                     const SkPaint* paint, DrawBitmapRectFlags flags) {
     if (bitmap.drawsNothing() || dst.isEmpty()) {
@@ -1797,6 +1804,7 @@
     }
     this->onDrawBitmapRect(bitmap, src, dst, paint, (SK_VIRTUAL_CONSTRAINT_TYPE)flags);
 }
+#endif
 
 void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
                               const SkPaint* paint, SrcRectConstraint constraint) {
@@ -1806,6 +1814,12 @@
     this->onDrawBitmapRect(bitmap, src, dst, paint, (SK_VIRTUAL_CONSTRAINT_TYPE)constraint);
 }
 
+void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkIRect& isrc, const SkRect& dst,
+                              const SkPaint* paint, SrcRectConstraint constraint) {
+    SkRect src = SkRect::Make(isrc);
+    this->drawBitmapRect(bitmap, &src, dst, paint, constraint);
+}
+
 void SkCanvas::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, const SkRect& dst,
                               const SkPaint* paint) {
     if (bitmap.drawsNothing() || dst.isEmpty()) {
diff --git a/src/effects/SkTestImageFilters.cpp b/src/effects/SkTestImageFilters.cpp
index ea5560f..cd277ec 100755
--- a/src/effects/SkTestImageFilters.cpp
+++ b/src/effects/SkTestImageFilters.cpp
@@ -71,7 +71,7 @@
 
         SkRect r = SkRect::MakeWH(SkIntToScalar(src.width()),
                                   SkIntToScalar(src.height()));
-        canvas.drawBitmapRect(tmp, NULL, r, NULL);
+        canvas.drawBitmapRect(tmp, r);
         *result = dev->accessBitmap(false);
     }
     return true;
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index bb04131..3334095 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -529,7 +529,7 @@
             break;
     }
     SkRect dstRect = SkRect::MakeWH(SkIntToScalar(stretch.fWidth), SkIntToScalar(stretch.fHeight));
-    canvas.drawBitmapRectToRect(bmp, NULL, dstRect, &paint);
+    canvas.drawBitmapRect(bmp, dstRect, &paint);
     return stretched;
 }
 
diff --git a/src/utils/SkNinePatch.cpp b/src/utils/SkNinePatch.cpp
index ce8d480..4a5308b 100644
--- a/src/utils/SkNinePatch.cpp
+++ b/src/utils/SkNinePatch.cpp
@@ -136,7 +136,7 @@
     const int numYStretch = (numYDivs + 1) >> 1;
 
     if (numXStretch < 1 && numYStretch < 1) {
-        canvas->drawBitmapRect(bitmap, NULL, bounds, paint);
+        canvas->drawBitmapRect(bitmap, bounds, paint);
         return;
     }
 
@@ -293,7 +293,7 @@
             s.fRight = srcX[x+1];
             d.fLeft = dstX[x];
             d.fRight = dstX[x+1];
-            canvas->drawBitmapRect(bitmap, &s, d, paint);
+            canvas->drawBitmapRect(bitmap, s, d, paint);
         }
     }
 }
diff --git a/src/utils/debugger/SkDrawCommand.cpp b/src/utils/debugger/SkDrawCommand.cpp
index 5f0f74f..1d28d2e 100644
--- a/src/utils/debugger/SkDrawCommand.cpp
+++ b/src/utils/debugger/SkDrawCommand.cpp
@@ -129,7 +129,7 @@
                                   yScale * input.height());
 
     canvas->clear(0xFFFFFFFF);
-    canvas->drawBitmapRect(input, NULL, dst);
+    canvas->drawBitmapRect(input, dst);
 
     if (srcRect) {
         SkRect r = SkRect::MakeLTRB(srcRect->fLeft * xScale + SK_Scalar1,
diff --git a/tests/DrawBitmapRectTest.cpp b/tests/DrawBitmapRectTest.cpp
index e6d46a7..7d8798c 100644
--- a/tests/DrawBitmapRectTest.cpp
+++ b/tests/DrawBitmapRectTest.cpp
@@ -299,7 +299,7 @@
     SkIRect srcR = { gWidth, 0, gWidth + 16, 16 };
     SkRect  dstR = { 0, 0, SkIntToScalar(16), SkIntToScalar(16) };
 
-    canvas.drawBitmapRect(src, &srcR, dstR, NULL);
+    canvas.drawBitmapRect(src, srcR, dstR, NULL);
 
     // ensure that we draw nothing if srcR does not intersect the bitmap
     REPORTER_ASSERT(reporter, check_for_all_zeros(dst));
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index ba66286..a20ff27 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -690,7 +690,7 @@
         make_bm(&bm, 10, 10, SK_ColorRED, true);
 
         r.offset(5.0f, 5.0f);
-        canvas->drawBitmapRectToRect(bm, NULL, r);
+        canvas->drawBitmapRect(bm, r);
 
         SkAutoTUnref<SkPicture> final(recorder.endRecording());
         REPORTER_ASSERT(reporter, final->willPlayBackBitmaps());
@@ -1167,7 +1167,7 @@
 
     // Don't care what these record, as long as they're legal.
     canvas->drawBitmap(bitmap, 0.0f, 0.0f, &paint);
-    canvas->drawBitmapRectToRect(bitmap, &rect, rect, &paint, SkCanvas::kNone_DrawBitmapRectFlag);
+    canvas->drawBitmapRect(bitmap, &rect, rect, &paint);
     canvas->drawBitmapNine(bitmap, irect, rect, &paint);
     canvas->drawSprite(bitmap, 1, 1);
 }
@@ -1197,8 +1197,8 @@
     // This test is from crbug.com/344987.
     // The commands are:
     //   saveLayer with paint that modifies alpha
-    //     drawBitmapRectToRect
-    //     drawBitmapRectToRect
+    //     drawBitmapRect
+    //     drawBitmapRect
     //   restore
     // The bug was that this structure was modified so that:
     //  - The saveLayer and restore were eliminated
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index 9d0c645..b1e233f 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -691,7 +691,7 @@
     EXPECT_COPY_ON_WRITE(drawRRect(testRRect, testPaint))
     EXPECT_COPY_ON_WRITE(drawPath(testPath, testPaint))
     EXPECT_COPY_ON_WRITE(drawBitmap(testBitmap, 0, 0))
-    EXPECT_COPY_ON_WRITE(drawBitmapRect(testBitmap, NULL, testRect))
+    EXPECT_COPY_ON_WRITE(drawBitmapRect(testBitmap, testRect))
     EXPECT_COPY_ON_WRITE(drawBitmapNine(testBitmap, testIRect, testRect, NULL))
     EXPECT_COPY_ON_WRITE(drawSprite(testBitmap, 0, 0, NULL))
     EXPECT_COPY_ON_WRITE(drawText(testText.c_str(), testText.size(), 0, 1, testPaint))