diff options
author | robertphillips <robertphillips@google.com> | 2014-06-04 05:40:44 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-06-04 05:40:44 -0700 |
commit | 9b14f26d0f3a974f3dd626c8354e1db1cfcd322f (patch) | |
tree | 542d5f1d7a1266454675745139e956b4424fde4b | |
parent | 232f7259a939c70ce447a729a5094fcc272b679d (diff) |
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
58 files changed, 187 insertions, 159 deletions
diff --git a/dm/DMUtil.cpp b/dm/DMUtil.cpp index f142d47dda..23634c30ad 100644 --- a/dm/DMUtil.cpp +++ b/dm/DMUtil.cpp @@ -35,7 +35,7 @@ void DrawPicture(SkPicture* picture, SkBitmap* bitmap) { 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 1790b48704..a976ea49da 100644 --- a/experimental/PdfViewer/SkNulCanvas.h +++ b/experimental/PdfViewer/SkNulCanvas.h @@ -47,7 +47,6 @@ public: 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 @@ protected: 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 65a233ffac..b73971441c 100644 --- a/gm/gmmain.cpp +++ b/gm/gmmain.cpp @@ -642,7 +642,7 @@ public: 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 e04692bfac..076f733af3 100644 --- a/gm/pathopsskpclip.cpp +++ b/gm/pathopsskpclip.cpp @@ -55,13 +55,13 @@ protected: 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 abcda610cb..12cf94b891 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 d1cd24c29f..f4e65bc34e 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 4aaf46b397..ee8ad250d2 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -969,13 +969,13 @@ public: 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 @@ public: @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 @@ protected: 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 078f7f531f..e58a491563 100644 --- a/include/core/SkDevice.h +++ b/include/core/SkDevice.h @@ -343,14 +343,14 @@ protected: * 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 @@ protected: * 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 7ca59bf1ba..a908ab577f 100644 --- a/include/core/SkPicture.h +++ b/include/core/SkPicture.h @@ -68,7 +68,7 @@ public: 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 @@ public: 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 @@ protected: SkPicturePlayback* fPlayback; SkPictureRecord* fRecord; int fWidth, fHeight; - const AccelData* fAccelData; + mutable const AccelData* fAccelData; void needsNewGenID() { fUniqueID = SK_InvalidGenID; } @@ -397,7 +397,7 @@ private: /** 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 f2a27d7bf5..c9650d6184 100644 --- a/include/gpu/SkGpuDevice.h +++ b/include/gpu/SkGpuDevice.h @@ -152,11 +152,11 @@ protected: 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 9413512c87..31ebce48b3 100644 --- a/include/utils/SkDeferredCanvas.h +++ b/include/utils/SkDeferredCanvas.h @@ -162,7 +162,6 @@ public: 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 @@ protected: 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 6fc679bfeb..0aa55463b4 100644 --- a/include/utils/SkDumpCanvas.h +++ b/include/utils/SkDumpCanvas.h @@ -90,7 +90,6 @@ public: 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 @@ protected: 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 3efbdb95bc..6bef8686a3 100644 --- a/include/utils/SkLuaCanvas.h +++ b/include/utils/SkLuaCanvas.h @@ -36,7 +36,6 @@ public: 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 @@ protected: 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 e60dc4d8b5..bd1935539e 100644 --- a/include/utils/SkNWayCanvas.h +++ b/include/utils/SkNWayCanvas.h @@ -43,7 +43,6 @@ public: 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 @@ protected: 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 a418ec0850..09bf37578b 100644 --- a/include/utils/SkProxyCanvas.h +++ b/include/utils/SkProxyCanvas.h @@ -42,7 +42,6 @@ public: 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 @@ protected: 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 5e304d8661..35021cba9f 100644 --- a/samplecode/SampleApp.cpp +++ b/samplecode/SampleApp.cpp @@ -1470,7 +1470,7 @@ void SampleWindow::afterChildren(SkCanvas* orig) { 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 @@ void SampleWindow::afterChildren(SkCanvas* orig) { 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 7b9584d305..9e9764c433 100644 --- a/samplecode/SamplePictFile.cpp +++ b/samplecode/SamplePictFile.cpp @@ -100,7 +100,7 @@ protected: *picture = LoadPicture(fFilename.c_str(), fBBox); } if (*picture) { - canvas->drawPicture(**picture); + canvas->drawPicture(*picture); } } @@ -140,7 +140,7 @@ private: 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 f242c21944..9c965e4308 100644 --- a/samplecode/SamplePicture.cpp +++ b/samplecode/SamplePicture.cpp @@ -74,13 +74,13 @@ public: 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 @@ protected: 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 @@ protected: 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 a59a8021b6..6bb9c74346 100644 --- a/samplecode/SampleTiling.cpp +++ b/samplecode/SampleTiling.cpp @@ -158,7 +158,7 @@ protected: } SkASSERT(NULL != fTextPicture); - canvas->drawPicture(*fTextPicture); + canvas->drawPicture(fTextPicture); } private: diff --git a/src/core/SkBBoxRecord.cpp b/src/core/SkBBoxRecord.cpp index b1c229e68b..a40ea8ba0d 100644 --- a/src/core/SkBBoxRecord.cpp +++ b/src/core/SkBBoxRecord.cpp @@ -280,10 +280,10 @@ void SkBBoxRecord::drawVertices(VertexMode mode, int vertexCount, } } -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 f2e9d8d283..123a91f1ec 100644 --- a/src/core/SkBBoxRecord.h +++ b/src/core/SkBBoxRecord.h @@ -54,7 +54,6 @@ public: 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 @@ protected: 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 53dec2ef4c..3134c46686 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -2479,31 +2479,39 @@ void SkCanvas::drawTextOnPathHV(const void* text, size_t byteLength, } /////////////////////////////////////////////////////////////////////////////// -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 36a8a754c0..6c5c0f391d 100644 --- a/src/core/SkDevice.cpp +++ b/src/core/SkDevice.cpp @@ -131,15 +131,15 @@ void* SkBaseDevice::onAccessPixels(SkImageInfo* info, size_t* rowBytes) { 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 00bcbef275..98c0e00c8c 100644 --- a/src/core/SkPicture.cpp +++ b/src/core/SkPicture.cpp @@ -366,7 +366,7 @@ const SkPicture::OperationList& SkPicture::OperationList::InvalidList() { 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 @@ size_t SkPicture::EXPERIMENTAL_curOpID() const { 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 8c77eeb6ac..63f2d7e8f9 100644 --- a/src/core/SkPicturePlayback.cpp +++ b/src/core/SkPicturePlayback.cpp @@ -129,10 +129,10 @@ SkPicturePlayback::SkPicturePlayback(const SkPicture* picture, 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 @@ SkPicturePlayback::SkPicturePlayback(const SkPicture* picture, const SkPicturePl } 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 @@ bool SkPicturePlayback::parseStreamTag(SkPicture* picture, } 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 @@ bool SkPicturePlayback::parseBufferTag(SkPicture* picture, 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 d6f0cf1919..ea36ca948b 100644 --- a/src/core/SkPicturePlayback.h +++ b/src/core/SkPicturePlayback.h @@ -150,10 +150,10 @@ private: 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 @@ private: 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 36b0763e9f..0c59b13b86 100644 --- a/src/core/SkPictureRecord.cpp +++ b/src/core/SkPictureRecord.cpp @@ -1411,7 +1411,7 @@ void SkPictureRecord::onDrawTextOnPath(const void* text, size_t byteLength, cons 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 @@ void SkPictureRecord::addPath(const SkPath& path) { 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 22d2546072..d6cdf05f28 100644 --- a/src/core/SkPictureRecord.h +++ b/src/core/SkPictureRecord.h @@ -55,7 +55,6 @@ public: 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 @@ public: 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 @@ private: 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 @@ protected: 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 @@ private: 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 ecb86e7e71..81e13752f6 100644 --- a/src/core/SkPictureShader.cpp +++ b/src/core/SkPictureShader.cpp @@ -92,7 +92,7 @@ SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix, const SkMatri 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 af9466f977..2d2df9231e 100644 --- a/src/effects/SkPictureImageFilter.cpp +++ b/src/effects/SkPictureImageFilter.cpp @@ -85,7 +85,7 @@ bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Co 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 0621aace44..f6377bf7e9 100644 --- a/src/gpu/GrLayerCache.cpp +++ b/src/gpu/GrLayerCache.cpp @@ -66,7 +66,7 @@ void GrLayerCache::freeAll() { 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::createLayer(SkPicture* picture, int layerID) { } -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 414b87dbb3..a957e78013 100644 --- a/src/gpu/GrLayerCache.h +++ b/src/gpu/GrLayerCache.h @@ -102,7 +102,7 @@ public: void freeAll(); - GrCachedLayer* findLayerOrCreate(SkPicture* picture, int id); + GrCachedLayer* findLayerOrCreate(const SkPicture* picture, int id); private: SkAutoTUnref<GrGpu> fGpu; @@ -113,7 +113,7 @@ private: 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 f8c2d31843..5166bb154f 100644 --- a/src/gpu/GrPictureUtils.cpp +++ b/src/gpu/GrPictureUtils.cpp @@ -29,7 +29,7 @@ class GrGatherDevice : public SkBaseDevice { 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 @@ protected: private: // The picture being processed - SkPicture *fPicture; + const SkPicture *fPicture; SkBitmap fEmptyBitmap; // legacy -- need to remove @@ -223,7 +223,7 @@ private: // 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 @@ public: 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 @@ protected: 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 a280a16ce3..a730697d62 100644 --- a/src/gpu/GrPictureUtils.h +++ b/src/gpu/GrPictureUtils.h @@ -74,6 +74,6 @@ private: 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 b05cd33425..7514359216 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -1816,7 +1816,7 @@ SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info) { 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 @@ static void wrap_texture(GrTexture* texture, int width, int height, SkBitmap* re 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 4a5dcd51a0..a3c38646bb 100644 --- a/src/pipe/SkGPipeWrite.cpp +++ b/src/pipe/SkGPipeWrite.cpp @@ -249,7 +249,6 @@ public: 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 @@ protected: 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::onDrawTextOnPath(const void* text, size_t byteLength, const } } -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 74101c1bed..8581257c4a 100644 --- a/src/record/SkRecorder.cpp +++ b/src/record/SkRecorder.cpp @@ -186,8 +186,8 @@ void SkRecorder::onDrawTextOnPath(const void* text, size_t byteLength, const SkP 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 cee25c152b..3e2932d42e 100644 --- a/src/record/SkRecorder.h +++ b/src/record/SkRecorder.h @@ -52,7 +52,6 @@ public: 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 @@ public: 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 02c2c5af28..e244505263 100644 --- a/src/utils/SkDeferredCanvas.cpp +++ b/src/utils/SkDeferredCanvas.cpp @@ -936,7 +936,7 @@ void SkDeferredCanvas::onDrawTextOnPath(const void* text, size_t byteLength, con 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 9814fb5762..4dfed395e0 100644 --- a/src/utils/SkDumpCanvas.cpp +++ b/src/utils/SkDumpCanvas.cpp @@ -422,14 +422,14 @@ void SkDumpCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const S 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 320d99694a..f46fe8ed42 100644 --- a/src/utils/SkGatherPixelRefsAndRects.cpp +++ b/src/utils/SkGatherPixelRefsAndRects.cpp @@ -21,5 +21,5 @@ void SkPictureUtils::GatherPixelRefsAndRects(SkPicture* pict, 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 b4c7c771c3..d9c5dc1d76 100644 --- a/src/utils/SkLuaCanvas.cpp +++ b/src/utils/SkLuaCanvas.cpp @@ -268,10 +268,10 @@ void SkLuaCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const Sk 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 3c98e4be09..505c05cbf1 100644 --- a/src/utils/SkNWayCanvas.cpp +++ b/src/utils/SkNWayCanvas.cpp @@ -265,7 +265,7 @@ void SkNWayCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const S } } -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 a2d6da131e..02fa6b11c4 100644 --- a/src/utils/SkPictureUtils.cpp +++ b/src/utils/SkPictureUtils.cpp @@ -214,7 +214,7 @@ SkData* SkPictureUtils::GatherPixelRefs(SkPicture* pict, const SkRect& area) { 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 20f93071c0..5cb54698f6 100644 --- a/src/utils/SkProxyCanvas.cpp +++ b/src/utils/SkProxyCanvas.cpp @@ -136,7 +136,7 @@ void SkProxyCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const 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 89a388e110..8f6dc1b7a2 100644 --- a/src/utils/debugger/SkDebugCanvas.cpp +++ b/src/utils/debugger/SkDebugCanvas.cpp @@ -519,7 +519,7 @@ void SkDebugCanvas::drawPath(const SkPath& path, const SkPaint& paint) { 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 e94f30f335..f15b397251 100644 --- a/src/utils/debugger/SkDebugCanvas.h +++ b/src/utils/debugger/SkDebugCanvas.h @@ -189,8 +189,6 @@ public: 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 @@ protected: 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 079961ae70..7c73cec786 100644 --- a/src/utils/debugger/SkDrawCommand.cpp +++ b/src/utils/debugger/SkDrawCommand.cpp @@ -502,11 +502,11 @@ bool SkDrawPathCommand::render(SkCanvas* canvas) const { 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 @@ bool SkDrawPictureCommand::render(SkCanvas* canvas) const { 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 f2e151ae4f..a0bfb2ddca 100644 --- a/src/utils/debugger/SkDrawCommand.h +++ b/src/utils/debugger/SkDrawCommand.h @@ -343,12 +343,12 @@ private: 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 597b578e4c..e2ad2ed6b3 100644 --- a/tests/CanvasTest.cpp +++ b/tests/CanvasTest.cpp @@ -503,7 +503,7 @@ static void DrawPictureTestStep(SkCanvas* canvas, 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 0c4d0766b5..cd6d235dc5 100644 --- a/tests/ImageFilterTest.cpp +++ b/tests/ImageFilterTest.cpp @@ -491,7 +491,7 @@ DEF_TEST(ImageFilterMatrixTest, reporter) { recordingCanvas->restore(); // saveLayer SkAutoTUnref<SkPicture> picture(recorder.endRecording()); - canvas.drawPicture(*picture); + canvas.drawPicture(picture); } DEF_TEST(ImageFilterPictureImageFilterTest, reporter) { @@ -529,7 +529,7 @@ DEF_TEST(ImageFilterPictureImageFilterTest, reporter) { // 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 @@ DEF_TEST(ImageFilterPictureImageFilterTest, reporter) { 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 @@ DEF_TEST(ImageFilterEmptySaveLayerTest, reporter) { 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 @@ DEF_TEST(ImageFilterEmptySaveLayerTest, reporter) { 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 @@ DEF_TEST(ImageFilterEmptySaveLayerTest, reporter) { 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 e6cf55342e..cb154def96 100644 --- a/tests/PictureStateTreeTest.cpp +++ b/tests/PictureStateTreeTest.cpp @@ -84,9 +84,9 @@ static void test_reference_picture(skiatest::Reporter* reporter) { 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 @@ static void test_reference_picture(skiatest::Reporter* reporter) { 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 @@ static void test_reference_picture(skiatest::Reporter* reporter) { 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 494b4ed8d4..f65c840899 100644 --- a/tests/PictureTest.cpp +++ b/tests/PictureTest.cpp @@ -346,7 +346,7 @@ static void draw(SkPicture* pic, int width, int height, SkBitmap* result) { 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 @@ static void test_unbalanced_save_restores(skiatest::Reporter* reporter) { 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 @@ static void test_unbalanced_save_restores(skiatest::Reporter* reporter) { canvas->restore(); SkAutoTUnref<SkPicture> extraRestorePicture(recorder.endRecording()); - testCanvas.drawPicture(*extraRestorePicture); + testCanvas.drawPicture(extraRestorePicture); REPORTER_ASSERT(reporter, 4 == testCanvas.getSaveCount()); } @@ -1099,7 +1099,7 @@ static void test_unbalanced_save_restores(skiatest::Reporter* reporter) { 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 @@ static void test_bad_bitmap() { SkAutoTUnref<SkPicture> picture(recorder.endRecording()); SkCanvas canvas; - canvas.drawPicture(*picture); + canvas.drawPicture(picture); } #endif @@ -1247,7 +1247,7 @@ static void test_draw_empty(skiatest::Reporter* reporter) { recorder.beginRecording(1, 1, NULL, 0); SkAutoTUnref<SkPicture> picture(recorder.endRecording()); - canvas.drawPicture(*picture); + canvas.drawPicture(picture); } { @@ -1262,7 +1262,7 @@ static void test_draw_empty(skiatest::Reporter* reporter) { recorder.beginRecording(1, 1, &factory, 0); SkAutoTUnref<SkPicture> picture(recorder.endRecording()); - canvas.drawPicture(*picture); + canvas.drawPicture(picture); } { @@ -1272,7 +1272,7 @@ static void test_draw_empty(skiatest::Reporter* reporter) { recorder.beginRecording(1, 1, &factory, 0); SkAutoTUnref<SkPicture> picture(recorder.endRecording()); - canvas.drawPicture(*picture); + canvas.drawPicture(picture); } { @@ -1282,7 +1282,7 @@ static void test_draw_empty(skiatest::Reporter* reporter) { recorder.beginRecording(1, 1, &factory, 0); SkAutoTUnref<SkPicture> picture(recorder.endRecording()); - canvas.drawPicture(*picture); + canvas.drawPicture(picture); } } @@ -1460,27 +1460,27 @@ static void test_hierarchical(skiatest::Reporter* reporter) { { 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 8022092c9a..245685568a 100644 --- a/tools/CopyTilesRenderer.cpp +++ b/tools/CopyTilesRenderer.cpp @@ -55,7 +55,7 @@ namespace sk_tools { 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 890abde320..bcecf579a8 100644 --- a/tools/PdfRenderer.cpp +++ b/tools/PdfRenderer.cpp @@ -51,7 +51,7 @@ bool SimplePdfRenderer::render() { return false; } - fCanvas->drawPicture(*fPicture); + fCanvas->drawPicture(fPicture); fCanvas->flush(); return fPdfDoc->close(); diff --git a/tools/PictureRenderer.cpp b/tools/PictureRenderer.cpp index 5128782d44..0343460e32 100644 --- a/tools/PictureRenderer.cpp +++ b/tools/PictureRenderer.cpp @@ -390,7 +390,7 @@ bool PipePictureRenderer::render(SkBitmap** out) { 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 @@ bool SimplePictureRenderer::render(SkBitmap** out) { return false; } - fCanvas->drawPicture(*fPicture); + fCanvas->drawPicture(fPicture); fCanvas->flush(); if (NULL != out) { *out = SkNEW(SkBitmap); @@ -592,7 +592,7 @@ static void draw_tile_to_canvas(SkCanvas* canvas, const SkRect& tileRect, SkPict 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 @@ void PlaybackCreationRenderer::setup() { 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 c8b205d255..f1c5ce920f 100644 --- a/tools/lua/lua_pictures.cpp +++ b/tools/lua/lua_pictures.cpp @@ -158,7 +158,7 @@ int tool_main(int argc, char** argv) { 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 306bf6f6a0..368d6feca7 100644 --- a/tools/pinspect.cpp +++ b/tools/pinspect.cpp @@ -48,7 +48,7 @@ static void dumpOps(SkPicture* pic) { #ifdef SK_DEVELOPER SkDebugfDumper dumper; SkDumpCanvas canvas(&dumper); - canvas.drawPicture(*pic); + canvas.drawPicture(pic); #else printf("SK_DEVELOPER mode not enabled\n"); #endif |