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

Unified Diff: src/core/SkScaledImageCache.cpp

Issue 297273006: Remove some unnecessary uses of SkOnce. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 7 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 | « gm/imagefiltersgraph.cpp ('k') | no next file » | 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 886b1438ca70ec243a69eebde6db3a2a134e6623..8a27445efb48b9aeb6026f52f587ed89daa6d0c6 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,16 @@ SK_DECLARE_STATIC_MUTEX(gMutex);
static SkScaledImageCache* gScaledImageCache = NULL;
static void cleanup_gScaledImageCache() { SkDELETE(gScaledImageCache); }
-static void create_cache(int) {
+static SkScaledImageCache* get_cache() {
+ // gMutex is always held when this is called, so we don't need to be fancy in here.
bungeman-skia 2014/05/27 16:21:21 We do have places where we have this requirement (
mtklein 2014/05/27 16:23:10 Done.
+ 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;
}
« no previous file with comments | « gm/imagefiltersgraph.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698