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

Unified Diff: src/core/SkPixelRef.cpp

Issue 960563002: only notify bitmaps that have been added to the cache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: address reviewer comments 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.cpp » ('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 7aed66c7226e1fc67f4c6e096640972114ea3be1..560748c463c99dfa84cea4857085c6ff392261b8 100644
--- a/src/core/SkPixelRef.cpp
+++ b/src/core/SkPixelRef.cpp
@@ -100,6 +100,7 @@ SkPixelRef::SkPixelRef(const SkImageInfo& info)
this->needsNewGenID();
fIsImmutable = false;
fPreLocked = false;
+ fAddedToCache.store(false);
}
@@ -115,6 +116,7 @@ SkPixelRef::SkPixelRef(const SkImageInfo& info, SkBaseMutex* mutex)
this->needsNewGenID();
fIsImmutable = false;
fPreLocked = false;
+ fAddedToCache.store(false);
}
SkPixelRef::~SkPixelRef() {
@@ -225,10 +227,11 @@ void SkPixelRef::callGenIDChangeListeners() {
fGenIDChangeListeners[i]->onChange();
}
- // If we can flag the pixelref somehow whenever it was actually added to the cache,
- // perhaps it would be nice to only call this notifier in that case. For now we always
- // call it, since we don't know if it was cached or not.
- SkNotifyBitmapGenIDIsStale(this->getGenerationID());
+ // TODO: SkAtomic could add "old_value = atomic.xchg(new_value)" to make this clearer.
+ if (fAddedToCache.load()) {
+ SkNotifyBitmapGenIDIsStale(this->getGenerationID());
+ fAddedToCache.store(false);
+ }
}
// Listeners get at most one shot, so whether these triggered or not, blow them away.
fGenIDChangeListeners.deleteAll();
« no previous file with comments | « src/core/SkBitmapCache.cpp ('k') | src/core/SkResourceCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698