Index: src/core/SkResourceCache.cpp |
diff --git a/src/core/SkResourceCache.cpp b/src/core/SkResourceCache.cpp |
index 1eb53cd8c6b4b504cdb7fb4674f9c7d4666cbb1c..ae8412d8b47a323ecd7f5e2f6508629d8d6abcb4 100644 |
--- a/src/core/SkResourceCache.cpp |
+++ b/src/core/SkResourceCache.cpp |
@@ -303,6 +303,15 @@ size_t SkResourceCache::setTotalByteLimit(size_t newLimit) { |
return prevLimit; |
} |
+SkCachedData* SkResourceCache::newCachedData(size_t bytes) { |
+ if (fDiscardableFactory) { |
+ SkDiscardableMemory* dm = fDiscardableFactory(bytes); |
+ return dm ? SkNEW_ARGS(SkCachedData, (bytes, dm)) : NULL; |
+ } else { |
+ return SkNEW_ARGS(SkCachedData, (sk_malloc_throw(bytes), bytes)); |
+ } |
+} |
+ |
/////////////////////////////////////////////////////////////////////////////// |
void SkResourceCache::detach(Rec* rec) { |
@@ -482,6 +491,11 @@ SkBitmap::Allocator* SkResourceCache::GetAllocator() { |
return get_cache()->allocator(); |
} |
+SkCachedData* SkResourceCache::NewCachedData(size_t bytes) { |
+ SkAutoMutexAcquire am(gMutex); |
+ return get_cache()->newCachedData(bytes); |
+} |
+ |
void SkResourceCache::Dump() { |
SkAutoMutexAcquire am(gMutex); |
get_cache()->dump(); |