aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkResourceCache.cpp
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2015-01-26 11:24:37 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-01-26 11:24:37 -0800
commit1d9e80f02b8260ffe2eb1944042cd79f10e38d43 (patch)
tree3d4d7d57dac5d0debc91ec23076e71e1133940a0 /src/core/SkResourceCache.cpp
parent878fa0204bc246ec5fbaca4aa3c81aaefccc30a1 (diff)
check effective cache-size for fixed-budget caches
Diffstat (limited to 'src/core/SkResourceCache.cpp')
-rw-r--r--src/core/SkResourceCache.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/core/SkResourceCache.cpp b/src/core/SkResourceCache.cpp
index efcff26c1a..4ed889a0ab 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();