aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports
diff options
context:
space:
mode:
Diffstat (limited to 'src/ports')
-rw-r--r--src/ports/SkFontConfigInterface_direct.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/ports/SkFontConfigInterface_direct.cpp b/src/ports/SkFontConfigInterface_direct.cpp
index 13993f10c0..80ee56e85c 100644
--- a/src/ports/SkFontConfigInterface_direct.cpp
+++ b/src/ports/SkFontConfigInterface_direct.cpp
@@ -15,6 +15,7 @@
#include "SkBuffer.h"
#include "SkFontConfigInterface.h"
+#include "SkOnce.h"
#include "SkStream.h"
size_t SkFontConfigInterface::FontIdentity::writeToMemory(void* addr) const {
@@ -123,16 +124,13 @@ private:
SkMutex mutex_;
};
+static void create_singleton_direct_interface(SkFontConfigInterface** singleton) {
+ *singleton = new SkFontConfigInterfaceDirect;
+}
SkFontConfigInterface* SkFontConfigInterface::GetSingletonDirectInterface() {
static SkFontConfigInterface* gDirect;
- if (NULL == gDirect) {
- static SkMutex gMutex;
- SkAutoMutexAcquire ac(gMutex);
-
- if (NULL == gDirect) {
- gDirect = new SkFontConfigInterfaceDirect;
- }
- }
+ SK_DECLARE_STATIC_ONCE(once);
+ SkOnce(&once, create_singleton_direct_interface, &gDirect);
return gDirect;
}