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

Unified Diff: src/core/SkResourceCache.cpp

Issue 825263005: notify resource caches when pixelref genID goes stale (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 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
« src/core/SkResourceCache.h ('K') | « src/core/SkResourceCache.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkResourceCache.cpp
diff --git a/src/core/SkResourceCache.cpp b/src/core/SkResourceCache.cpp
index ae8412d8b47a323ecd7f5e2f6508629d8d6abcb4..bb159fe1e4baee9f88f1560cc0eaf13852bde9c2 100644
--- a/src/core/SkResourceCache.cpp
+++ b/src/core/SkResourceCache.cpp
@@ -294,6 +294,19 @@ void SkResourceCache::purgeAsNeeded(bool forcePurge) {
}
}
+void SkResourceCache::purgeVisitor(const void* nameSpace, VisitorProc proc, void* context) {
+ // go backwards, just like purgeAsNeeded, just to make the code similar.
+ // could iterate either direction and still be correct.
+ Rec* rec = fTail;
+ while (rec) {
+ Rec* prev = rec->fPrev;
+ if (rec->getKey().getNamespace() == nameSpace && !proc(*rec, context)) {
+ this->remove(rec);
+ }
+ rec = prev;
+ }
+}
+
size_t SkResourceCache::setTotalByteLimit(size_t newLimit) {
size_t prevLimit = fTotalByteLimit;
fTotalByteLimit = newLimit;
@@ -511,6 +524,11 @@ size_t SkResourceCache::GetSingleAllocationByteLimit() {
return get_cache()->getSingleAllocationByteLimit();
}
+void SkResourceCache::PurgeVisitor(const void* nameSpace, VisitorProc proc, void* context) {
+ SkAutoMutexAcquire am(gMutex);
+ return get_cache()->purgeVisitor(nameSpace, proc, context);
+}
+
void SkResourceCache::PurgeAll() {
SkAutoMutexAcquire am(gMutex);
return get_cache()->purgeAll();
« src/core/SkResourceCache.h ('K') | « src/core/SkResourceCache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698