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 "core/fxge/include/fx_ge.h" | 7 #include "core/fxge/include/fx_ge.h" |
8 | 8 |
9 #include "core/fxge/ge/fx_text_int.h" | 9 #include "core/fxge/ge/fx_text_int.h" |
10 | 10 |
11 static CFX_GEModule* g_pGEModule = NULL; | 11 static CFX_GEModule* g_pGEModule = nullptr; |
12 CFX_GEModule::CFX_GEModule(const char** pUserFontPaths) { | 12 CFX_GEModule::CFX_GEModule(const char** pUserFontPaths) { |
13 m_pFontCache = NULL; | 13 m_pFontCache = nullptr; |
14 m_pFontMgr = NULL; | 14 m_pFontMgr = nullptr; |
15 m_FTLibrary = NULL; | 15 m_FTLibrary = nullptr; |
16 m_pCodecModule = NULL; | 16 m_pCodecModule = nullptr; |
17 m_pPlatformData = NULL; | 17 m_pPlatformData = nullptr; |
18 m_pUserFontPaths = pUserFontPaths; | 18 m_pUserFontPaths = pUserFontPaths; |
19 } | 19 } |
20 CFX_GEModule::~CFX_GEModule() { | 20 CFX_GEModule::~CFX_GEModule() { |
21 delete m_pFontCache; | 21 delete m_pFontCache; |
22 m_pFontCache = NULL; | 22 m_pFontCache = nullptr; |
23 delete m_pFontMgr; | 23 delete m_pFontMgr; |
24 m_pFontMgr = NULL; | 24 m_pFontMgr = nullptr; |
25 DestroyPlatform(); | 25 DestroyPlatform(); |
26 } | 26 } |
27 CFX_GEModule* CFX_GEModule::Get() { | 27 CFX_GEModule* CFX_GEModule::Get() { |
28 return g_pGEModule; | 28 return g_pGEModule; |
29 } | 29 } |
30 void CFX_GEModule::Create(const char** userFontPaths) { | 30 void CFX_GEModule::Create(const char** userFontPaths) { |
31 g_pGEModule = new CFX_GEModule(userFontPaths); | 31 g_pGEModule = new CFX_GEModule(userFontPaths); |
32 g_pGEModule->m_pFontMgr = new CFX_FontMgr; | 32 g_pGEModule->m_pFontMgr = new CFX_FontMgr; |
33 g_pGEModule->InitPlatform(); | 33 g_pGEModule->InitPlatform(); |
34 g_pGEModule->SetTextGamma(2.2f); | 34 g_pGEModule->SetTextGamma(2.2f); |
35 } | 35 } |
36 void CFX_GEModule::Use(CFX_GEModule* pModule) { | 36 void CFX_GEModule::Use(CFX_GEModule* pModule) { |
37 g_pGEModule = pModule; | 37 g_pGEModule = pModule; |
38 } | 38 } |
39 void CFX_GEModule::Destroy() { | 39 void CFX_GEModule::Destroy() { |
40 delete g_pGEModule; | 40 delete g_pGEModule; |
41 g_pGEModule = NULL; | 41 g_pGEModule = nullptr; |
42 } | 42 } |
43 CFX_FontCache* CFX_GEModule::GetFontCache() { | 43 CFX_FontCache* CFX_GEModule::GetFontCache() { |
44 if (!m_pFontCache) { | 44 if (!m_pFontCache) { |
45 m_pFontCache = new CFX_FontCache(); | 45 m_pFontCache = new CFX_FontCache(); |
46 } | 46 } |
47 return m_pFontCache; | 47 return m_pFontCache; |
48 } | 48 } |
49 void CFX_GEModule::SetTextGamma(FX_FLOAT gammaValue) { | 49 void CFX_GEModule::SetTextGamma(FX_FLOAT gammaValue) { |
50 gammaValue /= 2.2f; | 50 gammaValue /= 2.2f; |
51 int i = 0; | 51 int i = 0; |
52 while (i < 256) { | 52 while (i < 256) { |
53 m_GammaValue[i] = | 53 m_GammaValue[i] = |
54 (uint8_t)(FXSYS_pow((FX_FLOAT)i / 255, gammaValue) * 255.0f + 0.5f); | 54 (uint8_t)(FXSYS_pow((FX_FLOAT)i / 255, gammaValue) * 255.0f + 0.5f); |
55 i++; | 55 i++; |
56 } | 56 } |
57 } | 57 } |
58 const uint8_t* CFX_GEModule::GetTextGammaTable() { | 58 const uint8_t* CFX_GEModule::GetTextGammaTable() { |
59 return m_GammaValue; | 59 return m_GammaValue; |
60 } | 60 } |
OLD | NEW |