Index: src/core/SkTypeface.cpp |
diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp |
index 3830c46c7af2e5c608310ab9f098ff862ccc0e00..75bb05c2b13cbfac283b36281850603e0206f3c0 100644 |
--- a/src/core/SkTypeface.cpp |
+++ b/src/core/SkTypeface.cpp |
@@ -11,7 +11,7 @@ |
#include "SkFontMgr.h" |
#include "SkMutex.h" |
#include "SkOTTable_OS_2.h" |
-#include "SkOncePtr.h" |
+#include "SkOnce.h" |
#include "SkStream.h" |
#include "SkTypeface.h" |
@@ -79,21 +79,23 @@ |
} |
SK_DECLARE_STATIC_MUTEX(gCreateDefaultMutex); |
-SK_DECLARE_STATIC_ONCE_PTR(SkTypeface, defaults[4]); |
SkTypeface* SkTypeface::GetDefaultTypeface(Style style) { |
+ static SkOnce once[4]; |
+ static SkTypeface* defaults[4]; |
+ |
SkASSERT((int)style < 4); |
- return defaults[style].get([=]{ |
+ once[style]([style] { |
// It is not safe to call FontConfigTypeface::LegacyCreateTypeface concurrently. |
// To be safe, we serialize here with a mutex so only one call to |
// CreateTypeface is happening at any given time. |
// TODO(bungeman, mtklein): This is sad. Make our fontconfig code safe? |
SkAutoMutexAcquire lock(&gCreateDefaultMutex); |
- |
SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault()); |
SkTypeface* t = fm->legacyCreateTypeface(nullptr, SkFontStyle::FromOldStyle(style)); |
- return t ? t : SkEmptyTypeface::Create(); |
+ defaults[style] = t ? t : SkEmptyTypeface::Create(); |
}); |
+ return defaults[style]; |
} |
SkTypeface* SkTypeface::RefDefault(Style style) { |