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