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

Unified Diff: src/core/SkResourceCache.cpp

Issue 670063004: Add SkMaskCache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add style and quality to mask key Created 6 years, 2 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
Index: src/core/SkResourceCache.cpp
diff --git a/src/core/SkResourceCache.cpp b/src/core/SkResourceCache.cpp
index f7a810ec87a05027af859bb071f00a2be86324b8..6f3ef0d91eb8abf025d178d832fab41c1f8c9dbe 100644
--- a/src/core/SkResourceCache.cpp
+++ b/src/core/SkResourceCache.cpp
@@ -291,6 +291,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) {
@@ -470,6 +479,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();

Powered by Google App Engine
This is Rietveld 408576698