This CL plumbs in the drawBitmapRectToRect "bleed" flag and makes it live on the simplest GPU path.

R=bsalomon@google.com, reed@google.com, edisonn@google.com, scroggo@google.com, jvanverth@google.com, mtklein@google.com

Author: robertphillips@google.com

Review URL: https://chromiumcodereview.appspot.com/20806003

git-svn-id: http://skia.googlecode.com/svn/trunk/include@10765 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/core/SkCanvas.h b/core/SkCanvas.h
index a368182..915268d 100644
--- a/core/SkCanvas.h
+++ b/core/SkCanvas.h
@@ -673,6 +673,16 @@
     virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
                             const SkPaint* paint = NULL);
 
+    enum DrawBitmapRectFlags {
+        kNone_DrawBitmapRectflag            = 0x0,
+        /** 
+         *  When filtering is enabled, allow the color samples outside of
+         *  the src rect (but still in the src bitmap) to bleed into the 
+         *  drawn portion
+         */
+        kBleed_DrawBitmapRectFlag            = 0x1,
+    };
+
     /** Draw the specified bitmap, with the specified matrix applied (before the
         canvas' matrix is applied).
         @param bitmap   The bitmap to be drawn
@@ -683,22 +693,24 @@
     */
     virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
                                       const SkRect& dst,
-                                      const SkPaint* paint);
+                                      const SkPaint* paint = NULL,
+                                      DrawBitmapRectFlags flags = kNone_DrawBitmapRectflag);
 
     void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst,
-                        const SkPaint* paint) {
-        this->drawBitmapRectToRect(bitmap, NULL, dst, paint);
+                        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) {
+                        const SkRect& dst, const SkPaint* paint = NULL,
+                        DrawBitmapRectFlags flags = kNone_DrawBitmapRectflag) {
         SkRect realSrcStorage;
         SkRect* realSrcPtr = NULL;
         if (isrc) {
             realSrcStorage.set(*isrc);
             realSrcPtr = &realSrcStorage;
         }
-        this->drawBitmapRectToRect(bitmap, realSrcPtr, dst, paint);
+        this->drawBitmapRectToRect(bitmap, realSrcPtr, dst, paint, flags);
     }
 
     virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
@@ -1071,7 +1083,8 @@
     // canvas apis, without confusing subclasses (like SkPictureRecording)
     void internalDrawBitmap(const SkBitmap&, const SkMatrix& m, const SkPaint* paint);
     void internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
-                                const SkRect& dst, const SkPaint* paint);
+                                const SkRect& dst, const SkPaint* paint,
+                                DrawBitmapRectFlags flags);
     void internalDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
                                 const SkRect& dst, const SkPaint* paint);
     void internalDrawPaint(const SkPaint& paint);
