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

Unified Diff: src/core/SkFontHost.cpp

Issue 306063004: Revert of Port most uses of SkOnce to SkLazyPtr. (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 | « 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 a16a8c42e02956274090876e842f6a5c3c68e3a2..9e7eeb182d1790ba9f362fd9c2bcbcdaf91f150a 100644
--- a/src/core/SkFontHost.cpp
+++ b/src/core/SkFontHost.cpp
@@ -6,7 +6,7 @@
*/
#include "SkFontLCDConfig.h"
-#include "SkLazyPtr.h"
+#include "SkOnce.h"
static SkFontLCDConfig::LCDOrientation gLCDOrientation = SkFontLCDConfig::kHorizontal_LCDOrientation;
static SkFontLCDConfig::LCDOrder gLCDOrder = SkFontLCDConfig::kRGB_LCDOrder;
@@ -198,14 +198,19 @@
return this->onLegacyCreateTypeface(familyName, styleBits);
}
-SkFontMgr* SkFontMgr::CreateDefault() {
- SkFontMgr* fm = SkFontMgr::Factory();
- return fm ? fm : SkNEW(SkEmptyFontMgr);
+void set_up_default(SkFontMgr** singleton) {
+ *singleton = SkFontMgr::Factory();
+ // we never want to return NULL
+ if (NULL == *singleton) {
+ *singleton = SkNEW(SkEmptyFontMgr);
+ }
}
SkFontMgr* SkFontMgr::RefDefault() {
- SK_DECLARE_STATIC_LAZY_PTR(SkFontMgr, singleton, CreateDefault);
- return SkRef(singleton.get());
+ static SkFontMgr* gFM = NULL;
+ SK_DECLARE_STATIC_ONCE(once);
+ SkOnce(&once, set_up_default, &gFM);
+ return SkRef(gFM);
}
//////////////////////////////////////////////////////////////////////////
« 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