Alter SkCanvas::drawPicture (devirtualize, take const SkPicture, take pointer)

R=reed@google.com, bsalomon@google.com, mtklein@google.com

Author: robertphillips@google.com

Review URL: https://codereview.chromium.org/313613004
diff --git a/dm/DMUtil.cpp b/dm/DMUtil.cpp
index f142d47..23634c3 100644
--- a/dm/DMUtil.cpp
+++ b/dm/DMUtil.cpp
@@ -35,7 +35,7 @@
     SkASSERT(picture != NULL);
     SkASSERT(bitmap != NULL);
     SkCanvas canvas(*bitmap);
-    canvas.drawPicture(*picture);
+    canvas.drawPicture(picture);
     canvas.flush();
 }
 
diff --git a/experimental/PdfViewer/SkNulCanvas.h b/experimental/PdfViewer/SkNulCanvas.h
index 1790b48..a976ea4 100644
--- a/experimental/PdfViewer/SkNulCanvas.h
+++ b/experimental/PdfViewer/SkNulCanvas.h
@@ -47,7 +47,6 @@
                                 const SkRect& dst, const SkPaint* paint = NULL) SK_OVERRIDE {}
     virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
                             const SkPaint* paint = NULL) SK_OVERRIDE {}
-    virtual void drawPicture(SkPicture& picture) SK_OVERRIDE {}
     virtual void drawVertices(VertexMode vmode, int vertexCount,
                               const SkPoint vertices[], const SkPoint texs[],
                               const SkColor colors[], SkXfermode* xmode,
@@ -104,6 +103,8 @@
     virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE {}
     virtual void onClipRegion(const SkRegion&, SkRegion::Op)  SK_OVERRIDE {}
 
+    virtual void onDrawPicture(const SkPicture* picture) SK_OVERRIDE {}
+    
 private:
     typedef SkCanvas INHERITED;
 };
diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp
index 65a233f..b739714 100644
--- a/gm/gmmain.cpp
+++ b/gm/gmmain.cpp
@@ -642,7 +642,7 @@
             SkCanvas canvas(*bitmap);
             installFilter(&canvas);
             canvas.scale(scale, scale);
-            canvas.drawPicture(*pict);
+            canvas.drawPicture(pict);
             complete_bitmap(bitmap);
         }
     }
diff --git a/gm/pathopsskpclip.cpp b/gm/pathopsskpclip.cpp
index e04692b..076f733 100644
--- a/gm/pathopsskpclip.cpp
+++ b/gm/pathopsskpclip.cpp
@@ -55,13 +55,13 @@
 
         canvas->setAllowSimplifyClip(true);
         canvas->save();
-        canvas->drawPicture(*pict);
+        canvas->drawPicture(pict);
         canvas->restore();
 
         canvas->setAllowSimplifyClip(false);
         canvas->save();
         canvas->translate(SkIntToScalar(1200 / 2), 0);
-        canvas->drawPicture(*pict);
+        canvas->drawPicture(pict);
         canvas->restore();
     }
 
diff --git a/gyp/skia_for_android_framework_defines.gypi b/gyp/skia_for_android_framework_defines.gypi
index abcda61..12cf94b 100644
--- a/gyp/skia_for_android_framework_defines.gypi
+++ b/gyp/skia_for_android_framework_defines.gypi
@@ -20,6 +20,7 @@
       # Transitional, for deprecated SkCanvas::SaveFlags methods.
       'SK_ATTR_DEPRECATED=SK_NOTHING_ARG1',
       'SK_SUPPORT_LEGACY_SHADER_LOCALMATRIX',
+      'SK_SUPPORT_LEGACY_DRAWPICTURE_API',
     ],
   },
 }
diff --git a/gyp/skia_for_chromium_defines.gypi b/gyp/skia_for_chromium_defines.gypi
index d1cd24c..f4e65bc 100644
--- a/gyp/skia_for_chromium_defines.gypi
+++ b/gyp/skia_for_chromium_defines.gypi
@@ -19,6 +19,7 @@
       'SK_IGNORE_CORRECT_HIGH_QUALITY_IMAGE_SCALE',
       'SK_IGNORE_ETC1_SUPPORT',
       'SK_SUPPORT_LEGACY_INSTALLPIXELSPARAMS',
+      'SK_SUPPORT_LEGACY_DRAWPICTURE_API',
     ],
   },
 }
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 4aaf46b..ee8ad25 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -969,13 +969,13 @@
         drawPicture call.
         @param picture The recorded drawing commands to analyze/optimize
     */
-    void EXPERIMENTAL_optimize(SkPicture* picture);
+    void EXPERIMENTAL_optimize(const SkPicture* picture);
 
     /** PRIVATE / EXPERIMENTAL -- do not call
         Purge all the discardable optimization information associated with
         'picture'. If NULL is passed in, purge all discardable information.
     */
-    void EXPERIMENTAL_purge(SkPicture* picture);
+    void EXPERIMENTAL_purge(const SkPicture* picture);
 
     /** Draw the picture into this canvas. This method effective brackets the
         playback of the picture's draw calls with save/restore, so the state
@@ -983,7 +983,13 @@
         @param picture The recorded drawing commands to playback into this
                        canvas.
     */
-    virtual void drawPicture(SkPicture& picture);
+    void drawPicture(const SkPicture* picture);
+
+#ifdef SK_SUPPORT_LEGACY_DRAWPICTURE_API
+    virtual void drawPicture(SkPicture& picture) {
+        this->drawPicture(&picture);
+    }
+#endif
 
     enum VertexMode {
         kTriangles_VertexMode,
@@ -1242,6 +1248,8 @@
 
     virtual void onDiscard();
 
+    virtual void onDrawPicture(const SkPicture* picture);
+
     // Returns the canvas to be used by DrawIter. Default implementation
     // returns this. Subclasses that encapsulate an indirect canvas may
     // need to overload this method. The impl must keep track of this, as it
diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h
index 078f7f5..e58a491 100644
--- a/include/core/SkDevice.h
+++ b/include/core/SkDevice.h
@@ -343,14 +343,14 @@
      *  PRIVATE / EXPERIMENTAL -- do not call
      *  Construct an acceleration object and attach it to 'picture'
      */
-    virtual void EXPERIMENTAL_optimize(SkPicture* picture);
+    virtual void EXPERIMENTAL_optimize(const SkPicture* picture);
 
     /**
      *  PRIVATE / EXPERIMENTAL -- do not call
      *  Purge all discardable optimization information for 'picture'. If
      *  picture is NULL then purge discardable information for all pictures.
      */
-    virtual void EXPERIMENTAL_purge(SkPicture* picture);
+    virtual void EXPERIMENTAL_purge(const SkPicture* picture);
 
     /**
      *  PRIVATE / EXPERIMENTAL -- do not call
@@ -362,7 +362,7 @@
      *  to perform some device-specific warm up tasks and then let SkCanvas
      *  perform the main rendering loop (by return false from here).
      */
-    virtual bool EXPERIMENTAL_drawPicture(SkCanvas* canvas, SkPicture* picture);
+    virtual bool EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* picture);
 
 private:
     friend class SkCanvas;
diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h
index 7ca59bf..a908ab5 100644
--- a/include/core/SkPicture.h
+++ b/include/core/SkPicture.h
@@ -68,7 +68,7 @@
     SkPicture(const SkPicture& src);
 
     /**  PRIVATE / EXPERIMENTAL -- do not call */
