check effective cache-size for fixed-budget caches

BUG=skia:

Review URL: https://codereview.chromium.org/876743002
diff --git a/src/core/SkResourceCache.cpp b/src/core/SkResourceCache.cpp
index efcff26..4ed889a 100644
--- a/src/core/SkResourceCache.cpp
+++ b/src/core/SkResourceCache.cpp
@@ -435,6 +435,22 @@
     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 @@
     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();