Index: src/core/SkScaledImageCache.cpp |
diff --git a/src/core/SkScaledImageCache.cpp b/src/core/SkScaledImageCache.cpp |
index 886b1438ca70ec243a69eebde6db3a2a134e6623..a6bffd899fe66938a91fccf1dc90660d5d7e9a51 100644 |
--- a/src/core/SkScaledImageCache.cpp |
+++ b/src/core/SkScaledImageCache.cpp |
@@ -7,7 +7,6 @@ |
#include "SkScaledImageCache.h" |
#include "SkMipMap.h" |
-#include "SkOnce.h" |
#include "SkPixelRef.h" |
#include "SkRect.h" |
@@ -673,18 +672,17 @@ SK_DECLARE_STATIC_MUTEX(gMutex); |
static SkScaledImageCache* gScaledImageCache = NULL; |
static void cleanup_gScaledImageCache() { SkDELETE(gScaledImageCache); } |
-static void create_cache(int) { |
+/** Must hold gMutex when calling. */ |
+static SkScaledImageCache* get_cache() { |
+ // gMutex is always held when this is called, so we don't need to be fancy in here. |
+ if (NULL == gScaledImageCache) { |
#ifdef SK_USE_DISCARDABLE_SCALEDIMAGECACHE |
- gScaledImageCache = SkNEW_ARGS(SkScaledImageCache, (SkDiscardableMemory::Create)); |
+ gScaledImageCache = SkNEW_ARGS(SkScaledImageCache, (SkDiscardableMemory::Create)); |
#else |
- gScaledImageCache = SkNEW_ARGS(SkScaledImageCache, (SK_DEFAULT_IMAGE_CACHE_LIMIT)); |
+ gScaledImageCache = SkNEW_ARGS(SkScaledImageCache, (SK_DEFAULT_IMAGE_CACHE_LIMIT)); |
#endif |
-} |
- |
-static SkScaledImageCache* get_cache() { |
- SK_DECLARE_STATIC_ONCE(once); |
- SkOnce(&once, create_cache, 0, cleanup_gScaledImageCache); |
- SkASSERT(NULL != gScaledImageCache); |
+ atexit(cleanup_gScaledImageCache); |
+ } |
return gScaledImageCache; |
} |