-    void EXPERIMENTAL_addAccelData(const AccelData* data) {
+    void EXPERIMENTAL_addAccelData(const AccelData* data) const {
         SkRefCnt_SafeAssign(fAccelData, data);
     }
     /**  PRIVATE / EXPERIMENTAL -- do not call */
@@ -151,7 +151,7 @@
         calls endRecording() if that has not already been called.
         @param canvas the canvas receiving the drawing commands.
     */
-    void draw(SkCanvas* canvas, SkDrawPictureCallback* = NULL);
+    void draw(SkCanvas* canvas, SkDrawPictureCallback* = NULL) const;
 
     /** Return the width of the picture's recording canvas. This
         value reflects what was passed to setSize(), and does not necessarily
@@ -286,7 +286,7 @@
     SkPicturePlayback*    fPlayback;
     SkPictureRecord*      fRecord;
     int                   fWidth, fHeight;
-    const AccelData*      fAccelData;
+    mutable const AccelData* fAccelData;
 
     void needsNewGenID() { fUniqueID = SK_InvalidGenID; }
 
@@ -397,7 +397,7 @@
     /** PRIVATE / EXPERIMENTAL -- do not call
         Return the operations required to render the content inside 'queryRect'.
     */
-    const OperationList& EXPERIMENTAL_getActiveOps(const SkIRect& queryRect);
+    const OperationList& EXPERIMENTAL_getActiveOps(const SkIRect& queryRect) const;
 
     /** PRIVATE / EXPERIMENTAL -- do not call
         Return the ID of the operation currently being executed when playing
diff --git a/include/gpu/SkGpuDevice.h b/include/gpu/SkGpuDevice.h
index f2a27d7..c9650d6 100644
--- a/include/gpu/SkGpuDevice.h
+++ b/include/gpu/SkGpuDevice.h
@@ -152,11 +152,11 @@
     virtual bool onWritePixels(const SkImageInfo&, const void*, size_t, int, int) SK_OVERRIDE;
 
     /**  PRIVATE / EXPERIMENTAL -- do not call */
-    virtual void EXPERIMENTAL_optimize(SkPicture* picture) SK_OVERRIDE;
+    virtual void EXPERIMENTAL_optimize(const SkPicture* picture) SK_OVERRIDE;
     /**  PRIVATE / EXPERIMENTAL -- do not call */
-    virtual void EXPERIMENTAL_purge(SkPicture* picture) SK_OVERRIDE;
+    virtual void EXPERIMENTAL_purge(const SkPicture* picture) SK_OVERRIDE;
     /**  PRIVATE / EXPERIMENTAL -- do not call */
-    virtual bool EXPERIMENTAL_drawPicture(SkCanvas* canvas, SkPicture* picture) SK_OVERRIDE;
+    virtual bool EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* picture) SK_OVERRIDE;
 
 private:
     GrContext*      fContext;
diff --git a/include/utils/SkDeferredCanvas.h b/include/utils/SkDeferredCanvas.h
index 9413512..31ebce4 100644
--- a/include/utils/SkDeferredCanvas.h
+++ b/include/utils/SkDeferredCanvas.h
@@ -162,7 +162,6 @@
                                 SK_OVERRIDE;
     virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
                             const SkPaint* paint) SK_OVERRIDE;
-    virtual void drawPicture(SkPicture& picture) SK_OVERRIDE;
     virtual void drawVertices(VertexMode vmode, int vertexCount,
                               const SkPoint vertices[], const SkPoint texs[],
                               const SkColor colors[], SkXfermode* xmode,
@@ -193,6 +192,8 @@
     virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
     virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE;
 
+    virtual void onDrawPicture(const SkPicture* picture) SK_OVERRIDE;
+
 public:
     class NotificationClient {
     public:
diff --git a/include/utils/SkDumpCanvas.h b/include/utils/SkDumpCanvas.h
index 6fc679b..0aa5546 100644
--- a/include/utils/SkDumpCanvas.h
+++ b/include/utils/SkDumpCanvas.h
@@ -90,7 +90,6 @@
                                   const SkPaint* paint) SK_OVERRIDE;
     virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
                             const SkPaint* paint) SK_OVERRIDE;
-    virtual void drawPicture(SkPicture&) SK_OVERRIDE;
     virtual void drawVertices(VertexMode vmode, int vertexCount,
                               const SkPoint vertices[], const SkPoint texs[],
                               const SkColor colors[], SkXfermode* xmode,
@@ -126,6 +125,8 @@
     virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
     virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE;
 
+    virtual void onDrawPicture(const SkPicture*) SK_OVERRIDE;
+
     static const char* EdgeStyleToAAString(ClipEdgeStyle edgeStyle);
 
 private:
diff --git a/include/utils/SkLuaCanvas.h b/include/utils/SkLuaCanvas.h
index 3efbdb9..6bef868 100644
--- a/include/utils/SkLuaCanvas.h
+++ b/include/utils/SkLuaCanvas.h
@@ -36,7 +36,6 @@
                                   const SkPaint* paint) SK_OVERRIDE;
     virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
                             const SkPaint* paint) SK_OVERRIDE;
-    virtual void drawPicture(SkPicture&) SK_OVERRIDE;
     virtual void drawVertices(VertexMode vmode, int vertexCount,
                               const SkPoint vertices[], const SkPoint texs[],
                               const SkColor colors[], SkXfermode* xmode,
@@ -67,6 +66,8 @@
     virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
     virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE;
 
+    virtual void onDrawPicture(const SkPicture*) SK_OVERRIDE;
+
 private:
     lua_State*  fL;
     SkString    fFunc;
diff --git a/include/utils/SkNWayCanvas.h b/include/utils/SkNWayCanvas.h
index e60dc4d..bd19355 100644
--- a/include/utils/SkNWayCanvas.h
+++ b/include/utils/SkNWayCanvas.h
@@ -43,7 +43,6 @@
                                 const SkPaint* paint = NULL) SK_OVERRIDE;
     virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
                             const SkPaint*) SK_OVERRIDE;
-    virtual void drawPicture(SkPicture&) SK_OVERRIDE;
     virtual void drawVertices(VertexMode vmode, int vertexCount,
                               const SkPoint vertices[], const SkPoint texs[],
                               const SkColor colors[], SkXfermode* xmode,
@@ -82,6 +81,8 @@
     virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
     virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE;
 
+    virtual void onDrawPicture(const SkPicture*) SK_OVERRIDE;
+
     class Iter;
 
 private:
diff --git a/include/utils/SkProxyCanvas.h b/include/utils/SkProxyCanvas.h
index a418ec0..09bf375 100644
--- a/include/utils/SkProxyCanvas.h
+++ b/include/utils/SkProxyCanvas.h
@@ -42,7 +42,6 @@
                                   const SkPaint* paint = NULL) SK_OVERRIDE;
     virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
                             const SkPaint* paint = NULL) SK_OVERRIDE;
-    virtual void drawPicture(SkPicture&) SK_OVERRIDE;
     virtual void drawVertices(VertexMode vmode, int vertexCount,
                               const SkPoint vertices[], const SkPoint texs[],
                               const SkColor colors[], SkXfermode* xmode,
@@ -79,6 +78,8 @@
     virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
     virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE;
 
+    virtual void onDrawPicture(const SkPicture*) SK_OVERRIDE;
+
 private:
     SkCanvas*   fProxy;
 
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 5e304d8..35021cb 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -1470,7 +1470,7 @@
         if (true) {
             SkPicture* pict = new SkPicture(*picture);
             this->installDrawFilter(orig);
-            orig->drawPicture(*pict);
+            orig->drawPicture(pict);
             pict->unref();
         } else if (true) {
             SkDynamicMemoryWStream ostream;
@@ -1480,7 +1480,7 @@
             SkMemoryStream istream(data->data(), data->size());
             SkAutoTUnref<SkPicture> pict(SkPicture::CreateFromStream(&istream));
             if (pict.get() != NULL) {
-                orig->drawPicture(*pict.get());
+                orig->drawPicture(pict.get());
             }
         } else {
             picture->draw(orig);
diff --git a/samplecode/SamplePictFile.cpp b/samplecode/SamplePictFile.cpp
index 7b9584d..9e9764c 100644
--- a/samplecode/SamplePictFile.cpp
+++ b/samplecode/SamplePictFile.cpp
@@ -100,7 +100,7 @@
             *picture = LoadPicture(fFilename.c_str(), fBBox);
         }
         if (*picture) {
-            canvas->drawPicture(**picture);
+            canvas->drawPicture(*picture);
         }
     }
 
