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()); |
} |
////////////////////////////////////////////////////////////////////////// |