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

Unified Diff: src/ports/SkFontConfigInterface_direct.cpp

Issue 269143002: Initialize the SkFontConfigInterface singleton with SkOnce. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: 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 | « no previous file | 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
===================================================================
--- 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;
+}
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;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698