Chromium Code Reviews| Index: src/ports/SkFontConfigInterface_direct.cpp |
| =================================================================== |
| --- src/ports/SkFontConfigInterface_direct.cpp (revision 14580) |
| +++ src/ports/SkFontConfigInterface_direct.cpp (working copy) |
| @@ -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 @@ |
| SkMutex mutex_; |
| }; |
| +static void create_singleton_direct_interface(SkFontConfigInterface** singleton) { |
| + singleton = new SkFontConfigInterfaceDirect; |
|
mtklein
2014/05/05 21:42:50
Is it not *singleton = new ... ?
bungeman-skia
2014/05/05 21:52:21
Yes, it is. I must remember to check that what is
|
| +} |
| 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; |
| } |