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

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

Issue 1192743004: Cleanup: Do not check pointers before deleting them. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 5 years, 6 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/src/fxge/dib/fx_dib_main.cpp ('k') | core/src/fxge/ge/fx_ge_device.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 {
12 m_pFontCache = NULL; 12 m_pFontCache = NULL;
13 m_pFontMgr = NULL; 13 m_pFontMgr = NULL;
14 m_FTLibrary = NULL; 14 m_FTLibrary = NULL;
15 m_pCodecModule = NULL; 15 m_pCodecModule = NULL;
16 m_pPlatformData = NULL; 16 m_pPlatformData = NULL;
17 } 17 }
18 CFX_GEModule::~CFX_GEModule() 18 CFX_GEModule::~CFX_GEModule()
19 { 19 {
20 if (m_pFontCache) { 20 delete m_pFontCache;
21 delete m_pFontCache;
22 }
23 m_pFontCache = NULL; 21 m_pFontCache = NULL;
24 if (m_pFontMgr) { 22 delete m_pFontMgr;
25 delete m_pFontMgr;
26 }
27 m_pFontMgr = NULL; 23 m_pFontMgr = NULL;
28 DestroyPlatform(); 24 DestroyPlatform();
29 } 25 }
30 CFX_GEModule* CFX_GEModule::Get() 26 CFX_GEModule* CFX_GEModule::Get()
31 { 27 {
32 return g_pGEModule; 28 return g_pGEModule;
33 } 29 }
34 void CFX_GEModule::Create() 30 void CFX_GEModule::Create()
35 { 31 {
36 g_pGEModule = new CFX_GEModule; 32 g_pGEModule = new CFX_GEModule;
37 g_pGEModule->m_pFontMgr = new CFX_FontMgr; 33 g_pGEModule->m_pFontMgr = new CFX_FontMgr;
38 g_pGEModule->InitPlatform(); 34 g_pGEModule->InitPlatform();
39 g_pGEModule->SetTextGamma(2.2f); 35 g_pGEModule->SetTextGamma(2.2f);
40 } 36 }
41 void CFX_GEModule::Use(CFX_GEModule* pModule) 37 void CFX_GEModule::Use(CFX_GEModule* pModule)
42 { 38 {
43 g_pGEModule = pModule; 39 g_pGEModule = pModule;
44 } 40 }
45 void CFX_GEModule::Destroy() 41 void CFX_GEModule::Destroy()
46 { 42 {
47 if (g_pGEModule) { 43 delete g_pGEModule;
48 delete g_pGEModule;
49 }
50 g_pGEModule = NULL; 44 g_pGEModule = NULL;
51 } 45 }
52 CFX_FontCache* CFX_GEModule::GetFontCache() 46 CFX_FontCache* CFX_GEModule::GetFontCache()
53 { 47 {
54 if (m_pFontCache == NULL) { 48 if (m_pFontCache == NULL) {
55 m_pFontCache = new CFX_FontCache(); 49 m_pFontCache = new CFX_FontCache();
56 } 50 }
57 return m_pFontCache; 51 return m_pFontCache;
58 } 52 }
59 void CFX_GEModule::SetTextGamma(FX_FLOAT gammaValue) 53 void CFX_GEModule::SetTextGamma(FX_FLOAT gammaValue)
60 { 54 {
61 gammaValue /= 2.2f; 55 gammaValue /= 2.2f;
62 int i = 0; 56 int i = 0;
63 while (i < 256) { 57 while (i < 256) {
64 m_GammaValue[i] = (uint8_t)(FXSYS_pow((FX_FLOAT)i / 255, gammaValue) * 2 55.0f + 0.5f); 58 m_GammaValue[i] = (uint8_t)(FXSYS_pow((FX_FLOAT)i / 255, gammaValue) * 2 55.0f + 0.5f);
65 i++; 59 i++;
66 } 60 }
67 } 61 }
68 const uint8_t* CFX_GEModule::GetTextGammaTable() 62 const uint8_t* CFX_GEModule::GetTextGammaTable()
69 { 63 {
70 return m_GammaValue; 64 return m_GammaValue;
71 } 65 }
72 void CFX_GEModule::SetExtFontMapper(IFX_FontMapper* pFontMapper) 66 void CFX_GEModule::SetExtFontMapper(IFX_FontMapper* pFontMapper)
73 { 67 {
74 GetFontMgr()->m_pExtMapper = pFontMapper; 68 GetFontMgr()->m_pExtMapper = pFontMapper;
75 pFontMapper->m_pFontMgr = m_pFontMgr; 69 pFontMapper->m_pFontMgr = m_pFontMgr;
76 } 70 }
OLDNEW
« no previous file with comments | « core/src/fxge/dib/fx_dib_main.cpp ('k') | core/src/fxge/ge/fx_ge_device.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698