re-land 5578 w/ pipe fix
authorreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 18 Sep 2012 13:47:20 +0000 (13:47 +0000)
committerreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 18 Sep 2012 13:47:20 +0000 (13:47 +0000)
git-svn-id: http://skia.googlecode.com/svn/trunk@5580 2bbb7eff-a529-9590-31e7-b0007b416f81

29 files changed:
debugger/SkDebugCanvas.cpp
debugger/SkDebugCanvas.h
debugger/SkDrawCommand.cpp
debugger/SkDrawCommand.h
gm/aaclip.cpp
gm/bitmaprect.cpp [new file with mode: 0644]
gm/gmmain.cpp
gm/techtalk1.cpp
gyp/gmslides.gypi
include/core/SkCanvas.h
include/utils/SkDeferredCanvas.h
include/utils/SkDumpCanvas.h
include/utils/SkNWayCanvas.h
include/utils/SkProxyCanvas.h
src/core/SkBBoxRecord.cpp
src/core/SkBBoxRecord.h
src/core/SkCanvas.cpp
src/core/SkPicture.cpp
src/core/SkPictureFlat.h
src/core/SkPicturePlayback.cpp
src/core/SkPictureRecord.cpp
src/core/SkPictureRecord.h
src/pipe/SkGPipePriv.h
src/pipe/SkGPipeRead.cpp
src/pipe/SkGPipeWrite.cpp
src/utils/SkDeferredCanvas.cpp
src/utils/SkDumpCanvas.cpp
src/utils/SkNWayCanvas.cpp
src/utils/SkProxyCanvas.cpp

index 6fda8b0f24e13aa4979a35ad9cbabe3069f98fc5..db9154e15bdf643c8b457509a6959dc90c3f90ee 100644 (file)
@@ -183,8 +183,8 @@ void SkDebugCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar left,
     addDrawCommand(new DrawBitmap(bitmap, left, top, paint));
 }
 
-void SkDebugCanvas::drawBitmapRect(const SkBitmap& bitmap,
-        const SkIRect* src, const SkRect& dst, const SkPaint* paint) {
+void SkDebugCanvas::drawBitmapRectToRect(const SkBitmap& bitmap,
+        const SkRect* src, const SkRect& dst, const SkPaint* paint) {
     addDrawCommand(new DrawBitmapRect(bitmap, src, dst, paint));
 }
 
index 28340109fa425772c28edf1231521b1faa76c3e4..5172bc23f51aab15ea6f52156646deed28179ca5 100644 (file)
@@ -135,8 +135,8 @@ public:
     virtual void drawBitmap(const SkBitmap&, SkScalar left, SkScalar top,
                             const SkPaint*) SK_OVERRIDE;
 
-    virtual void drawBitmapRect(const SkBitmap&, const SkIRect* src,
-                                const SkRect& dst, const SkPaint*) SK_OVERRIDE;
+    virtual void drawBitmapRectToRect(const SkBitmap&, const SkRect* src,
+                                  const SkRect& dst, const SkPaint*) SK_OVERRIDE;
 
     virtual void drawBitmapMatrix(const SkBitmap&, const SkMatrix&,
                                   const SkPaint*) SK_OVERRIDE;
index 00ea535a58558bc5c6c678b41eead9eda14e9c7e..7d9eaea6e4ab216bfe7d95335dd6d30bc4859b12 100644 (file)
@@ -180,7 +180,7 @@ void DrawBitmapNine::execute(SkCanvas* canvas) {
     canvas->drawBitmapNine(*this->fBitmap, *this->fCenter, *this->fDst, this->fPaint);
 }
 
-DrawBitmapRect::DrawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
+DrawBitmapRect::DrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
         const SkRect& dst, const SkPaint* paint) {
     this->fBitmap = &bitmap;
     this->fSrc = src;
@@ -189,7 +189,7 @@ DrawBitmapRect::DrawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
     this->fDrawType = DRAW_BITMAP_RECT;
 
     this->fInfo.push(SkObjectParser::BitmapToString(bitmap));
-    if (src) this->fInfo.push(SkObjectParser::IRectToString(*src));
+    if (src) this->fInfo.push(SkObjectParser::RectToString(*src));
     this->fInfo.push(SkObjectParser::RectToString(dst));
     if (paint) this->fInfo.push(SkObjectParser::PaintToString(*paint));
 }
