aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2014-07-22 10:18:06 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-07-22 10:18:06 -0700
commitd771f6bc273457bc7aa95938ac326dfbbf876e1a (patch)
tree9a88b85ac2a0c044c9a160a0f960b5d7f761267f /include/core
parent17f0b6df7248b9bbdaddacc3a6c9c6efe4ae278e (diff)
Add auto purging for SkPicture-related Ganesh resources (esp. layers)
This is intended to lower the bookkeeping burden for the Layer Caching feature. Cached layers are now automatically purged when a picture is deleted. R=bsalomon@google.com Author: robertphillips@google.com Review URL: https://codereview.chromium.org/408923002
Diffstat (limited to 'include/core')
-rw-r--r--include/core/SkCanvas.h6
-rw-r--r--include/core/SkDevice.h7
-rw-r--r--include/core/SkPicture.h11
3 files changed, 11 insertions, 13 deletions
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 6bd3cc5363..d68a9c50ab 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -964,12 +964,6 @@ public:
*/
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(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
of this canvas will be unchanged after this call.
diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h
index 2e06aab74f..4a9edee0ec 100644
--- a/include/core/SkDevice.h
+++ b/include/core/SkDevice.h
@@ -338,13 +338,6 @@ protected:
/**
* 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(const SkPicture* picture);
-
- /**
- * PRIVATE / EXPERIMENTAL -- do not call
* This entry point gives the backend an opportunity to take over the rendering
* of 'picture'. If optimization data is available (due to an earlier
* 'optimize' call) this entry point should make use of it and return true
diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h
index db996e02e8..21ebef32cd 100644
--- a/include/core/SkPicture.h
+++ b/include/core/SkPicture.h
@@ -190,6 +190,14 @@ public:
bool suitableForGpuRasterization(GrContext*, const char ** = NULL) const;
#endif
+ class DeletionListener : public SkRefCnt {
+ public:
+ virtual void onDeletion(uint32_t pictureID) = 0;
+ };
+
+ // Takes ref on listener.
+ void addDeletionListener(DeletionListener* listener) const;
+
private:
// V2 : adds SkPixelRef's generation ID.
// V3 : PictInfo tag at beginning, and EOF tag at the end
@@ -237,7 +245,10 @@ private:
int fWidth, fHeight;
mutable SkAutoTUnref<const AccelData> fAccelData;
+ mutable SkTDArray<DeletionListener*> fDeletionListeners; // pointers are refed
+
void needsNewGenID() { fUniqueID = SK_InvalidGenID; }
+ void callDeletionListeners();
// Create a new SkPicture from an existing SkPictureData. The new picture
// takes ownership of 'data'.