Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Side by Side Diff: core/fxge/ge/fx_ge.cpp

Issue 2217663002: Refactor fx_ge part 1 (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fxge/ge/cfx_gemodule.cpp ('k') | core/fxge/ge/fx_ge_font.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « core/fxge/ge/cfx_gemodule.cpp ('k') | core/fxge/ge/fx_ge_font.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698