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

Unified Diff: src/core/SkGlyphCache.cpp

Issue 304383005: Port most uses of SkOnce to SkLazyPtr. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add mutex 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 | « src/core/SkFontHost.cpp ('k') | src/core/SkLazyPtr.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkGlyphCache.cpp
diff --git a/src/core/SkGlyphCache.cpp b/src/core/SkGlyphCache.cpp
index 699801d2dbb3cb9ca16c87c1bd8f3f5351b92495..2ab721aab464c74676cde710a711156c125e5a2d 100755
--- a/src/core/SkGlyphCache.cpp
+++ b/src/core/SkGlyphCache.cpp
@@ -11,7 +11,7 @@
#include "SkGlyphCache_Globals.h"
#include "SkDistanceFieldGen.h"
#include "SkGraphics.h"
-#include "SkOnce.h"
+#include "SkLazyPtr.h"
#include "SkPaint.h"
#include "SkPath.h"
#include "SkTemplates.h"
@@ -21,18 +21,18 @@
//#define SPEW_PURGE_STATUS
//#define RECORD_HASH_EFFICIENCY
-static void create_globals(SkGlyphCache_Globals** globals) {
- *globals = SkNEW_ARGS(SkGlyphCache_Globals, (SkGlyphCache_Globals::kYes_UseMutex));
+namespace {
+
+SkGlyphCache_Globals* create_globals() {
+ return SkNEW_ARGS(SkGlyphCache_Globals, (SkGlyphCache_Globals::kYes_UseMutex));
}
+} // namespace
+
// Returns the shared globals
static SkGlyphCache_Globals& getSharedGlobals() {
- // we leak this, so we don't incur any shutdown cost of the destructor
- static SkGlyphCache_Globals* gGlobals = NULL;
- SK_DECLARE_STATIC_ONCE(once);
- SkOnce(&once, create_globals, &gGlobals);
- SkASSERT(NULL != gGlobals);
- return *gGlobals;
+ SK_DECLARE_STATIC_LAZY_PTR(SkGlyphCache_Globals, globals, create_globals);
+ return *globals.get();
}
// Returns the TLS globals (if set), or the shared globals
« no previous file with comments | « src/core/SkFontHost.cpp ('k') | src/core/SkLazyPtr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698