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