index 33b735e51e21257d2adfb0ab4a6478aaf42d7a6b..3334209bd0bc5aa8c4663bf7d90714300bfad8dc 100644 (file)
@@ -134,11 +134,11 @@ private:
 
 class DrawBitmapRect : public SkDrawCommand {
 public:
-    DrawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
+    DrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
             const SkRect& dst, const SkPaint* paint);
     virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
 private:
-    const SkIRect* fSrc;
+    const SkRect* fSrc;
     const SkPaint* fPaint;
     const SkBitmap* fBitmap;
     const SkRect* fDst;
index ef73614c6bbb9259301191f8932d9fe741000712..f67ac17a9f8a4b20d00e8ef613eece4a5017e4cf 100644 (file)
@@ -9,43 +9,6 @@
 #include "SkCanvas.h"
 #include "SkPath.h"
 
-#if 0
-def unpremul(x,alpha):
-assert x <= alpha
-if alpha == 0:
-return 0
-else:
-return math.floor(x*MAXVAL/alpha)
-
-def premul(X,alpha):
-return math.ceil(X*alpha/MAXVAL)
-#endif
-
-static int premul(int r, int a) {
-    SkASSERT(a >= 0 && a <= 255);
-    SkASSERT(r >= 0 && r <= 255);
-    return (int)ceil(r * a / 255.0);
-}
-
-static int unpremul(int r, int a) {
-    SkASSERT(a >= 0 && a <= 255);
-    SkASSERT(r >= 0 && r <= a);
-    if (0 == a) {
-        return 0;
-    }
-    return (int)floor(r * 255.0 / a);
-}
-
-static void test_premul() {
-    for (int a = 0; a <= 255; ++a) {
-        for (int r = 0; r <= a; ++r) {
-            int tmpr = unpremul(r, a);
-            int newr = premul(tmpr, a);
-            SkASSERT(newr == r);
-        }
-    }
-}
-
 static SkCanvas* MakeCanvas(const SkIRect& bounds) {
     SkBitmap bm;
     bm.setConfig(SkBitmap::kARGB_8888_Config, bounds.width(), bounds.height());
@@ -182,7 +145,7 @@ static void draw_rect_tests (SkCanvas* canvas) {
 class AAClipGM : public GM {
 public:
     AAClipGM() {
-        test_premul();
+
     }
 
 protected:
diff --git a/gm/bitmaprect.cpp b/gm/bitmaprect.cpp
new file mode 100644 (file)
index 0000000..0e6c074
--- /dev/null
@@ -0,0 +1,100 @@
+
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#include "gm.h"
+#include "SkCanvas.h"
+#include "SkGradientShader.h"
+#include "SkGraphics.h"
+#include "SkPath.h"
+#include "SkRegion.h"
+#include "SkShader.h"
+
+static void make_bitmap(SkBitmap* bitmap) {
+    SkCanvas canvas;
+
+    {
+        bitmap->setConfig(SkBitmap::kARGB_8888_Config, 64, 64);
+        bitmap->allocPixels();
+        canvas.setBitmapDevice(*bitmap);
+    }
+
+    canvas.drawColor(SK_ColorRED);
+    SkPaint paint;
+    paint.setAntiAlias(true);
+    const SkPoint pts[] = { { 0, 0 }, { 64, 64 } };
+    const SkColor colors[] = { SK_ColorWHITE, SK_ColorBLUE };
+    paint.setShader(SkGradientShader::CreateLinear(pts, colors, NULL, 2,
+                                                   SkShader::kClamp_TileMode))->unref();
+    canvas.drawCircle(32, 32, 32, paint);
+}
+
+class DrawBitmapRect2 : public skiagm::GM {
+    bool fUseIRect;
+public:
+    DrawBitmapRect2(bool useIRect) : fUseIRect(useIRect) {
+    }
+
+protected:
+    virtual SkString onShortName() SK_OVERRIDE {
+        SkString str;
+        str.printf("bitmaprect_%s", fUseIRect ? "i" : "s");
+        return str;
+    }
+
+    virtual SkISize onISize() SK_OVERRIDE {
+        return SkISize::Make(640, 480);
+    }
+
+    virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+        canvas->drawColor(0xFFCCCCCC);
+
+        const SkIRect src[] = {
+            { 0, 0, 32, 32 },
+            { 0, 0, 80, 80 },
+            { 32, 32, 96, 96 },
+            { -32, -32, 32, 32, }
+        };
+
+        SkPaint paint;
+        paint.setStyle(SkPaint::kStroke_Style);
+//        paint.setColor(SK_ColorGREEN);
+
+        SkBitmap bitmap;
+        make_bitmap(&bitmap);
+
+        SkRect dstR = { 0, 200, 128, 380 };
+
+        canvas->translate(16, 40);
+        for (size_t i = 0; i < SK_ARRAY_COUNT(src); i++) {
+            SkRect srcR;
+            srcR.set(src[i]);
+
+            canvas->drawBitmap(bitmap, 0, 0, &paint);
+            if (fUseIRect) {
+                canvas->drawBitmapRectToRect(bitmap, &srcR, dstR, &paint);
+            } else {
+                canvas->drawBitmapRect(bitmap, &src[i], dstR, &paint);
+            }
+
+            canvas->drawRect(dstR, paint);
+            canvas->drawRect(srcR, paint);
+
+            canvas->translate(160, 0);
+        }
+    }
+
+private:
+    typedef skiagm::GM INHERITED;
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+static skiagm::GM* MyFactory0(void*) { return new DrawBitmapRect2(false); }
+static skiagm::GM* MyFactory1(void*) { return new DrawBitmapRect2(true); }
+
+static skiagm::GMRegistry reg0(MyFactory0);
+static skiagm::GMRegistry reg1(MyFactory1);
index c4ed298efa8d70a2255db76e5508f89ece7a80c2..06a41958ccddce10c1f0ba0a101aa8177a245714 100644 (file)
@@ -1106,6 +1106,7 @@ int main(int argc, char * const argv[]) {
 
             if ((ERROR_NONE == testErrors) && doPipe &&
                 !(gmFlags & GM::kSkipPipe_Flag)) {
+                SkDebugf("test_pipe\n");
                 testErrors |= test_pipe_playback(gm, config,
                                                  forwardRenderedBitmap,
                                                  readPath, diffPath);
index acfea90fb54ea6768f92dc4a7c71c04765261d37..00c49569c0b4984be52d945bfc25ab4e78079e95 100644 (file)
@@ -8,7 +8,6 @@
 #include "gm.h"
 
 #include "SkColorPriv.h"
-#include "SkGradientShader.h"
 #include "SkGeometry.h"
 #include "SkShader.h"
 
@@ -312,25 +311,6 @@ static void draw_text(SkCanvas* canvas, bool showGL, int flags) {
     }
 }
 
-static void draw_grad(SkCanvas* canvas, bool showGL, int) {
-    SkPoint gradient_bounds[2];
-    gradient_bounds[0].iset(0, 0);
-    gradient_bounds[1].iset(0, 480);
-
-    SkColor colors[2];
-    colors[0] = 0xFFAB3300; // top
-    colors[1] = 0xFF4F0000; // bottom
-
-    SkShader* shader = SkGradientShader::CreateLinear(gradient_bounds,
-                                                         colors, NULL, 2, SkShader::kClamp_TileMode, NULL);
-
-    SkPaint paint;
-    paint.setShader(shader)->unref();
-    paint.setDither(showGL);
-
-    canvas->drawPaint(paint);
-}
-
 static const struct {
     DrawProc    fProc;
     const char* fName;
@@ -340,7 +320,6 @@ static const struct {
     {   draw_oval,  "Ovals" },
     {   draw_image, "Images" },
     {   draw_text,  "Text" },
-    {   draw_grad,  "Gradient" },
 };
 
 class TalkGM : public skiagm::GM {
@@ -414,9 +393,6 @@ ADD_GM(TalkGM, (3, true))
 ADD_GM(TalkGM, (4, false))
 ADD_GM(TalkGM, (4, true))
 
-ADD_GM(TalkGM, (5, false))
-ADD_GM(TalkGM, (5, true))
-
 //static GM* MyFactory(void*) { return new TalkGM(0, false); }
 //static GMRegistry reg(MyFactory);
 
index 17a41c8ec9f23f4207401168fa49bd26e25f60ff..a0d418ba83f469f62003b919dc02fc3b4408b10b 100644 (file)
@@ -8,6 +8,7 @@
     '../gm/bitmapcopy.cpp',
     '../gm/bitmapmatrix.cpp',
     '../gm/bitmapfilters.cpp',
+    '../gm/bitmaprect.cpp',
     '../gm/bitmapscroll.cpp',
     '../gm/blend.cpp',
     '../gm/blurs.cpp',
index 1f29e1c00ab68d4a65ec86be5063deb71a5c6024..4696c9f20bb824db26ba4c546af63e9c0faed2c4 100644 (file)
@@ -644,9 +644,26 @@ public:
                         image will be drawn
         @param paint    The paint used to draw the bitmap, or NULL
     */
-    virtual void drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
-                                const SkRect& dst, const SkPaint* paint = NULL);
+    virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
+                                      const SkRect& dst,
+                                      const SkPaint* paint);
+
+    void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst,
+                        const SkPaint* paint) {
+        this->drawBitmapRectToRect(bitmap, NULL, dst, paint);
+    }
 
+    void drawBitmapRect(const SkBitmap& bitmap, const SkIRect* isrc,
+                        const SkRect& dst, const SkPaint* paint = NULL) {
+        SkRect realSrcStorage;
+        SkRect* realSrcPtr = NULL;
+        if (isrc) {
+            realSrcStorage.set(*isrc);
+            realSrcPtr = &realSrcStorage;
+        }
+        this->drawBitmapRectToRect(bitmap, realSrcPtr, dst, paint);
+    }
+    
     virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
                                   const SkPaint* paint = NULL);
 
@@ -993,7 +1010,7 @@ private:
     // canvas apis, without confusing subclasses (like SkPictureRecording)
     void internalDrawBitmap(const SkBitmap&, const SkIRect*, const SkMatrix& m,
                                   const SkPaint* paint);
-    void internalDrawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
+    void internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
                                 const SkRect& dst, const SkPaint* paint);
     void internalDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
                                 const SkRect& dst, const SkPaint* paint);