diff --git a/core/SkDevice.h b/core/SkDevice.h
index f39e5dd..47eebe2 100644
--- a/core/SkDevice.h
+++ b/core/SkDevice.h
@@ -287,7 +287,8 @@
      */
     virtual void drawBitmapRect(const SkDraw&, const SkBitmap&,
                                 const SkRect* srcOrNull, const SkRect& dst,
-                                const SkPaint& paint);
+                                const SkPaint& paint,
+                                SkCanvas::DrawBitmapRectFlags flags);
 
     /**
      *  Does not handle text decoration.
diff --git a/core/SkPicture.h b/core/SkPicture.h
index 0bac3f7..95034c2 100644
--- a/core/SkPicture.h
+++ b/core/SkPicture.h
@@ -208,7 +208,11 @@
     // V10: add drawRRect, drawOval, clipRRect
     // V11: modify how readBitmap and writeBitmap store their info.
     // V12: add conics to SkPath, use new SkPathRef flattening
-    static const uint32_t PICTURE_VERSION = 12;
+    // V13: add flag to drawBitmapRectToRect
+#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V13_AND_ALL_OTHER_INSTANCES_TOO
+    static const uint32_t PRIOR_PICTURE_VERSION = 12;  // TODO: remove when .skps regenerated
+#endif
+    static const uint32_t PICTURE_VERSION = 13;
 
     // fPlayback, fRecord, fWidth & fHeight are protected to allow derived classes to
     // install their own SkPicturePlayback-derived players,SkPictureRecord-derived
diff --git a/gpu/SkGpuDevice.h b/gpu/SkGpuDevice.h
index 32f8749..40d2554 100644
--- a/gpu/SkGpuDevice.h
+++ b/gpu/SkGpuDevice.h
@@ -84,7 +84,8 @@
                             const SkMatrix&, const SkPaint&) SK_OVERRIDE;
     virtual void drawBitmapRect(const SkDraw&, const SkBitmap&,
                                 const SkRect* srcOrNull, const SkRect& dst,
-                                const SkPaint& paint) SK_OVERRIDE;
+                                const SkPaint& paint,
+                                SkCanvas::DrawBitmapRectFlags flags) SK_OVERRIDE;
     virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap,
                             int x, int y, const SkPaint& paint);
     virtual void drawText(const SkDraw&, const void* text, size_t len,
@@ -163,7 +164,8 @@
                           const SkBitmap& bitmap,
                           const SkRect* srcRectPtr,
                           const SkMatrix&,
-                          const SkPaint&);
+                          const SkPaint&,
+                          SkCanvas::DrawBitmapRectFlags flags);
 
     /**
      * Helper functions called by drawBitmapCommon. By the time these are called the SkDraw's
@@ -176,12 +178,14 @@
                             const SkRect&,
                             const SkMatrix&,
                             const GrTextureParams& params,
-                            const SkPaint& paint);
+                            const SkPaint& paint,
+                            SkCanvas::DrawBitmapRectFlags flags);
     void drawTiledBitmap(const SkBitmap& bitmap,
                          const SkRect& srcRect,
                          const SkMatrix& m,
                          const GrTextureParams& params,
-                         const SkPaint& paint);
+                         const SkPaint& paint,
+                         SkCanvas::DrawBitmapRectFlags flags);
 
     /**
      * Returns non-initialized instance.
diff --git a/pdf/SkPDFDevice.h b/pdf/SkPDFDevice.h
index 207b2b2..e64b83f 100644
--- a/pdf/SkPDFDevice.h
+++ b/pdf/SkPDFDevice.h
@@ -88,7 +88,8 @@
                           bool pathIsMutable) SK_OVERRIDE;
     virtual void drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap,
                                 const SkRect* src, const SkRect& dst,
-                                const SkPaint& paint) SK_OVERRIDE;
+                                const SkPaint& paint,
+                                SkCanvas::DrawBitmapRectFlags flags) SK_OVERRIDE;
     virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap,
                             const SkMatrix& matrix, const SkPaint&) SK_OVERRIDE;
     virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap, int x, int y,
diff --git a/utils/SkDeferredCanvas.h b/utils/SkDeferredCanvas.h
index 77229a7..539e5d3 100644
--- a/utils/SkDeferredCanvas.h
+++ b/utils/SkDeferredCanvas.h
@@ -170,8 +170,8 @@
                             SkScalar top, const SkPaint* paint)
                             SK_OVERRIDE;
     virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
-                                const SkRect& dst, const SkPaint* paint)
-                                SK_OVERRIDE;
+                                      const SkRect& dst, const SkPaint* paint,
+                                      DrawBitmapRectFlags flags) SK_OVERRIDE;
 
     virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
                                   const SkPaint* paint) SK_OVERRIDE;
diff --git a/utils/SkDumpCanvas.h b/utils/SkDumpCanvas.h
index cdb1f19..96b45e7 100644
--- a/utils/SkDumpCanvas.h
+++ b/utils/SkDumpCanvas.h
@@ -99,7 +99,8 @@
     virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
                             const SkPaint* paint) SK_OVERRIDE;
     virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
-                                const SkRect& dst, const SkPaint* paint) SK_OVERRIDE;
+                                      const SkRect& dst, const SkPaint* paint,
+                                      DrawBitmapRectFlags flags) SK_OVERRIDE;
     virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
                                   const SkPaint* paint) SK_OVERRIDE;
     virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
diff --git a/utils/SkLuaCanvas.h b/utils/SkLuaCanvas.h
index e41e58c..c34d134 100644
--- a/utils/SkLuaCanvas.h
+++ b/utils/SkLuaCanvas.h
@@ -48,7 +48,8 @@
     virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
                             const SkPaint* paint) SK_OVERRIDE;
     virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
-                                      const SkRect& dst, const SkPaint* paint) SK_OVERRIDE;
+                                      const SkRect& dst, const SkPaint* paint,
+                                      DrawBitmapRectFlags flags) SK_OVERRIDE;
     virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
                                   const SkPaint* paint) SK_OVERRIDE;
     virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
diff --git a/utils/SkNWayCanvas.h b/utils/SkNWayCanvas.h
index 5669cd0..3bb2c97 100644
--- a/utils/SkNWayCanvas.h
+++ b/utils/SkNWayCanvas.h
@@ -49,7 +49,8 @@
     virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
                             const SkPaint*) SK_OVERRIDE;
     virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
-                                const SkRect& dst, const SkPaint*) SK_OVERRIDE;
+                                      const SkRect& dst, const SkPaint* paint,
+                                      DrawBitmapRectFlags flags) SK_OVERRIDE;
     virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
                                   const SkPaint*) SK_OVERRIDE;
     virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
diff --git a/utils/SkProxyCanvas.h b/utils/SkProxyCanvas.h
index 4091636..383e532 100644
--- a/utils/SkProxyCanvas.h
+++ b/utils/SkProxyCanvas.h
@@ -54,7 +54,8 @@
     virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
                             const SkPaint* paint = NULL) SK_OVERRIDE;
     virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
-                                const SkRect& dst, const SkPaint* paint = NULL) SK_OVERRIDE;
+                                      const SkRect& dst, const SkPaint* paint,
+                                      DrawBitmapRectFlags flags) SK_OVERRIDE;
     virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
                                   const SkPaint* paint = NULL) SK_OVERRIDE;
     virtual void drawSprite(const SkBitmap& bitmap, int left, int top,