diff options
author | bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-05 22:33:45 +0000 |
---|---|---|
committer | bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-05 22:33:45 +0000 |
commit | 31d179de5aa462f943a67645f6107a2ad4685c15 (patch) | |
tree | 61aa976455ebce09ba241baff59b4160b246b8e3 | |
parent | 63ca47a65e11bd75517bba10e336341cddadab52 (diff) | |
download | src-31d179de5aa462f943a67645f6107a2ad4685c15.tar.gz |
Initialize the SkFontConfigInterface singleton with SkOnce.
BUG=chromium:369257
R=mtklein@google.com
Review URL: https://codereview.chromium.org/269143002
git-svn-id: http://skia.googlecode.com/svn/trunk/src@14583 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | ports/SkFontConfigInterface_direct.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/ports/SkFontConfigInterface_direct.cpp b/ports/SkFontConfigInterface_direct.cpp index 13993f10..80ee56e8 100644 --- a/ports/SkFontConfigInterface_direct.cpp +++ b/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; } |