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

Unified Diff: src/core/SkFontHost.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 | « include/ports/SkRemotableFontMgr.h ('k') | src/core/SkGlyphCache.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkFontHost.cpp
diff --git a/src/core/SkFontHost.cpp b/src/core/SkFontHost.cpp
index 9e7eeb182d1790ba9f362fd9c2bcbcdaf91f150a..a16a8c42e02956274090876e842f6a5c3c68e3a2 100644
--- a/src/core/SkFontHost.cpp
+++ b/src/core/SkFontHost.cpp
@@ -6,7 +6,7 @@
*/
#include "SkFontLCDConfig.h"
-#include "SkOnce.h"
+#include "SkLazyPtr.h"
static SkFontLCDConfig::LCDOrientation gLCDOrientation = SkFontLCDConfig::kHorizontal_LCDOrientation;
static SkFontLCDConfig::LCDOrder gLCDOrder = SkFontLCDConfig::kRGB_LCDOrder;
@@ -198,19 +198,14 @@ SkTypeface* SkFontMgr::legacyCreateTypeface(const char familyName[],
return this->onLegacyCreateTypeface(familyName, styleBits);
}
-void set_up_default(SkFontMgr** singleton) {
- *singleton = SkFontMgr::Factory();
- // we never want to return NULL
- if (NULL == *singleton) {
- *singleton = SkNEW(SkEmptyFontMgr);
- }
+SkFontMgr* SkFontMgr::CreateDefault() {
+ SkFontMgr* fm = SkFontMgr::Factory();
+ return fm ? fm : SkNEW(SkEmptyFontMgr);
}
SkFontMgr* SkFontMgr::RefDefault() {
- static SkFontMgr* gFM = NULL;
- SK_DECLARE_STATIC_ONCE(once);
- SkOnce(&once, set_up_default, &gFM);
- return SkRef(gFM);
+ SK_DECLARE_STATIC_LAZY_PTR(SkFontMgr, singleton, CreateDefault);
+ return SkRef(singleton.get());
}
//////////////////////////////////////////////////////////////////////////
« no previous file with comments | « include/ports/SkRemotableFontMgr.h ('k') | src/core/SkGlyphCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698