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

Unified Diff: src/core/SkPixelRef.cpp

Issue 825263005: notify resource caches when pixelref genID goes stale (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add test for purge notifications Created 5 years, 10 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/SkBitmapCache.cpp ('k') | src/core/SkResourceCache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPixelRef.cpp
diff --git a/src/core/SkPixelRef.cpp b/src/core/SkPixelRef.cpp
index f56298165cd67648276272f6667d9753c38b604e..a2638c9431777d7301aed5acc25ed037c70c21cb 100644
--- a/src/core/SkPixelRef.cpp
+++ b/src/core/SkPixelRef.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "SkBitmapCache.h"
#include "SkPixelRef.h"
#include "SkThread.h"
@@ -222,6 +223,7 @@ void SkPixelRef::addGenIDChangeListener(GenIDChangeListener* listener) {
*fGenIDChangeListeners.append() = listener;
}
+// we need to be called *before* the genID gets changed or zerod
void SkPixelRef::callGenIDChangeListeners() {
// We don't invalidate ourselves if we think another SkPixelRef is sharing our genID.
if (fUniqueGenerationID) {
@@ -231,6 +233,15 @@ void SkPixelRef::callGenIDChangeListeners() {
}
// Listeners get at most one shot, so whether these triggered or not, blow them away.
fGenIDChangeListeners.deleteAll();
+
+ // if fGenerationID is 0, then perhaps we never had one, and we are in the destructor
+ if (fGenerationID) {
+ // If the ResourceCache ever generalizes/standardizes on accessing the gen-id field,
+ // then it would be more efficient to roll these together, and only grab the mutex
+ // and fixing the resources once...
+ SkBitmapCache::NotifyGenIDStale(fGenerationID);
+ SkMipMapCache::NotifyGenIDStale(fGenerationID);
+ }
}
void SkPixelRef::notifyPixelsChanged() {
« no previous file with comments | « src/core/SkBitmapCache.cpp ('k') | src/core/SkResourceCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698