@@ -140,7 +140,7 @@
 
             if (false) {
                 SkSurface* surf = SkSurface::NewRasterPMColor(pic->width(), pic->height());
-                surf->getCanvas()->drawPicture(*pic);
+                surf->getCanvas()->drawPicture(pic);
                 surf->unref();
             }
             if (false) { // re-record
diff --git a/samplecode/SamplePicture.cpp b/samplecode/SamplePicture.cpp
index f242c21..9c965e4 100644
--- a/samplecode/SamplePicture.cpp
+++ b/samplecode/SamplePicture.cpp
@@ -74,13 +74,13 @@
         canvas->drawBitmap(fBitmap, 0, 0, NULL);
 
         drawCircle(canvas, 50, SK_ColorBLACK);
-        canvas->drawPicture(*fSubPicture);
+        canvas->drawPicture(fSubPicture);
         canvas->translate(SkIntToScalar(50), 0);
-        canvas->drawPicture(*fSubPicture);
+        canvas->drawPicture(fSubPicture);
         canvas->translate(0, SkIntToScalar(50));
-        canvas->drawPicture(*fSubPicture);
+        canvas->drawPicture(fSubPicture);
         canvas->translate(SkIntToScalar(-50), 0);
-        canvas->drawPicture(*fSubPicture);
+        canvas->drawPicture(fSubPicture);
 
         fPicture = recorder.endRecording();
 
@@ -140,28 +140,28 @@
         canvas->translate(SkIntToScalar(300), SkIntToScalar(50));
         canvas->scale(-SK_Scalar1, -SK_Scalar1);
         canvas->translate(-SkIntToScalar(100), -SkIntToScalar(50));
-        canvas->drawPicture(*pict);
+        canvas->drawPicture(pict);
         canvas->restore();
 
         canvas->save();
         canvas->translate(SkIntToScalar(200), SkIntToScalar(150));
         canvas->scale(SK_Scalar1, -SK_Scalar1);
         canvas->translate(0, -SkIntToScalar(50));
-        canvas->drawPicture(*pict);
+        canvas->drawPicture(pict);
         canvas->restore();
 
         canvas->save();
         canvas->translate(SkIntToScalar(100), SkIntToScalar(100));
         canvas->scale(-SK_Scalar1, SK_Scalar1);
         canvas->translate(-SkIntToScalar(100), 0);
-        canvas->drawPicture(*pict);
+        canvas->drawPicture(pict);
         canvas->restore();
 
 #ifdef SK_DEVELOPER
         if (false) {
             SkDebugfDumper dumper;
             SkDumpCanvas dumpCanvas(&dumper);
-            dumpCanvas.drawPicture(*pict);
+            dumpCanvas.drawPicture(pict);
         }
 #endif
 
@@ -170,7 +170,7 @@
 
         SkRandom rand(SampleCode::GetAnimTime());
         canvas->translate(SkIntToScalar(10), SkIntToScalar(250));
-        canvas->drawPicture(*fPicture);
+        canvas->drawPicture(fPicture);
         delayInval(500);
     }
 
diff --git a/samplecode/SampleTiling.cpp b/samplecode/SampleTiling.cpp
index a59a802..6bb9c74 100644
--- a/samplecode/SampleTiling.cpp
+++ b/samplecode/SampleTiling.cpp
@@ -158,7 +158,7 @@
         }
 
         SkASSERT(NULL != fTextPicture);
-        canvas->drawPicture(*fTextPicture);
+        canvas->drawPicture(fTextPicture);
     }
 
 private:
diff --git a/src/core/SkBBoxRecord.cpp b/src/core/SkBBoxRecord.cpp
index b1c229e..a40ea8b 100644
--- a/src/core/SkBBoxRecord.cpp
+++ b/src/core/SkBBoxRecord.cpp
@@ -280,10 +280,10 @@
     }
 }
 
-void SkBBoxRecord::drawPicture(SkPicture& picture) {
-    if (picture.width() > 0 && picture.height() > 0 &&
-        this->transformBounds(SkRect::MakeWH(picture.width(), picture.height()), NULL)) {
-        INHERITED::drawPicture(picture);
+void SkBBoxRecord::onDrawPicture(const SkPicture* picture) {
+    if (picture->width() > 0 && picture->height() > 0 &&
+        this->transformBounds(SkRect::MakeWH(picture->width(), picture->height()), NULL)) {
+        this->INHERITED::onDrawPicture(picture);
     }
 }
 
diff --git a/src/core/SkBBoxRecord.h b/src/core/SkBBoxRecord.h
index f2e9d8d..123a91f 100644
--- a/src/core/SkBBoxRecord.h
+++ b/src/core/SkBBoxRecord.h
@@ -54,7 +54,6 @@
                               const SkColor colors[], SkXfermode* xfer,
                               const uint16_t indices[], int indexCount,
                               const SkPaint& paint) SK_OVERRIDE;
-    virtual void drawPicture(SkPicture& picture) SK_OVERRIDE;
 
 protected:
     virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE;
@@ -66,6 +65,7 @@
                                 SkScalar constY, const SkPaint&) SK_OVERRIDE;
     virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
                                   const SkMatrix* matrix, const SkPaint&) SK_OVERRIDE;
