1 // Copyright 2016 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #include "core/fxge/cfx_gemodule.h" 8 9 #include "core/fxge/cfx_folderfontinfo.h" 10 #include "core/fxge/cfx_fontcache.h" 11 #include "core/fxge/cfx_fontmgr.h" 12 #include "third_party/base/ptr_util.h" 13 14 namespace { 15 16 CFX_GEModule* g_pGEModule = nullptr; 17 18 } // namespace 19 CFX_GEModule(const char ** pUserFontPaths)20CFX_GEModule::CFX_GEModule(const char** pUserFontPaths) 21 : m_pPlatform(PlatformIface::Create()), 22 m_pFontMgr(pdfium::MakeUnique<CFX_FontMgr>()), 23 m_pFontCache(pdfium::MakeUnique<CFX_FontCache>()), 24 m_pUserFontPaths(pUserFontPaths) {} 25 26 CFX_GEModule::~CFX_GEModule() = default; 27 28 // static Create(const char ** pUserFontPaths)29void CFX_GEModule::Create(const char** pUserFontPaths) { 30 ASSERT(!g_pGEModule); 31 g_pGEModule = new CFX_GEModule(pUserFontPaths); 32 g_pGEModule->m_pPlatform->Init(); 33 } 34 35 // static Destroy()36void CFX_GEModule::Destroy() { 37 ASSERT(g_pGEModule); 38 delete g_pGEModule; 39 g_pGEModule = nullptr; 40 } 41 42 // static Get()43CFX_GEModule* CFX_GEModule::Get() { 44 ASSERT(g_pGEModule); 45 return g_pGEModule; 46 } 47