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

Unified Diff: src/core/SkScaledImageCache.cpp

Issue 132803005: SkOnce: add option to call another cleanup function once at exit. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add static Created 6 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
« no previous file with comments | « src/core/SkPathRef.cpp ('k') | tests/CachedDecodingPixelRefTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkScaledImageCache.cpp
diff --git a/src/core/SkScaledImageCache.cpp b/src/core/SkScaledImageCache.cpp
index 2bc692a51b10f3a75e109f2a4e6e662959b4b7a8..6a1264eb6a3393ac165af18ba954f1657c2d7d31 100644
--- a/src/core/SkScaledImageCache.cpp
+++ b/src/core/SkScaledImageCache.cpp
@@ -683,21 +683,22 @@ void SkScaledImageCache::dump() const {
#include "SkThread.h"
SK_DECLARE_STATIC_MUTEX(gMutex);
+static SkScaledImageCache* gScaledImageCache = NULL;
+static void cleanup_gScaledImageCache() { SkDELETE(gScaledImageCache); }
-static void create_cache(SkScaledImageCache** cache) {
+static void create_cache(int) {
#ifdef SK_USE_DISCARDABLE_SCALEDIMAGECACHE
- *cache = SkNEW_ARGS(SkScaledImageCache, (SkDiscardableMemory::Create));
+ gScaledImageCache = SkNEW_ARGS(SkScaledImageCache, (SkDiscardableMemory::Create));
#else
- *cache = SkNEW_ARGS(SkScaledImageCache, (SK_DEFAULT_IMAGE_CACHE_LIMIT));
+ gScaledImageCache = SkNEW_ARGS(SkScaledImageCache, (SK_DEFAULT_IMAGE_CACHE_LIMIT));
#endif
}
static SkScaledImageCache* get_cache() {
- static SkScaledImageCache* gCache(NULL);
- SK_DECLARE_STATIC_ONCE(create_cache_once);
- SkOnce(&create_cache_once, create_cache, &gCache);
- SkASSERT(NULL != gCache);
- return gCache;
+ SK_DECLARE_STATIC_ONCE(once);
+ SkOnce(&once, create_cache, 0, cleanup_gScaledImageCache);
+ SkASSERT(NULL != gScaledImageCache);
+ return gScaledImageCache;
}
« no previous file with comments | « src/core/SkPathRef.cpp ('k') | tests/CachedDecodingPixelRefTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698