+    virtual void onDrawPicture(const SkPicture* picture) SK_OVERRIDE;
 
 private:
     /**
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 53dec2e..3134c46 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -2479,31 +2479,39 @@
 }
 
 ///////////////////////////////////////////////////////////////////////////////
-void SkCanvas::EXPERIMENTAL_optimize(SkPicture* picture) {
+void SkCanvas::EXPERIMENTAL_optimize(const SkPicture* picture) {
     SkBaseDevice* device = this->getDevice();
     if (NULL != device) {
         device->EXPERIMENTAL_optimize(picture);
     }
 }
 
-void SkCanvas::EXPERIMENTAL_purge(SkPicture* picture) {
+void SkCanvas::EXPERIMENTAL_purge(const SkPicture* picture) {
     SkBaseDevice* device = this->getTopDevice();
     if (NULL != device) {
         device->EXPERIMENTAL_purge(picture);
     }
 }
 
-void SkCanvas::drawPicture(SkPicture& picture) {
+void SkCanvas::drawPicture(const SkPicture* picture) {
+    if (NULL != picture) {
+        this->onDrawPicture(picture);
+    }
+}
+
+void SkCanvas::onDrawPicture(const SkPicture* picture) {
+    SkASSERT(NULL != picture);
+
     SkBaseDevice* device = this->getTopDevice();
     if (NULL != device) {
         // Canvas has to first give the device the opportunity to render
         // the picture itself.
-        if (device->EXPERIMENTAL_drawPicture(this, &picture)) {
+        if (device->EXPERIMENTAL_drawPicture(this, picture)) {
             return; // the device has rendered the entire picture
         }
     }
 
-    picture.draw(this);
+    picture->draw(this);
 }
 
 ///////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp
index 36a8a75..6c5c0f3 100644
--- a/src/core/SkDevice.cpp
+++ b/src/core/SkDevice.cpp
@@ -131,15 +131,15 @@
     return NULL;
 }
 
-void SkBaseDevice::EXPERIMENTAL_optimize(SkPicture* picture) {
+void SkBaseDevice::EXPERIMENTAL_optimize(const SkPicture* picture) {
     // The base class doesn't perform any analysis but derived classes may
 }
 
-void SkBaseDevice::EXPERIMENTAL_purge(SkPicture* picture) {
+void SkBaseDevice::EXPERIMENTAL_purge(const SkPicture* picture) {
     // Derived-classes may have data to purge but not the base class
 }
 
-bool SkBaseDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, SkPicture* picture) {
+bool SkBaseDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* picture) {
     // The base class doesn't perform any accelerated picture rendering
     return false;
 }
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp
index 00bcbef..98c0e00 100644
--- a/src/core/SkPicture.cpp
+++ b/src/core/SkPicture.cpp
@@ -366,7 +366,7 @@
     return gInvalid;
 }
 
-const SkPicture::OperationList& SkPicture::EXPERIMENTAL_getActiveOps(const SkIRect& queryRect) {
+const SkPicture::OperationList& SkPicture::EXPERIMENTAL_getActiveOps(const SkIRect& queryRect) const {
     SkASSERT(NULL != fPlayback && NULL == fRecord);
     if (NULL != fPlayback) {
         return fPlayback->getActiveOps(queryRect);
@@ -381,7 +381,7 @@
     return 0;
 }
 
-void SkPicture::draw(SkCanvas* surface, SkDrawPictureCallback* callback) {
+void SkPicture::draw(SkCanvas* surface, SkDrawPictureCallback* callback) const {
     SkASSERT(NULL != fPlayback && NULL == fRecord);
     if (NULL != fPlayback) {
         fPlayback->draw(*surface, callback);
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index 8c77eeb..63f2d7e 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -129,10 +129,10 @@
 
     picture->initForPlayback();
 
-    const SkTDArray<SkPicture* >& pictures = record.getPictureRefs();
+    const SkTDArray<const SkPicture* >& pictures = record.getPictureRefs();
     fPictureCount = pictures.count();
     if (fPictureCount > 0) {
-        fPictureRefs = SkNEW_ARRAY(SkPicture*, fPictureCount);
+        fPictureRefs = SkNEW_ARRAY(const SkPicture*, fPictureCount);
         for (int i = 0; i < fPictureCount; i++) {
             if (deepCopy) {
                 fPictureRefs[i] = pictures[i]->clone();
@@ -210,7 +210,7 @@
     }
 
     fPictureCount = src.fPictureCount;
-    fPictureRefs = SkNEW_ARRAY(SkPicture*, fPictureCount);
+    fPictureRefs = SkNEW_ARRAY(const SkPicture*, fPictureCount);
     for (int i = 0; i < fPictureCount; i++) {
         if (deepCopyInfo) {
             fPictureRefs[i] = src.fPictureRefs[i]->clone();
@@ -505,7 +505,7 @@
         } break;
         case SK_PICT_PICTURE_TAG: {
             fPictureCount = size;
-            fPictureRefs = SkNEW_ARRAY(SkPicture*, fPictureCount);
+            fPictureRefs = SkNEW_ARRAY(const SkPicture*, fPictureCount);
             bool success = true;
             int i = 0;
             for ( ; i < fPictureCount; i++) {
@@ -590,7 +590,7 @@
                 return false;
             }
             fPictureCount = size;
-            fPictureRefs = SkNEW_ARRAY(SkPicture*, fPictureCount);
+            fPictureRefs = SkNEW_ARRAY(const SkPicture*, fPictureCount);
             bool success = true;
             int i = 0;
             for ( ; i < fPictureCount; i++) {
diff --git a/src/core/SkPicturePlayback.h b/src/core/SkPicturePlayback.h
index d6f0cf1..ea36ca9 100644
--- a/src/core/SkPicturePlayback.h
+++ b/src/core/SkPicturePlayback.h
@@ -150,10 +150,10 @@
         return fPicture->getPath(reader.readInt() - 1);
     }
 
-    SkPicture& getPicture(SkReader32& reader) {
+    const SkPicture* getPicture(SkReader32& reader) {
         int index = reader.readInt();
         SkASSERT(index > 0 && index <= fPictureCount);
-        return *fPictureRefs[index - 1];
+        return fPictureRefs[index - 1];
     }
 
     const SkPaint* getPaint(SkReader32& reader) {
@@ -246,7 +246,7 @@
 
     SkData* fOpData;    // opcodes and parameters
 
-    SkPicture** fPictureRefs;
+    const SkPicture** fPictureRefs;
     int fPictureCount;
 
     SkBBoxHierarchy* fBoundingHierarchy;
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp
index 36b0763..0c59b13 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -1411,7 +1411,7 @@
     this->validate(initialOffset, size);
 }
 
-void SkPictureRecord::drawPicture(SkPicture& picture) {
+void SkPictureRecord::onDrawPicture(const SkPicture* picture) {
 
 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
     fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
@@ -1618,12 +1618,12 @@
     this->addInt(this->addPathToHeap(path));
 }
 
-void SkPictureRecord::addPicture(SkPicture& picture) {
-    int index = fPictureRefs.find(&picture);
+void SkPictureRecord::addPicture(const SkPicture* picture) {
+    int index = fPictureRefs.find(picture);
     if (index < 0) {    // not found
         index = fPictureRefs.count();
-        *fPictureRefs.append() = &picture;
-        picture.ref();
+        *fPictureRefs.append() = picture;
+        picture->ref();
     }
     // follow the convention of recording a 1-based index
     this->addInt(index + 1);
diff --git a/src/core/SkPictureRecord.h b/src/core/SkPictureRecord.h
index 22d2546..d6cdf05 100644
--- a/src/core/SkPictureRecord.h
+++ b/src/core/SkPictureRecord.h
@@ -55,7 +55,6 @@
                                 const SkRect& dst, const SkPaint*) SK_OVERRIDE;
     virtual void drawSprite(const SkBitmap&, int left, int top,
                             const SkPaint*) SK_OVERRIDE;
-    virtual void drawPicture(SkPicture& picture) SK_OVERRIDE;
     virtual void drawVertices(VertexMode, int vertexCount,
                           const SkPoint vertices[], const SkPoint texs[],
                           const SkColor colors[], SkXfermode*,
@@ -70,7 +69,7 @@
     void addFontMetricsTopBottom(const SkPaint& paint, const SkFlatData&,
                                  SkScalar minY, SkScalar maxY);
 
-    const SkTDArray<SkPicture* >& getPictureRefs() const {
+    const SkTDArray<const SkPicture* >& getPictureRefs() const {
         return fPictureRefs;
     }
 
@@ -156,7 +155,7 @@
     const SkFlatData* addPaintPtr(const SkPaint* paint);
     void addFlatPaint(const SkFlatData* flatPaint);
     void addPath(const SkPath& path);
-    void addPicture(SkPicture& picture);
+    void addPicture(const SkPicture* picture);
     void addPoint(const SkPoint& point);
     void addPoints(const SkPoint pts[], int count);
     void addRect(const SkRect& rect);
@@ -236,6 +235,8 @@
     virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
     virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE;
 
+    virtual void onDrawPicture(const SkPicture* picture) SK_OVERRIDE;
+
     // Return fontmetrics.fTop,fBottom in topbot[0,1], after they have been
     // tweaked by paint.computeFastBounds().
     static void ComputeFontMetricsTopBottom(const SkPaint& paint, SkScalar topbot[2]);
@@ -295,7 +296,7 @@
     SkWriter32 fWriter;
 
     // we ref each item in these arrays
-    SkTDArray<SkPicture*> fPictureRefs;
+    SkTDArray<const SkPicture*> fPictureRefs;
 
     uint32_t fRecordFlags;
     bool     fOptsEnabled;
diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp
index ecb86e7..81e1375 100644
--- a/src/core/SkPictureShader.cpp
+++ b/src/core/SkPictureShader.cpp
@@ -92,7 +92,7 @@
 
         SkCanvas canvas(bm);
         canvas.scale(tileScale.width(), tileScale.height());
-        canvas.drawPicture(*fPicture);
+        canvas.drawPicture(fPicture);
 
         fCachedTileScale = tileScale;
         fCachedLocalMatrix = this->getLocalMatrix();
diff --git a/src/effects/SkPictureImageFilter.cpp b/src/effects/SkPictureImageFilter.cpp
index af9466f..2d2df92 100644
--- a/src/effects/SkPictureImageFilter.cpp
+++ b/src/effects/SkPictureImageFilter.cpp
@@ -85,7 +85,7 @@
 
     canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop));
     canvas.concat(ctx.ctm());
-    canvas.drawPicture(*fPicture);
+    canvas.drawPicture(fPicture);
 
     *result = device.get()->accessBitmap(false);
     offset->fX = bounds.fLeft;
diff --git a/src/gpu/GrLayerCache.cpp b/src/gpu/GrLayerCache.cpp
index 0621aac..f6377bf 100644
--- a/src/gpu/GrLayerCache.cpp
+++ b/src/gpu/GrLayerCache.cpp
@@ -66,7 +66,7 @@
     fAtlasMgr.free();
 }
 
-GrCachedLayer* GrLayerCache::createLayer(SkPicture* picture, int layerID) {
+GrCachedLayer* GrLayerCache::createLayer(const SkPicture* picture, int layerID) {
     GrCachedLayer* layer = fLayerPool.alloc();
 
     SkASSERT(picture->uniqueID() != SK_InvalidGenID);
@@ -76,7 +76,7 @@
 }
 
 
-GrCachedLayer* GrLayerCache::findLayerOrCreate(SkPicture* picture, int layerID) {
+GrCachedLayer* GrLayerCache::findLayerOrCreate(const SkPicture* picture, int layerID) {
     SkASSERT(picture->uniqueID() != SK_InvalidGenID);
     GrCachedLayer* layer = fLayerHash.find(PictureLayerKey(picture->uniqueID(), layerID));
     if (NULL == layer) {
diff --git a/src/gpu/GrLayerCache.h b/src/gpu/GrLayerCache.h
index 414b87d..a957e78 100644
--- a/src/gpu/GrLayerCache.h
+++ b/src/gpu/GrLayerCache.h
@@ -102,7 +102,7 @@
 
     void freeAll();
 
-    GrCachedLayer* findLayerOrCreate(SkPicture* picture, int id);
+    GrCachedLayer* findLayerOrCreate(const SkPicture* picture, int id);
 
 private:
     SkAutoTUnref<GrGpu>       fGpu;
@@ -113,7 +113,7 @@
     GrTAllocPool<GrCachedLayer> fLayerPool;
 
     void init();
-    GrCachedLayer* createLayer(SkPicture* picture, int id);
+    GrCachedLayer* createLayer(const SkPicture* picture, int id);
 
 };
 
diff --git a/src/gpu/GrPictureUtils.cpp b/src/gpu/GrPictureUtils.cpp
index f8c2d31..5166bb1 100644
--- a/src/gpu/GrPictureUtils.cpp
+++ b/src/gpu/GrPictureUtils.cpp
@@ -29,7 +29,7 @@
 public:
     SK_DECLARE_INST_COUNT(GrGatherDevice)
 
-    GrGatherDevice(int width, int height, SkPicture* picture, GPUAccelData* accelData,
+    GrGatherDevice(int width, int height, const SkPicture* picture, GPUAccelData* accelData,
                    int saveLayerDepth) {
         fPicture = picture;
         fSaveLayerDepth = saveLayerDepth;
@@ -172,7 +172,7 @@
 
 private:
     // The picture being processed
-    SkPicture *fPicture;
+    const SkPicture *fPicture;
 
     SkBitmap fEmptyBitmap; // legacy -- need to remove
 
@@ -223,7 +223,7 @@
 // which is all just to fill in 'accelData'
 class SK_API GrGatherCanvas : public SkCanvas {
 public:
-    GrGatherCanvas(GrGatherDevice* device, SkPicture* pict)
+    GrGatherCanvas(GrGatherDevice* device, const SkPicture* pict)
         : INHERITED(device)
         , fPicture(pict) {
     }
@@ -236,20 +236,9 @@
         this->clipRect(SkRect::MakeWH(SkIntToScalar(fPicture->width()),
                                       SkIntToScalar(fPicture->height())),
                        SkRegion::kIntersect_Op, false);
-        this->drawPicture(*fPicture);
+        this->drawPicture(fPicture);
     }
 
-    virtual void drawPicture(SkPicture& picture) SK_OVERRIDE {
-        // BBH-based rendering doesn't re-issue many of the operations the gather
-        // process cares about (e.g., saves and restores) so it must be disabled.
-        if (NULL != picture.fPlayback) {
-            picture.fPlayback->setUseBBH(false);
-        }
-        picture.draw(this);
-        if (NULL != picture.fPlayback) {
-            picture.fPlayback->setUseBBH(true);
-        }
-    }
 protected:
     // disable aa for speed
     virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle) SK_OVERRIDE {
@@ -266,15 +255,27 @@
         this->updateClipConservativelyUsingBounds(rrect.getBounds(), op, false);
     }
 
+    virtual void onDrawPicture(const SkPicture* picture) SK_OVERRIDE {
+        // BBH-based rendering doesn't re-issue many of the operations the gather
+        // process cares about (e.g., saves and restores) so it must be disabled.
+        if (NULL != picture->fPlayback) {
+            picture->fPlayback->setUseBBH(false);
+        }
+        picture->draw(this);
+        if (NULL != picture->fPlayback) {
+            picture->fPlayback->setUseBBH(true);
+        }
+    }
+
 private:
-    SkPicture* fPicture;
+    const SkPicture* fPicture;
 
     typedef SkCanvas INHERITED;
 };
 
 // GatherGPUInfo is only intended to be called within the context of SkGpuDevice's
 // EXPERIMENTAL_optimize method.
-void GatherGPUInfo(SkPicture* pict, GPUAccelData* accelData) {
+void GatherGPUInfo(const SkPicture* pict, GPUAccelData* accelData) {
     if (0 == pict->width() || 0 == pict->height()) {
         return ;
     }
diff --git a/src/gpu/GrPictureUtils.h b/src/gpu/GrPictureUtils.h
index a280a16..a730697 100644
--- a/src/gpu/GrPictureUtils.h
+++ b/src/gpu/GrPictureUtils.h
@@ -74,6 +74,6 @@
     typedef SkPicture::AccelData INHERITED;
 };
 
-void GatherGPUInfo(SkPicture* pict, GPUAccelData* accelData);
+void GatherGPUInfo(const SkPicture* pict, GPUAccelData* accelData);
 
 #endif // GrPictureUtils_DEFINED
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index b05cd33..7514359 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1816,7 +1816,7 @@
     return SkSurface::NewRenderTarget(fContext, info, fRenderTarget->numSamples());
 }
 
-void SkGpuDevice::EXPERIMENTAL_optimize(SkPicture* picture) {
+void SkGpuDevice::EXPERIMENTAL_optimize(const SkPicture* picture) {
     SkPicture::AccelData::Key key = GPUAccelData::ComputeAccelDataKey();
 
     const SkPicture::AccelData* existing = picture->EXPERIMENTAL_getAccelData(key);
@@ -1837,11 +1837,11 @@
     result->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref();
 }
 
-void SkGpuDevice::EXPERIMENTAL_purge(SkPicture* picture) {
+void SkGpuDevice::EXPERIMENTAL_purge(const SkPicture* picture) {
 
 }
 
-bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, SkPicture* picture) {
+bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* picture) {
 
     SkPicture::AccelData::Key key = GPUAccelData::ComputeAccelDataKey();
 
diff --git a/src/pipe/SkGPipeWrite.cpp b/src/pipe/SkGPipeWrite.cpp
index 4a5dcd5..a3c3864 100644
--- a/src/pipe/SkGPipeWrite.cpp
+++ b/src/pipe/SkGPipeWrite.cpp
@@ -249,7 +249,6 @@
                                 const SkRect& dst, const SkPaint* paint = NULL) SK_OVERRIDE;
     virtual void drawSprite(const SkBitmap&, int left, int top,
                             const SkPaint*) SK_OVERRIDE;
-    virtual void drawPicture(SkPicture& picture) SK_OVERRIDE;
     virtual void drawVertices(VertexMode, int vertexCount,
                           const SkPoint vertices[], const SkPoint texs[],
                           const SkColor colors[], SkXfermode*,
@@ -289,6 +288,8 @@
     virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
     virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE;
 
+    virtual void onDrawPicture(const SkPicture* picture) SK_OVERRIDE;
+
 private:
     void recordTranslate(const SkMatrix&);
     void recordScale(const SkMatrix&);
@@ -929,9 +930,9 @@
     }
 }
 
-void SkGPipeCanvas::drawPicture(SkPicture& picture) {
+void SkGPipeCanvas::onDrawPicture(const SkPicture* picture) {
     // we want to playback the picture into individual draw calls
-    this->INHERITED::drawPicture(picture);
+    this->INHERITED::onDrawPicture(picture);
 }
 
 void SkGPipeCanvas::drawVertices(VertexMode vmode, int vertexCount,
diff --git a/src/record/SkRecorder.cpp b/src/record/SkRecorder.cpp
index 74101c1..8581257 100644
--- a/src/record/SkRecorder.cpp
+++ b/src/record/SkRecorder.cpp
@@ -186,8 +186,8 @@
            this->copy(matrix));
 }
 
-void SkRecorder::drawPicture(SkPicture& picture) {
-    picture.draw(this);
+void SkRecorder::onDrawPicture(const SkPicture* picture) {
+    picture->draw(this);
 }
 
 void SkRecorder::drawVertices(VertexMode vmode,
diff --git a/src/record/SkRecorder.h b/src/record/SkRecorder.h
index cee25c1..3e2932d 100644
--- a/src/record/SkRecorder.h
+++ b/src/record/SkRecorder.h
@@ -52,7 +52,6 @@
                     int left,
                     int top,
                     const SkPaint* paint = NULL) SK_OVERRIDE;
-    void drawPicture(SkPicture& picture) SK_OVERRIDE;
     void drawVertices(VertexMode vmode,
                       int vertexCount,
                       const SkPoint vertices[],
@@ -95,6 +94,8 @@
     void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) SK_OVERRIDE;
     void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) SK_OVERRIDE;
 
+    void onDrawPicture(const SkPicture* picture) SK_OVERRIDE;
+
     void onPushCull(const SkRect& cullRect) SK_OVERRIDE;
     void onPopCull() SK_OVERRIDE;
 
diff --git a/src/utils/SkDeferredCanvas.cpp b/src/utils/SkDeferredCanvas.cpp
index 02c2c5a..e244505 100644
--- a/src/utils/SkDeferredCanvas.cpp
+++ b/src/utils/SkDeferredCanvas.cpp
@@ -936,7 +936,7 @@
     this->recordedDrawCommand();
 }
 
-void SkDeferredCanvas::drawPicture(SkPicture& picture) {
+void SkDeferredCanvas::onDrawPicture(const SkPicture* picture) {
     this->drawingCanvas()->drawPicture(picture);
     this->recordedDrawCommand();
 }
diff --git a/src/utils/SkDumpCanvas.cpp b/src/utils/SkDumpCanvas.cpp
index 9814fb5..4dfed39 100644
--- a/src/utils/SkDumpCanvas.cpp
+++ b/src/utils/SkDumpCanvas.cpp
@@ -422,14 +422,14 @@
                str.c_str(), byteLength);
 }
 
-void SkDumpCanvas::drawPicture(SkPicture& picture) {
-    this->dump(kDrawPicture_Verb, NULL, "drawPicture(%p) %d:%d", &picture,
-               picture.width(), picture.height());
+void SkDumpCanvas::onDrawPicture(const SkPicture* picture) {
+    this->dump(kDrawPicture_Verb, NULL, "drawPicture(%p) %d:%d", picture,
+               picture->width(), picture->height());
     fNestLevel += 1;
-    this->INHERITED::drawPicture(picture);
+    this->INHERITED::onDrawPicture(picture);
     fNestLevel -= 1;
     this->dump(kDrawPicture_Verb, NULL, "endPicture(%p) %d:%d", &picture,
-               picture.width(), picture.height());
+               picture->width(), picture->height());
 }
 
 void SkDumpCanvas::drawVertices(VertexMode vmode, int vertexCount,
diff --git a/src/utils/SkGatherPixelRefsAndRects.cpp b/src/utils/SkGatherPixelRefsAndRects.cpp
index 320d996..f46fe8e 100644
--- a/src/utils/SkGatherPixelRefsAndRects.cpp
+++ b/src/utils/SkGatherPixelRefsAndRects.cpp
@@ -21,5 +21,5 @@
     canvas.clipRect(SkRect::MakeWH(SkIntToScalar(pict->width()),
                                    SkIntToScalar(pict->height())),
                     SkRegion::kIntersect_Op, false);
-    canvas.drawPicture(*pict);
+    canvas.drawPicture(pict);
 }
diff --git a/src/utils/SkLuaCanvas.cpp b/src/utils/SkLuaCanvas.cpp
index b4c7c77..d9c5dc1 100644
--- a/src/utils/SkLuaCanvas.cpp
+++ b/src/utils/SkLuaCanvas.cpp
@@ -268,10 +268,10 @@
     lua.pushPaint(paint, "paint");
 }
 
-void SkLuaCanvas::drawPicture(SkPicture& picture) {
+void SkLuaCanvas::onDrawPicture(const SkPicture* picture) {
     AUTO_LUA("drawPicture");
     // call through so we can see the nested picture ops
-    this->INHERITED::drawPicture(picture);
+    this->INHERITED::onDrawPicture(picture);
 }
 
 void SkLuaCanvas::drawVertices(VertexMode vmode, int vertexCount,
diff --git a/src/utils/SkNWayCanvas.cpp b/src/utils/SkNWayCanvas.cpp
index 3c98e4b..505c05c 100644
--- a/src/utils/SkNWayCanvas.cpp
+++ b/src/utils/SkNWayCanvas.cpp
@@ -265,7 +265,7 @@
     }
 }
 
-void SkNWayCanvas::drawPicture(SkPicture& picture) {
+void SkNWayCanvas::onDrawPicture(const SkPicture* picture) {
     Iter iter(fList);
     while (iter.next()) {
         iter->drawPicture(picture);
diff --git a/src/utils/SkPictureUtils.cpp b/src/utils/SkPictureUtils.cpp
index a2d6da1..02fa6b1 100644
--- a/src/utils/SkPictureUtils.cpp
+++ b/src/utils/SkPictureUtils.cpp
@@ -214,7 +214,7 @@
     SkNoSaveLayerCanvas canvas(&device);
 
     canvas.clipRect(area, SkRegion::kIntersect_Op, false);
-    canvas.drawPicture(*pict);
+    canvas.drawPicture(pict);
 
     SkData* data = NULL;
     int count = array.count();
diff --git a/src/utils/SkProxyCanvas.cpp b/src/utils/SkProxyCanvas.cpp
index 20f9307..5cb5469 100644
--- a/src/utils/SkProxyCanvas.cpp
+++ b/src/utils/SkProxyCanvas.cpp
@@ -136,7 +136,7 @@
     fProxy->drawTextOnPath(text, byteLength, path, matrix, paint);
 }
 
-void SkProxyCanvas::drawPicture(SkPicture& picture) {
+void SkProxyCanvas::onDrawPicture(const SkPicture* picture) {
     fProxy->drawPicture(picture);
 }
 
diff --git a/src/utils/debugger/SkDebugCanvas.cpp b/src/utils/debugger/SkDebugCanvas.cpp
index 89a388e..8f6dc1b 100644
--- a/src/utils/debugger/SkDebugCanvas.cpp
+++ b/src/utils/debugger/SkDebugCanvas.cpp
@@ -519,7 +519,7 @@
     this->addDrawCommand(new SkDrawPathCommand(path, paint));
 }
 
-void SkDebugCanvas::drawPicture(SkPicture& picture) {
+void SkDebugCanvas::onDrawPicture(const SkPicture* picture) {
     this->addDrawCommand(new SkDrawPictureCommand(picture));
 }
 
diff --git a/src/utils/debugger/SkDebugCanvas.h b/src/utils/debugger/SkDebugCanvas.h
index e94f30f..f15b397 100644
--- a/src/utils/debugger/SkDebugCanvas.h
+++ b/src/utils/debugger/SkDebugCanvas.h
@@ -189,8 +189,6 @@
 
     virtual void drawPath(const SkPath& path, const SkPaint&) SK_OVERRIDE;
 
-    virtual void drawPicture(SkPicture& picture) SK_OVERRIDE;
-
     virtual void drawPoints(PointMode, size_t count, const SkPoint pts[],
                             const SkPaint&) SK_OVERRIDE;
 
@@ -257,6 +255,8 @@
     virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
     virtual void onClipRegion(const SkRegion& region, SkRegion::Op) SK_OVERRIDE;
 
+    virtual void onDrawPicture(const SkPicture* picture) SK_OVERRIDE;
+
     void markActiveCommands(int index);
 
 private:
diff --git a/src/utils/debugger/SkDrawCommand.cpp b/src/utils/debugger/SkDrawCommand.cpp
index 079961a..7c73cec 100644
--- a/src/utils/debugger/SkDrawCommand.cpp
+++ b/src/utils/debugger/SkDrawCommand.cpp
@@ -502,11 +502,11 @@
     return true;
 }
 
-SkDrawPictureCommand::SkDrawPictureCommand(SkPicture& picture)
+SkDrawPictureCommand::SkDrawPictureCommand(const SkPicture* picture)
     : INHERITED(DRAW_PICTURE)
-    , fPicture(picture) {
+    , fPicture(SkRef(picture)) {
     SkString* temp = new SkString;
-    temp->appendf("SkPicture: W: %d H: %d", picture.width(), picture.height());
+    temp->appendf("SkPicture: W: %d H: %d", picture->width(), picture->height());
     fInfo.push(temp);
 }
 
@@ -518,11 +518,11 @@
     canvas->clear(0xFFFFFFFF);
     canvas->save();
 
-    SkRect bounds = SkRect::MakeWH(SkIntToScalar(fPicture.width()),
-                                   SkIntToScalar(fPicture.height()));
+    SkRect bounds = SkRect::MakeWH(SkIntToScalar(fPicture->width()),
+                                   SkIntToScalar(fPicture->height()));
     xlate_and_scale_to_bounds(canvas, bounds);
 
-    canvas->drawPicture(const_cast<SkPicture&>(fPicture));
+    canvas->drawPicture(fPicture.get());
 
     canvas->restore();
 
diff --git a/src/utils/debugger/SkDrawCommand.h b/src/utils/debugger/SkDrawCommand.h
index f2e151a..a0bfb2d 100644
--- a/src/utils/debugger/SkDrawCommand.h
+++ b/src/utils/debugger/SkDrawCommand.h
@@ -343,12 +343,12 @@
 
 class SkDrawPictureCommand : public SkDrawCommand {
 public:
-    SkDrawPictureCommand(SkPicture& picture);
+    SkDrawPictureCommand(const SkPicture* picture);
     virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
     virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
 
 private:
-    SkPicture fPicture;
+    SkAutoTUnref<const SkPicture> fPicture;
 
     typedef SkDrawCommand INHERITED;
 };
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index 597b578..e2ad2ed 100644
--- a/tests/CanvasTest.cpp
+++ b/tests/CanvasTest.cpp
@@ -503,7 +503,7 @@
     testCanvas->drawRect(kTestRect, kTestPaint);
     SkAutoTUnref<SkPicture> testPicture(recorder.endRecording());
 
-    canvas->drawPicture(*testPicture);
+    canvas->drawPicture(testPicture);
 }
 TEST_STEP(DrawPicture, DrawPictureTestStep);
 
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index 0c4d076..cd6d235 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -491,7 +491,7 @@
     recordingCanvas->restore(); // saveLayer
     SkAutoTUnref<SkPicture> picture(recorder.endRecording());
 
-    canvas.drawPicture(*picture);
+    canvas.drawPicture(picture);
 }
 
 DEF_TEST(ImageFilterPictureImageFilterTest, reporter) {
@@ -529,7 +529,7 @@
 
     // The result here should be green, since the filter replaces the primitive's red interior.
     canvas.clear(0x0);
-    canvas.drawPicture(*outerPicture);
+    canvas.drawPicture(outerPicture);
     uint32_t pixel = *bitmap.getAddr32(0, 0);
     REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN);
 
@@ -548,7 +548,7 @@
     SkAutoTUnref<SkPicture> crossProcessPicture(crossProcessRecorder.endRecording());
 
     canvas.clear(0x0);
-    canvas.drawPicture(*crossProcessPicture);
+    canvas.drawPicture(crossProcessPicture);
     pixel = *bitmap.getAddr32(0, 0);
     // The result here should not be green, since the filter draws nothing.
     REPORTER_ASSERT(reporter, pixel != SK_ColorGREEN);
@@ -584,7 +584,7 @@
     SkAutoTUnref<SkPicture> picture(recorder.endRecording());
 
     canvas.clear(0);
-    canvas.drawPicture(*picture);
+    canvas.drawPicture(picture);
     uint32_t pixel = *bitmap.getAddr32(0, 0);
     REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN);
 
@@ -594,7 +594,7 @@
     SkAutoTUnref<SkPicture> picture2(recorder.endRecording());
 
     canvas.clear(0);
-    canvas.drawPicture(*picture2);
+    canvas.drawPicture(picture2);
     pixel = *bitmap.getAddr32(0, 0);
     REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN);
 
@@ -604,7 +604,7 @@
     SkAutoTUnref<SkPicture> picture3(recorder.endRecording());
 
     canvas.clear(0);
-    canvas.drawPicture(*picture3);
+    canvas.drawPicture(picture3);
     pixel = *bitmap.getAddr32(0, 0);
     REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN);
 }
diff --git a/tests/PictureStateTreeTest.cpp b/tests/PictureStateTreeTest.cpp
index e6cf553..cb154de 100644
--- a/tests/PictureStateTreeTest.cpp
+++ b/tests/PictureStateTreeTest.cpp
@@ -84,9 +84,9 @@
     SkCanvas bbhCanvas(bbhBitmap);
 
     referenceCanvas.drawColor(SK_ColorTRANSPARENT);
-    referenceCanvas.drawPicture(*referencePicture.get());
+    referenceCanvas.drawPicture(referencePicture.get());
     bbhCanvas.drawColor(SK_ColorTRANSPARENT);
-    bbhCanvas.drawPicture(*bbhPicture.get());
+    bbhCanvas.drawPicture(bbhPicture.get());
     REPORTER_ASSERT(reporter,
                     referenceCanvas.getSaveCount() == bbhCanvas.getSaveCount());
     REPORTER_ASSERT(reporter,
@@ -95,10 +95,10 @@
 
     referenceCanvas.drawColor(SK_ColorTRANSPARENT);
     referenceCanvas.clipRect(SkRect::MakeWH(50, 50));
-    referenceCanvas.drawPicture(*referencePicture.get());
+    referenceCanvas.drawPicture(referencePicture.get());
     bbhCanvas.drawColor(SK_ColorTRANSPARENT);
     bbhCanvas.clipRect(SkRect::MakeWH(50, 50));
-    bbhCanvas.drawPicture(*bbhPicture.get());
+    bbhCanvas.drawPicture(bbhPicture.get());
     REPORTER_ASSERT(reporter,
                     referenceCanvas.getSaveCount() == bbhCanvas.getSaveCount());
     REPORTER_ASSERT(reporter,
@@ -107,10 +107,10 @@
 
     referenceCanvas.drawColor(SK_ColorTRANSPARENT);
     referenceCanvas.clipRect(SkRect::MakeWH(10, 10));
-    referenceCanvas.drawPicture(*referencePicture.get());
+    referenceCanvas.drawPicture(referencePicture.get());
     bbhCanvas.drawColor(SK_ColorTRANSPARENT);
     bbhCanvas.clipRect(SkRect::MakeWH(10, 10));
-    bbhCanvas.drawPicture(*bbhPicture.get());
+    bbhCanvas.drawPicture(bbhPicture.get());
     REPORTER_ASSERT(reporter,
                     referenceCanvas.getSaveCount() == bbhCanvas.getSaveCount());
     REPORTER_ASSERT(reporter,
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index 494b4ed..f65c840 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -346,7 +346,7 @@
     make_bm(result, width, height, SK_ColorBLACK, false);
 
     SkCanvas canvas(*result);
-    canvas.drawPicture(*pic);
+    canvas.drawPicture(pic);
 }
 
 template <typename T> int find_index(const T* array, T elem, int count) {
@@ -1066,7 +1066,7 @@
         canvas->drawRect(rect, paint);
         SkAutoTUnref<SkPicture> extraSavePicture(recorder.endRecording());
 
-        testCanvas.drawPicture(*extraSavePicture);
+        testCanvas.drawPicture(extraSavePicture);
         REPORTER_ASSERT(reporter, 4 == testCanvas.getSaveCount());
     }
 
@@ -1087,7 +1087,7 @@
         canvas->restore();
         SkAutoTUnref<SkPicture> extraRestorePicture(recorder.endRecording());
 
-        testCanvas.drawPicture(*extraRestorePicture);
+        testCanvas.drawPicture(extraRestorePicture);
         REPORTER_ASSERT(reporter, 4 == testCanvas.getSaveCount());
     }
 
@@ -1099,7 +1099,7 @@
         canvas->drawRect(rect, paint);
         SkAutoTUnref<SkPicture> noSavePicture(recorder.endRecording());
 
-        testCanvas.drawPicture(*noSavePicture);
+        testCanvas.drawPicture(noSavePicture);
         REPORTER_ASSERT(reporter, 4 == testCanvas.getSaveCount());
         REPORTER_ASSERT(reporter, testCanvas.getTotalMatrix().isIdentity());
     }
@@ -1152,7 +1152,7 @@
     SkAutoTUnref<SkPicture> picture(recorder.endRecording());
 
     SkCanvas canvas;
-    canvas.drawPicture(*picture);
+    canvas.drawPicture(picture);
 }
 #endif
 
@@ -1247,7 +1247,7 @@
         recorder.beginRecording(1, 1, NULL, 0);
         SkAutoTUnref<SkPicture> picture(recorder.endRecording());
 
-        canvas.drawPicture(*picture);
+        canvas.drawPicture(picture);
     }
 
     {
@@ -1262,7 +1262,7 @@
         recorder.beginRecording(1, 1, &factory, 0);
         SkAutoTUnref<SkPicture> picture(recorder.endRecording());
 
-        canvas.drawPicture(*picture);
+        canvas.drawPicture(picture);
     }
 
     {
@@ -1272,7 +1272,7 @@
         recorder.beginRecording(1, 1, &factory, 0);
         SkAutoTUnref<SkPicture> picture(recorder.endRecording());
 
-        canvas.drawPicture(*picture);
+        canvas.drawPicture(picture);
     }
 
     {
@@ -1282,7 +1282,7 @@
         recorder.beginRecording(1, 1, &factory, 0);
         SkAutoTUnref<SkPicture> picture(recorder.endRecording());
 
-        canvas.drawPicture(*picture);
+        canvas.drawPicture(picture);
     }
 }
 
@@ -1460,27 +1460,27 @@
 
     {
         SkCanvas* canvas = recorder.beginRecording(10, 10, NULL, 0);
-        canvas->drawPicture(*childPlain);
+        canvas->drawPicture(childPlain);
         SkAutoTUnref<SkPicture> parentPP(recorder.endRecording());
         REPORTER_ASSERT(reporter, !parentPP->willPlayBackBitmaps()); // 0
     }
     {
         SkCanvas* canvas = recorder.beginRecording(10, 10, NULL, 0);
-        canvas->drawPicture(*childWithBitmap);
+        canvas->drawPicture(childWithBitmap);
         SkAutoTUnref<SkPicture> parentPWB(recorder.endRecording());
         REPORTER_ASSERT(reporter, parentPWB->willPlayBackBitmaps()); // 1
     }
     {
         SkCanvas* canvas = recorder.beginRecording(10, 10, NULL, 0);
         canvas->drawBitmap(bm, 0, 0);
-        canvas->drawPicture(*childPlain);
+        canvas->drawPicture(childPlain);
         SkAutoTUnref<SkPicture> parentWBP(recorder.endRecording());
         REPORTER_ASSERT(reporter, parentWBP->willPlayBackBitmaps()); // 1
     }
     {
         SkCanvas* canvas = recorder.beginRecording(10, 10, NULL, 0);
         canvas->drawBitmap(bm, 0, 0);
-        canvas->drawPicture(*childWithBitmap);
+        canvas->drawPicture(childWithBitmap);
         SkAutoTUnref<SkPicture> parentWBWB(recorder.endRecording());
         REPORTER_ASSERT(reporter, parentWBWB->willPlayBackBitmaps()); // 2
     }
diff --git a/tools/CopyTilesRenderer.cpp b/tools/CopyTilesRenderer.cpp
index 8022092..2456855 100644
--- a/tools/CopyTilesRenderer.cpp
+++ b/tools/CopyTilesRenderer.cpp
@@ -55,7 +55,7 @@
                 mat.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
                 fCanvas->setMatrix(mat);
                 // Draw the picture
-                fCanvas->drawPicture(*fPicture);
+                fCanvas->drawPicture(fPicture);
                 // Now extract the picture into tiles
                 const SkBitmap& baseBitmap = fCanvas->getDevice()->accessBitmap(false);
                 SkIRect subset;
diff --git a/tools/PdfRenderer.cpp b/tools/PdfRenderer.cpp
index 890abde..bcecf57 100644
--- a/tools/PdfRenderer.cpp
+++ b/tools/PdfRenderer.cpp
@@ -51,7 +51,7 @@
         return false;
     }
 
-    fCanvas->drawPicture(*fPicture);
+    fCanvas->drawPicture(fPicture);
     fCanvas->flush();
 
     return fPdfDoc->close();
diff --git a/tools/PictureRenderer.cpp b/tools/PictureRenderer.cpp
index 5128782..0343460 100644
--- a/tools/PictureRenderer.cpp
+++ b/tools/PictureRenderer.cpp
@@ -390,7 +390,7 @@
     PipeController pipeController(fCanvas.get());
     SkGPipeWriter writer;
     SkCanvas* pipeCanvas = writer.startRecording(&pipeController);
-    pipeCanvas->drawPicture(*fPicture);
+    pipeCanvas->drawPicture(fPicture);
     writer.endRecording();
     fCanvas->flush();
     if (NULL != out) {
@@ -426,7 +426,7 @@
         return false;
     }
 
-    fCanvas->drawPicture(*fPicture);
+    fCanvas->drawPicture(fPicture);
     fCanvas->flush();
     if (NULL != out) {
         *out = SkNEW(SkBitmap);
@@ -592,7 +592,7 @@
     SkMatrix mat(canvas->getTotalMatrix());
     mat.postTranslate(-tileRect.fLeft, -tileRect.fTop);
     canvas->setMatrix(mat);
-    canvas->drawPicture(*picture);
+    canvas->drawPicture(picture);
     canvas->restoreToCount(saveCount);
     canvas->flush();
 }
@@ -893,7 +893,7 @@
                                                  factory.get(),
                                                  this->recordFlags());
     this->scaleToScaleFactor(canvas);
-    canvas->drawPicture(*fPicture);
+    canvas->drawPicture(fPicture);
 }
 
 bool PlaybackCreationRenderer::render(SkBitmap** out) {
diff --git a/tools/lua/lua_pictures.cpp b/tools/lua/lua_pictures.cpp
index c8b205d..f1c5ce9 100644
--- a/tools/lua/lua_pictures.cpp
+++ b/tools/lua/lua_pictures.cpp
@@ -158,7 +158,7 @@
                                                     L.get(), gAccumulateFunc));
 
                 call_canvas(L.get(), canvas.get(), path, gStartCanvasFunc);
-                canvas->drawPicture(*pic);
+                canvas->drawPicture(pic);
                 call_canvas(L.get(), canvas.get(), path, gEndCanvasFunc);
 
             } else {
diff --git a/tools/pinspect.cpp b/tools/pinspect.cpp
index 306bf6f..368d6fe 100644
--- a/tools/pinspect.cpp
+++ b/tools/pinspect.cpp
@@ -48,7 +48,7 @@
 #ifdef SK_DEVELOPER
     SkDebugfDumper dumper;
     SkDumpCanvas canvas(&dumper);
-    canvas.drawPicture(*pic);
+    canvas.drawPicture(pic);
 #else
     printf("SK_DEVELOPER mode not enabled\n");
 #endif