Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(759)

Unified Diff: src/ports/SkFontConfigInterface_direct.cpp

Issue 304383005: Port most uses of SkOnce to SkLazyPtr. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add mutex Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/lazy/SkDiscardableMemoryPool.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontConfigInterface_direct.cpp
diff --git a/src/ports/SkFontConfigInterface_direct.cpp b/src/ports/SkFontConfigInterface_direct.cpp
index 80ee56e85c6dbffa921d697e9c8709809a45a95f..bc3dede40d24c86748eb22cdef5bb649b39a66d3 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();
}
///////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « src/lazy/SkDiscardableMemoryPool.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698