OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "../../../include/fxge/fx_ge.h" | 7 #include "../../../include/fxge/fx_ge.h" |
8 #include "text_int.h" | 8 #include "text_int.h" |
9 static CFX_GEModule* g_pGEModule = NULL; | 9 static CFX_GEModule* g_pGEModule = NULL; |
10 CFX_GEModule::CFX_GEModule() { | 10 CFX_GEModule::CFX_GEModule(const char** pUserFontPaths) { |
11 m_pFontCache = NULL; | 11 m_pFontCache = NULL; |
12 m_pFontMgr = NULL; | 12 m_pFontMgr = NULL; |
13 m_FTLibrary = NULL; | 13 m_FTLibrary = NULL; |
14 m_pCodecModule = NULL; | 14 m_pCodecModule = NULL; |
15 m_pPlatformData = NULL; | 15 m_pPlatformData = NULL; |
| 16 m_pUserFontPaths = pUserFontPaths; |
16 } | 17 } |
17 CFX_GEModule::~CFX_GEModule() { | 18 CFX_GEModule::~CFX_GEModule() { |
18 delete m_pFontCache; | 19 delete m_pFontCache; |
19 m_pFontCache = NULL; | 20 m_pFontCache = NULL; |
20 delete m_pFontMgr; | 21 delete m_pFontMgr; |
21 m_pFontMgr = NULL; | 22 m_pFontMgr = NULL; |
22 DestroyPlatform(); | 23 DestroyPlatform(); |
23 } | 24 } |
24 CFX_GEModule* CFX_GEModule::Get() { | 25 CFX_GEModule* CFX_GEModule::Get() { |
25 return g_pGEModule; | 26 return g_pGEModule; |
26 } | 27 } |
27 void CFX_GEModule::Create() { | 28 void CFX_GEModule::Create(const char** userFontPaths) { |
28 g_pGEModule = new CFX_GEModule; | 29 g_pGEModule = new CFX_GEModule(userFontPaths); |
29 if (!g_pGEModule) { | |
30 return; | |
31 } | |
32 g_pGEModule->m_pFontMgr = new CFX_FontMgr; | 30 g_pGEModule->m_pFontMgr = new CFX_FontMgr; |
33 g_pGEModule->InitPlatform(); | 31 g_pGEModule->InitPlatform(); |
34 g_pGEModule->SetTextGamma(2.2f); | 32 g_pGEModule->SetTextGamma(2.2f); |
35 } | 33 } |
36 void CFX_GEModule::Use(CFX_GEModule* pModule) { | 34 void CFX_GEModule::Use(CFX_GEModule* pModule) { |
37 g_pGEModule = pModule; | 35 g_pGEModule = pModule; |
38 } | 36 } |
39 void CFX_GEModule::Destroy() { | 37 void CFX_GEModule::Destroy() { |
40 delete g_pGEModule; | 38 delete g_pGEModule; |
41 g_pGEModule = NULL; | 39 g_pGEModule = NULL; |
42 } | 40 } |
43 CFX_FontCache* CFX_GEModule::GetFontCache() { | 41 CFX_FontCache* CFX_GEModule::GetFontCache() { |
44 if (m_pFontCache == NULL) { | 42 if (m_pFontCache == NULL) { |
45 m_pFontCache = new CFX_FontCache(); | 43 m_pFontCache = new CFX_FontCache(); |
46 } | 44 } |
47 return m_pFontCache; | 45 return m_pFontCache; |
48 } | 46 } |
49 void CFX_GEModule::SetTextGamma(FX_FLOAT gammaValue) { | 47 void CFX_GEModule::SetTextGamma(FX_FLOAT gammaValue) { |
50 gammaValue /= 2.2f; | 48 gammaValue /= 2.2f; |
51 int i = 0; | 49 int i = 0; |
52 while (i < 256) { | 50 while (i < 256) { |
53 m_GammaValue[i] = | 51 m_GammaValue[i] = |
54 (uint8_t)(FXSYS_pow((FX_FLOAT)i / 255, gammaValue) * 255.0f + 0.5f); | 52 (uint8_t)(FXSYS_pow((FX_FLOAT)i / 255, gammaValue) * 255.0f + 0.5f); |
55 i++; | 53 i++; |
56 } | 54 } |
57 } | 55 } |
58 const uint8_t* CFX_GEModule::GetTextGammaTable() { | 56 const uint8_t* CFX_GEModule::GetTextGammaTable() { |
59 return m_GammaValue; | 57 return m_GammaValue; |
60 } | 58 } |
OLD | NEW |