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