diff options
author | 2014-06-02 08:44:27 -0700 | |
---|---|---|
committer | 2014-06-02 08:44:27 -0700 | |
commit | 78358bf624c7e7c09ffccf638c50870808d884d6 (patch) | |
tree | 71a7dfbae1429f457cd5c31eb4469925991cf245 /src/ports/SkFontConfigInterface_direct.cpp | |
parent | 309e86912445879651d52ebbedb67b4ff3f1516c (diff) |
Port most uses of SkOnce to SkLazyPtr.
BUG=skia:
Committed: http://code.google.com/p/skia/source/detail?r=15006
Committed: http://code.google.com/p/skia/source/detail?r=15014
R=reed@google.com, mtklein@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/304383005
Diffstat (limited to 'src/ports/SkFontConfigInterface_direct.cpp')
-rw-r--r-- | src/ports/SkFontConfigInterface_direct.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/ports/SkFontConfigInterface_direct.cpp b/src/ports/SkFontConfigInterface_direct.cpp index 80ee56e85c..bc3dede40d 100644 --- a/src/ports/SkFontConfigInterface_direct.cpp +++ b/src/ports/SkFontConfigInterface_direct.cpp @@ -15,7 +15,7 @@ #include "SkBuffer.h" #include "SkFontConfigInterface.h" -#include "SkOnce.h" +#include "SkLazyPtr.h" #include "SkStream.h" size_t SkFontConfigInterface::FontIdentity::writeToMemory(void* addr) const { @@ -124,14 +124,13 @@ private: SkMutex mutex_; }; -static void create_singleton_direct_interface(SkFontConfigInterface** singleton) { - *singleton = new SkFontConfigInterfaceDirect; -} +namespace { +SkFontConfigInterface* create_direct() { return SkNEW(SkFontConfigInterfaceDirect); } +} // namespace + SkFontConfigInterface* SkFontConfigInterface::GetSingletonDirectInterface() { - static SkFontConfigInterface* gDirect; - SK_DECLARE_STATIC_ONCE(once); - SkOnce(&once, create_singleton_direct_interface, &gDirect); - return gDirect; + SK_DECLARE_STATIC_LAZY_PTR(SkFontConfigInterface, direct, create_direct); + return direct.get(); } /////////////////////////////////////////////////////////////////////////////// |