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

Unified Diff: src/ports/SkFontMgr_FontConfigInterface_factory.cpp

Issue 2346333002: Split SkFontConfigInterface globals and factory. (Closed)
Patch Set: Created 4 years, 3 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
Index: src/ports/SkFontMgr_FontConfigInterface_factory.cpp
diff --git a/src/ports/SkFontMgr_FontConfigInterface_factory.cpp b/src/ports/SkFontMgr_FontConfigInterface_factory.cpp
index 0ffc26116f9880a86bf8c6ba43400eef2c76cf49..92ed3b4e517fae9f7b89adc25bfdf4da110c5163 100644
--- a/src/ports/SkFontMgr_FontConfigInterface_factory.cpp
+++ b/src/ports/SkFontMgr_FontConfigInterface_factory.cpp
@@ -7,38 +7,17 @@
#include "SkFontConfigInterface.h"
#include "SkFontMgr.h"
-#include "SkMutex.h"
-#include "SkRefCnt.h"
+#include "SkFontMgr_FontConfigInterface.h"
-SK_DECLARE_STATIC_MUTEX(gFontConfigInterfaceMutex);
-static SkFontConfigInterface* gFontConfigInterface;
-
-SkFontConfigInterface* SkFontConfigInterface::RefGlobal() {
- SkAutoMutexAcquire ac(gFontConfigInterfaceMutex);
-
- return SkSafeRef(gFontConfigInterface);
-}
-
-SkFontConfigInterface* SkFontConfigInterface::SetGlobal(SkFontConfigInterface* fc) {
- SkAutoMutexAcquire ac(gFontConfigInterfaceMutex);
-
- SkRefCnt_SafeAssign(gFontConfigInterface, fc);
- return fc;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-static SkFontConfigInterface* init_FCI() {
- SkAutoMutexAcquire ac(gFontConfigInterfaceMutex);
-
- if (gFontConfigInterface) {
- return SkRef(gFontConfigInterface);
- }
- gFontConfigInterface = SkRef(SkFontConfigInterface::GetSingletonDirectInterface());
- return gFontConfigInterface;
-}
+#ifdef SK_ADDING_src_ports_SkFontConfigInterface_cpp
+// The code previously here is moving to SkFontConfigInterface.cpp
+#include "SkFontConfigInterface.cpp"
+#endif
SkFontMgr* SkFontMgr::Factory() {
- SkFontConfigInterface* fci = init_FCI();
- return fci ? SkFontMgr_New_FCI(fci) : nullptr;
+ sk_sp<SkFontConfigInterface> fci(SkFontConfigInterface::RefGlobal());
+ if (!fci) {
+ return nullptr;
+ }
+ return SkFontMgr_New_FCI(std::move(fci));
}
« include/ports/SkFontConfigInterface.h ('K') | « src/ports/SkFontMgr_FontConfigInterface.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698