index 8779df96b27f4479b03218f4170792d7a5e40d39..5e8920024a87b0bd0fb3593272069ae3430c0655 100644 (file)
@@ -138,7 +138,7 @@ public:
     virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left,
                             SkScalar top, const SkPaint* paint)
                             SK_OVERRIDE;
-    virtual void drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
+    virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
                                 const SkRect& dst, const SkPaint* paint)
                                 SK_OVERRIDE;
 
index bae84c6e8405e5c2566f95b58648e6fd01ae7811..4eb1f25fcc6439b3897daa2eaf146690089f5d53 100644 (file)
@@ -87,7 +87,7 @@ public:
     virtual void drawPath(const SkPath& path, const SkPaint& paint) SK_OVERRIDE;
     virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
                             const SkPaint* paint) SK_OVERRIDE;
-    virtual void drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
+    virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
                                 const SkRect& dst, const SkPaint* paint) SK_OVERRIDE;
     virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
                                   const SkPaint* paint) SK_OVERRIDE;
index dbf4a589f7bb789bb0f944659c4f0dcfafb13937..065adf0a470fbaaf6eb2bf00c75f1ea3a8f6848a 100644 (file)
@@ -45,7 +45,7 @@ public:
     virtual void drawPath(const SkPath& path, const SkPaint&) SK_OVERRIDE;
     virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
                             const SkPaint*) SK_OVERRIDE;
