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

Unified Diff: core/fxge/ge/fx_ge.cpp

Issue 2154843002: Clean up singleton implementation (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 5 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: core/fxge/ge/fx_ge.cpp
diff --git a/core/fxge/ge/fx_ge.cpp b/core/fxge/ge/fx_ge.cpp
index 4ebf812f127040f0648a8d8756ab39509d3d178b..f1b7e81717da14e6f8ff296a50d8098a4d6b6e3f 100644
--- a/core/fxge/ge/fx_ge.cpp
+++ b/core/fxge/ge/fx_ge.cpp
@@ -8,19 +8,15 @@
#include "core/fxge/ge/fx_text_int.h"
-static CFX_GEModule* g_pGEModule = nullptr;
+CFX_GEModule* CFX_GEModule::m_pGEModule = nullptr;
-CFX_GEModule::CFX_GEModule(const char** pUserFontPaths,
- CCodec_ModuleMgr* pCodecModule)
+CFX_GEModule::CFX_GEModule()
: m_FTLibrary(nullptr),
m_pFontCache(nullptr),
m_pFontMgr(new CFX_FontMgr),
- m_pCodecModule(pCodecModule),
+ m_pCodecModule(nullptr),
m_pPlatformData(nullptr),
- m_pUserFontPaths(pUserFontPaths) {
- InitPlatform();
- SetTextGamma(2.2f);
-}
+ m_pUserFontPaths(nullptr) {}
CFX_GEModule::~CFX_GEModule() {
delete m_pFontCache;
@@ -28,22 +24,26 @@ CFX_GEModule::~CFX_GEModule() {
}
// static
-void CFX_GEModule::Create(const char** userFontPaths,
- CCodec_ModuleMgr* pCodecModule) {
- ASSERT(!g_pGEModule);
- g_pGEModule = new CFX_GEModule(userFontPaths, pCodecModule);
-}
-
-// static
CFX_GEModule* CFX_GEModule::Get() {
- return g_pGEModule;
+ if (!m_pGEModule)
+ m_pGEModule = new CFX_GEModule();
+ return m_pGEModule;
}
// static
void CFX_GEModule::Destroy() {
- ASSERT(g_pGEModule);
- delete g_pGEModule;
- g_pGEModule = nullptr;
+ ASSERT(m_pGEModule);
+ delete m_pGEModule;
+ m_pGEModule = nullptr;
+}
+
+void CFX_GEModule::Init(const char** userFontPaths,
+ CCodec_ModuleMgr* pCodecModule) {
+ ASSERT(m_pGEModule);
+ m_pCodecModule = pCodecModule;
+ m_pUserFontPaths = userFontPaths;
+ InitPlatform();
+ SetTextGamma(2.2f);
}
CFX_FontCache* CFX_GEModule::GetFontCache() {

Powered by Google App Engine
This is Rietveld 408576698