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

Unified Diff: src/core/SkResourceCache.cpp

Issue 876743002: check effective cache-size for fixed-budget caches (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 efcff26c1a84c170d8d8a01b922c4550c7f049f7..4ed889a0aba3095900d934187f812f170217cca8 100644
--- a/src/core/SkResourceCache.cpp
+++ b/src/core/SkResourceCache.cpp
@@ -435,6 +435,22 @@ size_t SkResourceCache::getSingleAllocationByteLimit() const {
return fSingleAllocationByteLimit;
}
+size_t SkResourceCache::getEffectiveSingleAllocationByteLimit() const {
+ // fSingleAllocationByteLimit == 0 means the caller is asking for our default
+ size_t limit = fSingleAllocationByteLimit;
+
+ // if we're not discardable (i.e. we are fixed-budget) then cap the single-limit
+ // to our budget.
+ if (NULL == fDiscardableFactory) {
+ if (0 == limit) {
+ limit = fTotalByteLimit;
+ } else {
+ limit = SkTMin(limit, fTotalByteLimit);
+ }
+ }
+ return limit;
+}
+
///////////////////////////////////////////////////////////////////////////////
#include "SkThread.h"
@@ -511,6 +527,11 @@ size_t SkResourceCache::GetSingleAllocationByteLimit() {
return get_cache()->getSingleAllocationByteLimit();
}
+size_t SkResourceCache::GetEffectiveSingleAllocationByteLimit() {
+ SkAutoMutexAcquire am(gMutex);
+ return get_cache()->getEffectiveSingleAllocationByteLimit();
+}
+
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