-    virtual void drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
+    virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
                                 const SkRect& dst, const SkPaint*) SK_OVERRIDE;
     virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
                                   const SkPaint*) SK_OVERRIDE;
index 720436bc4238f987285bfc1a5467437fd340d08e..aa4708544fd031cb029c79c0ea8310c1507e6c40 100644 (file)
@@ -50,7 +50,7 @@ public:
     virtual void drawPath(const SkPath& path, const SkPaint& paint) SK_OVERRIDE;
     virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
                             const SkPaint* paint = NULL) SK_OVERRIDE;
-    virtual void drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
+    virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
                                 const SkRect& dst, const SkPaint* paint = NULL) SK_OVERRIDE;
     virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
                                   const SkPaint* paint = NULL) SK_OVERRIDE;
index 41f6b95516288c5016f38bed621ea4e1586f8a3b..52e5dd3f4401b794c9802855002526f599249922 100644 (file)
@@ -101,10 +101,10 @@ void SkBBoxRecord::drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar to
     }
 }
 
-void SkBBoxRecord::drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
+void SkBBoxRecord::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
                                   const SkRect& dst, const SkPaint* paint) {
     if (this->transformBounds(dst, paint)) {
-        INHERITED::drawBitmapRect(bitmap, src, dst, paint);
+        INHERITED::drawBitmapRectToRect(bitmap, src, dst, paint);
     }
 }
 
