Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Unified Diff: src/core/SkPicture.cpp

Issue 408923002: Add auto purging for SkPicture-related Ganesh resources (esp. layers) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix comment Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkDevice.cpp ('k') | src/gpu/GrLayerCache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPicture.cpp
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp
index d57de97d78c5f67a3c3da1c9a0087b9497e7a052..0b7a1dbcc592702ec3cf9185f3bfcded0b32bf79 100644
--- a/src/core/SkPicture.cpp
+++ b/src/core/SkPicture.cpp
@@ -144,7 +144,9 @@ static SkPicture* backport(const SkRecord& src, int width, int height) {
}
// fRecord OK
-SkPicture::~SkPicture() {}
+SkPicture::~SkPicture() {
+ this->callDeletionListeners();
+}
#ifdef SK_SUPPORT_LEGACY_PICTURE_CLONE
// fRecord TODO, fix by deleting this method
@@ -492,3 +494,21 @@ SkPicture::SkPicture(int width, int height, SkRecord* record)
, fRecordWillPlayBackBitmaps(SkRecordWillPlaybackBitmaps(*record)) {
this->needsNewGenID();
}
+
+// Note that we are assuming that this entry point will only be called from
+// one thread. Currently the only client of this method is
+// SkGpuDevice::EXPERIMENTAL_optimize which should be only called from a single
+// thread.
+void SkPicture::addDeletionListener(DeletionListener* listener) const {
+ SkASSERT(NULL != listener);
+
+ *fDeletionListeners.append() = SkRef(listener);
+}
+
+void SkPicture::callDeletionListeners() {
+ for (int i = 0; i < fDeletionListeners.count(); ++i) {
+ fDeletionListeners[i]->onDeletion(this->uniqueID());
+ }
+
+ fDeletionListeners.unrefAll();
+}
« no previous file with comments | « src/core/SkDevice.cpp ('k') | src/gpu/GrLayerCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698