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