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

Unified Diff: src/core/SkResourceCache.cpp

Issue 554263005: add PurgeResourceCache to track leaks (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 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/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 6400e8a71eccd0e45cc5c0bb2b26cc124fb07815..9262c3476fe4e0bc1d6ebb246d6de19e283189f0 100644
--- a/src/core/SkResourceCache.cpp
+++ b/src/core/SkResourceCache.cpp
@@ -303,7 +303,7 @@ void SkResourceCache::remove(Rec* rec) {
fCount -= 1;
}
-void SkResourceCache::purgeAsNeeded() {
+void SkResourceCache::purgeAsNeeded(bool forcePurge) {
size_t byteLimit;
int countLimit;
@@ -317,7 +317,7 @@ void SkResourceCache::purgeAsNeeded() {
Rec* rec = fTail;
while (rec) {
- if (fTotalBytesUsed < byteLimit && fCount < countLimit) {
+ if (!forcePurge && fTotalBytesUsed < byteLimit && fCount < countLimit) {
break;
}
@@ -564,6 +564,11 @@ size_t SkResourceCache::GetSingleAllocationByteLimit() {
return get_cache()->getSingleAllocationByteLimit();
}
+void SkResourceCache::PurgeAll() {
+ SkAutoMutexAcquire am(gMutex);
+ return get_cache()->purgeAll();
+}
+
const SkResourceCache::Rec* SkResourceCache::FindAndLock(const Key& key) {
SkAutoMutexAcquire am(gMutex);
return get_cache()->findAndLock(key);
@@ -603,3 +608,7 @@ size_t SkGraphics::SetResourceCacheSingleAllocationByteLimit(size_t newLimit) {
return SkResourceCache::SetSingleAllocationByteLimit(newLimit);
}
+void SkGraphics::PurgeResourceCache() {
+ return SkResourceCache::PurgeAll();
+}
+
« no previous file with comments | « src/core/SkResourceCache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698