index 5cf8a506251ab0b8fa6eeb59c0759a48f7e5624c..c13a7f01c445b792e5409f0f23f74a6b6897aca3 100644 (file)
@@ -38,7 +38,7 @@ public:
                           const SkPaint& paint) SK_OVERRIDE;
     virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
                             const SkPaint* paint = NULL) SK_OVERRIDE;
-    virtual void drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
+    virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
                                 const SkRect& dst, const SkPaint* paint) SK_OVERRIDE;
     virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& mat,
                                   const SkPaint* paint) SK_OVERRIDE;
index 0df44b66de33bff2336ff7b3235ca62c119d0df3..9ef9c25e919e297ef28f3f8c66092ec22fe12c02 100644 (file)
@@ -1576,13 +1576,12 @@ void SkCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
 }
 
 // this one is non-virtual, so it can be called safely by other canvas apis
-void SkCanvas::internalDrawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
+void SkCanvas::internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
                                       const SkRect& dst, const SkPaint* paint) {
     if (bitmap.width() == 0 || bitmap.height() == 0 || dst.isEmpty()) {
         return;
     }
 
-    // do this now, to avoid the cost of calling extract for RLE bitmaps
     if (NULL == paint || paint->canComputeFastBounds()) {
         SkRect storage;
         const SkRect* bounds = &dst;
@@ -1594,43 +1593,45 @@ void SkCanvas::internalDrawBitmapRect(const SkBitmap& bitmap, const SkIRect* src
         }
     }
 
-    const SkBitmap* bitmapPtr = &bitmap;
-
     SkMatrix matrix;
-    SkRect tmpSrc;
-    if (src) {
-        tmpSrc.set(*src);
-        // if the extract process clipped off the top or left of the
-        // original, we adjust for that here to get the position right.
-        if (tmpSrc.fLeft > 0) {
-            tmpSrc.fRight -= tmpSrc.fLeft;
-            tmpSrc.fLeft = 0;
-        }
-        if (tmpSrc.fTop > 0) {
-            tmpSrc.fBottom -= tmpSrc.fTop;
-            tmpSrc.fTop = 0;
+    // Compute matrix from the two rectangles
+    {
+        SkRect tmpSrc;
+        if (src) {
+            tmpSrc = *src;
+            // if the extract process clipped off the top or left of the
+            // original, we adjust for that here to get the position right.
+            if (tmpSrc.fLeft > 0) {
+                tmpSrc.fRight -= tmpSrc.fLeft;
+                tmpSrc.fLeft = 0;
+            }
+            if (tmpSrc.fTop > 0) {
+                tmpSrc.fBottom -= tmpSrc.fTop;
+                tmpSrc.fTop = 0;
+            }
+        } else {
+            tmpSrc.set(0, 0, SkIntToScalar(bitmap.width()),
+                       SkIntToScalar(bitmap.height()));
         }
-    } else {
-        tmpSrc.set(0, 0, SkIntToScalar(bitmap.width()),
-                   SkIntToScalar(bitmap.height()));
+        matrix.setRectToRect(tmpSrc, dst, SkMatrix::kFill_ScaleToFit);
     }
-    matrix.setRectToRect(tmpSrc, dst, SkMatrix::kFill_ScaleToFit);
 
     // ensure that src is "valid" before we pass it to our internal routines
     // and to SkDevice. i.e. sure it is contained inside the original bitmap.
-    SkIRect tmpISrc;
+    SkIRect isrcStorage;
+    SkIRect* isrcPtr = NULL;
     if (src) {
-        tmpISrc.set(0, 0, bitmap.width(), bitmap.height());
-        if (!tmpISrc.intersect(*src)) {
+        src->roundOut(&isrcStorage);
+        if (!isrcStorage.intersect(0, 0, bitmap.width(), bitmap.height())) {
             return;
         }
-        src = &tmpISrc;
+        isrcPtr = &isrcStorage;
     }
-    this->internalDrawBitmap(*bitmapPtr, src, matrix, paint);
+    this->internalDrawBitmap(bitmap, isrcPtr, matrix, paint);
 }
 
-void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
-                              const SkRect& dst, const SkPaint* paint) {
+void SkCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
+                                    const SkRect& dst, const SkPaint* paint) {
     SkDEBUGCODE(bitmap.validate();)
     this->internalDrawBitmapRect(bitmap, src, dst, paint);
 }
@@ -1678,8 +1679,12 @@ void SkCanvas::internalDrawBitmapNine(const SkBitmap& bitmap,
     c.fRight = SkPin32(center.fRight, c.fLeft, w);
     c.fBottom = SkPin32(center.fBottom, c.fTop, h);
 
-    const int32_t srcX[4] = { 0, c.fLeft, c.fRight, w };
-    const int32_t srcY[4] = { 0, c.fTop, c.fBottom, h };
+    const SkScalar srcX[4] = {
+        0, SkIntToScalar(c.fLeft), SkIntToScalar(c.fRight), w
+    };
+    const SkScalar srcY[4] = {
+        0, SkIntToScalar(c.fTop), SkIntToScalar(c.fBottom), h
+    };
     SkScalar dstX[4] = {
         dst.fLeft, dst.fLeft + SkIntToScalar(c.fLeft),
         dst.fRight - SkIntToScalar(w - c.fRight), dst.fRight
@@ -1699,9 +1704,9 @@ void SkCanvas::internalDrawBitmapNine(const SkBitmap& bitmap,
         dstY[2] = dstY[1];
     }
 
-    SkIRect s;
-    SkRect  d;
     for (int y = 0; y < 3; y++) {
+        SkRect s, d;
+
         s.fTop = srcY[y];
         s.fBottom = srcY[y+1];
         d.fTop = dstY[y];
index 4c7ccf7c0fe3d735af87dce66326ee1014e7902b..7e8b371b588cf2169f5acbb1abbaf8110bb29f8d 100644 (file)
@@ -240,7 +240,8 @@ void SkPicture::draw(SkCanvas* surface) {
 // V4 : move SkPictInfo to be the header
 // V5 : don't read/write FunctionPtr on cross-process (we can detect that)
 // V6 : added serialization of SkPath's bounds (and packed its flags tighter)
-#define PICTURE_VERSION     6
+// V7 : changed drawBitmapRect(IRect) to drawBitmapRectToRect(Rect)
+#define PICTURE_VERSION     7
 
 SkPicture::SkPicture(SkStream* stream, bool* success) : SkRefCnt() {
     if (success) {
index 6671f1bdf90f5988142581605d9c284c9a9a9b12..2c8aa2c18e15cacc6a8703c12484930327c4a577 100644 (file)
@@ -33,7 +33,7 @@ enum DrawType {
     DRAW_BITMAP,
     DRAW_BITMAP_MATRIX,
     DRAW_BITMAP_NINE,
-    DRAW_BITMAP_RECT,
+    DRAW_BITMAP_RECT_TO_RECT,
     DRAW_CLEAR,
     DRAW_DATA,
     DRAW_PAINT,
index e3181d0cb9c994e18d8b268110a5d67d857f6160..3bff5ea9253bbad421c0a74ef4fc41d4d1f6ae2e 100644 (file)
@@ -672,12 +672,12 @@ void SkPicturePlayback::draw(SkCanvas& canvas) {
                 const SkPoint& loc = reader.skipT<SkPoint>();
                 canvas.drawBitmap(bitmap, loc.fX, loc.fY, paint);
             } break;
-            case DRAW_BITMAP_RECT: {
+            case DRAW_BITMAP_RECT_TO_RECT: {
                 const SkPaint* paint = getPaint(reader);
                 const SkBitmap& bitmap = getBitmap(reader);
-                const SkIRect* src = this->getIRectPtr(reader);   // may be null
+                const SkRect* src = this->getRectPtr(reader);   // may be null
                 const SkRect& dst = reader.skipT<SkRect>();     // required
-                canvas.drawBitmapRect(bitmap, src, dst, paint);
+                canvas.drawBitmapRectToRect(bitmap, src, dst, paint);
             } break;
             case DRAW_BITMAP_MATRIX: {
                 const SkPaint* paint = getPaint(reader);
index 73a3ab549a519f9311275808dadedfa47128f6da..944fd1898f0056f650de7e76a1d19b9a05b02905 100644 (file)
@@ -426,12 +426,12 @@ void SkPictureRecord::drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar
     validate();
 }
 
-void SkPictureRecord::drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
+void SkPictureRecord::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
                             const SkRect& dst, const SkPaint* paint) {
-    addDraw(DRAW_BITMAP_RECT);
+    addDraw(DRAW_BITMAP_RECT_TO_RECT);
     addPaintPtr(paint);
     addBitmap(bitmap);
-    addIRectPtr(src);  // may be null
+    addRectPtr(src);  // may be null
     addRect(dst);
     validate();
 }
index a6e0b68050adbfc932086a9dadfc292da72ccb0d..fec1a829f31d5fd3fa015b6d87c3fa8ba35a689b 100644 (file)
@@ -46,8 +46,8 @@ public:
     virtual void drawPath(const SkPath& path, const SkPaint&) SK_OVERRIDE;
     virtual void drawBitmap(const SkBitmap&, SkScalar left, SkScalar top,
                             const SkPaint*) SK_OVERRIDE;
-    virtual void drawBitmapRect(const SkBitmap&, const SkIRect* src,
-                                const SkRect& dst, const SkPaint*) SK_OVERRIDE;
+    virtual void drawBitmapRectToRect(const SkBitmap&, const SkRect* src,
+                                      const SkRect& dst, const SkPaint*) SK_OVERRIDE;
     virtual void drawBitmapMatrix(const SkBitmap&, const SkMatrix&,
                                   const SkPaint*) SK_OVERRIDE;
     virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
index 207a3bdc8a983d24f2cff8783ab7f0165b87c8c2..31803ea9b55a88b78cb4990f0a2fc4d52ff474bd 100644 (file)
@@ -41,7 +41,7 @@ enum DrawOps {
     kDrawBitmap_DrawOp,
     kDrawBitmapMatrix_DrawOp,
     kDrawBitmapNine_DrawOp,
-    kDrawBitmapRect_DrawOp,
+    kDrawBitmapRectToRect_DrawOp,
     kDrawClear_DrawOp,
     kDrawData_DrawOp,
     kDrawPaint_DrawOp,
index 803685a07de70014e0222839a1b8c68ccb1832e8..137ecb706251b3d31fc9e0077d4b33dc88857fdd 100644 (file)
@@ -490,14 +490,14 @@ static void drawBitmapRect_rp(SkCanvas* canvas, SkReader32* reader,
     unsigned flags = DrawOp_unpackFlags(op32);
     bool hasPaint = SkToBool(flags & kDrawBitmap_HasPaint_DrawOpFlag);
     bool hasSrc = SkToBool(flags & kDrawBitmap_HasSrcRect_DrawOpFlag);
-    const SkIRect* src;
+    const SkRect* src;
     if (hasSrc) {
-        src = skip<SkIRect>(reader);
+        src = skip<SkRect>(reader);
     } else {
         src = NULL;
     }
     const SkRect* dst = skip<SkRect>(reader);
-    canvas->drawBitmapRect(*holder.getBitmap(), src, *dst, hasPaint ? &state->paint() : NULL);
+    canvas->drawBitmapRectToRect(*holder.getBitmap(), src, *dst, hasPaint ? &state->paint() : NULL);
 }
 
 static void drawSprite_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
index b41ebb72fd75717712bc3c6ae884a5c0a18665cf..f0b4e0aee61d375be3ab4c1e0ea765f87ef24615 100644 (file)
@@ -221,7 +221,7 @@ public:
     virtual void drawPath(const SkPath& path, const SkPaint&) SK_OVERRIDE;
     virtual void drawBitmap(const SkBitmap&, SkScalar left, SkScalar top,
                             const SkPaint*) SK_OVERRIDE;
-    virtual void drawBitmapRect(const SkBitmap&, const SkIRect* src,
+    virtual void drawBitmapRectToRect(const SkBitmap&, const SkRect* src,
                                 const SkRect& dst, const SkPaint*) SK_OVERRIDE;
     virtual void drawBitmapMatrix(const SkBitmap&, const SkMatrix&,
                                   const SkPaint*) SK_OVERRIDE;
@@ -732,7 +732,7 @@ void SkGPipeCanvas::drawBitmap(const SkBitmap& bm, SkScalar left, SkScalar top,
     }
 }
 
-void SkGPipeCanvas::drawBitmapRect(const SkBitmap& bm, const SkIRect* src,
+void SkGPipeCanvas::drawBitmapRectToRect(const SkBitmap& bm, const SkRect* src,
                                    const SkRect& dst, const SkPaint* paint) {
     NOTIFY_SETUP(this);
     size_t opBytesNeeded = sizeof(SkRect);
@@ -745,12 +745,9 @@ void SkGPipeCanvas::drawBitmapRect(const SkBitmap& bm, const SkIRect* src,
         flags = 0;
     }
 
-    if (this->commonDrawBitmap(bm, kDrawBitmapRect_DrawOp, flags, opBytesNeeded, paint)) {
+    if (this->commonDrawBitmap(bm, kDrawBitmapRectToRect_DrawOp, flags, opBytesNeeded, paint)) {
         if (hasSrc) {
-            fWriter.write32(src->fLeft);
-            fWriter.write32(src->fTop);
-            fWriter.write32(src->fRight);
-            fWriter.write32(src->fBottom);
+            fWriter.writeRect(*src);
         }
         fWriter.writeRect(dst);
     }
index bbd3ae88010f7f205945b1eb7f285d505d868750..ef2c0bde2918a5bfd9e5d0fd1c8ff1a6288761e3 100644 (file)
@@ -856,10 +856,10 @@ void SkDeferredCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar left,
     this->recordedDrawCommand();
 }
 
-void SkDeferredCanvas::drawBitmapRect(const SkBitmap& bitmap,
-                                      const SkIRect* src,
-                                      const SkRect& dst,
-                                      const SkPaint* paint) {
+void SkDeferredCanvas::drawBitmapRectToRect(const SkBitmap& bitmap,
+                                            const SkRect* src,
+                                            const SkRect& dst,
+                                            const SkPaint* paint) {
     if (fDeferredDrawing &&
         this->isFullFrame(&dst, paint) &&
         isPaintOpaque(paint, &bitmap)) {
@@ -867,7 +867,7 @@ void SkDeferredCanvas::drawBitmapRect(const SkBitmap& bitmap,
     }
 
     AutoImmediateDrawIfNeeded autoDraw(*this, &bitmap, paint);
-    this->drawingCanvas()->drawBitmapRect(bitmap, src, dst, paint);
+    this->drawingCanvas()->drawBitmapRectToRect(bitmap, src, dst, paint);
     this->recordedDrawCommand();
 }
 
index 755a39bd4da2e43013cbb00c198fdeca7db34919..f1af88fc1fef3e785e8a0d37c863371359ce633c 100644 (file)
@@ -318,21 +318,21 @@ void SkDumpCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
                SkScalarToFloat(x), SkScalarToFloat(y));
 }
 
-void SkDumpCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
-                                   const SkRect& dst, const SkPaint* paint) {
+void SkDumpCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
+                                        const SkRect& dst, const SkPaint* paint) {
     SkString bs, rs;
     toString(bitmap, &bs);
     toString(dst, &rs);
     // show the src-rect only if its not everything
     if (src && (src->fLeft > 0 || src->fTop > 0 ||
-                src->fRight < bitmap.width() ||
-                src->fBottom < bitmap.height())) {
+                src->fRight < SkIntToScalar(bitmap.width()) ||
+                src->fBottom < SkIntToScalar(bitmap.height()))) {
         SkString ss;
         toString(*src, &ss);
         rs.prependf("%s ", ss.c_str());
     }
 
-    this->dump(kDrawBitmap_Verb, paint, "drawBitmapRect(%s %s)",
+    this->dump(kDrawBitmap_Verb, paint, "drawBitmapRectToRect(%s %s)",
                bs.c_str(), rs.c_str());
 }
 
index 9f6ebc68bc284eca7f795ddb11591b6acd5e54d3..2ca80ce2d1549b679bdf22393361661c0c829359 100644 (file)
@@ -194,11 +194,11 @@ void SkNWayCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
     }
 }
 
-void SkNWayCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
+void SkNWayCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
                                   const SkRect& dst, const SkPaint* paint) {
     Iter iter(fList);
     while (iter.next()) {
-        iter->drawBitmapRect(bitmap, src, dst, paint);
+        iter->drawBitmapRectToRect(bitmap, src, dst, paint);
     }
 }
 
index bc21d526497c9be79d29ebb8893105844fc1a018..e245c73272101934e62a506b6a81ae11ebbbfd42 100644 (file)
@@ -92,9 +92,9 @@ void SkProxyCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
     fProxy->drawBitmap(bitmap, x, y, paint);
 }
 
-void SkProxyCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
+void SkProxyCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
                                    const SkRect& dst, const SkPaint* paint) {
-    fProxy->drawBitmapRect(bitmap, src, dst, paint);
+    fProxy->drawBitmapRectToRect(bitmap, src, dst, paint);
 }
 
 void SkProxyCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,