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

Side by Side Diff: core/src/fpdfapi/fpdf_render/fpdf_render.cpp

Issue 1195363002: Cleanup: Do not check pointers before deleting them, part 2. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: nits Created 5 years, 5 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 | « no previous file | core/src/fpdfapi/fpdf_render/fpdf_render_image.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/fpdfapi/fpdf_module.h" 7 #include "../../../include/fpdfapi/fpdf_module.h"
8 #include "../../../include/fpdfapi/fpdf_render.h" 8 #include "../../../include/fpdfapi/fpdf_render.h"
9 #include "../../../include/fxge/fx_ge.h" 9 #include "../../../include/fxge/fx_ge.h"
10 #include "../fpdf_page/pageint.h" 10 #include "../fpdf_page/pageint.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 m_bLoadMask = FALSE; 195 m_bLoadMask = FALSE;
196 m_pType3Char = NULL; 196 m_pType3Char = NULL;
197 m_T3FillColor = 0; 197 m_T3FillColor = 0;
198 m_pFormResource = NULL; 198 m_pFormResource = NULL;
199 m_pPageResource = NULL; 199 m_pPageResource = NULL;
200 m_curBlend = FXDIB_BLEND_NORMAL; 200 m_curBlend = FXDIB_BLEND_NORMAL;
201 } 201 }
202 202
203 CPDF_RenderStatus::~CPDF_RenderStatus() 203 CPDF_RenderStatus::~CPDF_RenderStatus()
204 { 204 {
205 if (m_pObjectRenderer) { 205 delete m_pObjectRenderer;
206 delete m_pObjectRenderer;
207 }
208 } 206 }
209 207
210 FX_BOOL CPDF_RenderStatus::Initialize(CPDF_RenderContext* pContext, CFX_RenderDe vice* pDevice, 208 FX_BOOL CPDF_RenderStatus::Initialize(CPDF_RenderContext* pContext, CFX_RenderDe vice* pDevice,
211 const CFX_AffineMatrix* pDeviceMatrix, con st CPDF_PageObject* pStopObj, 209 const CFX_AffineMatrix* pDeviceMatrix, con st CPDF_PageObject* pStopObj,
212 const CPDF_RenderStatus* pParentState, con st CPDF_GraphicStates* pInitialStates, 210 const CPDF_RenderStatus* pParentState, con st CPDF_GraphicStates* pInitialStates,
213 const CPDF_RenderOptions* pOptions, int tr ansparency, FX_BOOL bDropObjects, 211 const CPDF_RenderOptions* pOptions, int tr ansparency, FX_BOOL bDropObjects,
214 CPDF_Dictionary* pFormResource, FX_BOOL bS tdCS, CPDF_Type3Char* pType3Char, 212 CPDF_Dictionary* pFormResource, FX_BOOL bS tdCS, CPDF_Type3Char* pType3Char,
215 FX_ARGB fill_color, FX_DWORD GroupFamily, 213 FX_ARGB fill_color, FX_DWORD GroupFamily,
216 FX_BOOL bLoadMask) 214 FX_BOOL bLoadMask)
217 { 215 {
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 delete pTextClippingPath; 656 delete pTextClippingPath;
659 pTextClippingPath = NULL; 657 pTextClippingPath = NULL;
660 } 658 }
661 } else { 659 } else {
662 if (pTextClippingPath == NULL) { 660 if (pTextClippingPath == NULL) {
663 pTextClippingPath = new CFX_PathData; 661 pTextClippingPath = new CFX_PathData;
664 } 662 }
665 ProcessText(pText, pObj2Device, pTextClippingPath); 663 ProcessText(pText, pObj2Device, pTextClippingPath);
666 } 664 }
667 } 665 }
668 if (pTextClippingPath) { 666 delete pTextClippingPath;
669 delete pTextClippingPath;
670 }
671 } 667 }
672 void CPDF_RenderStatus::DrawClipPath(CPDF_ClipPath ClipPath, const CFX_AffineMat rix* pObj2Device) 668 void CPDF_RenderStatus::DrawClipPath(CPDF_ClipPath ClipPath, const CFX_AffineMat rix* pObj2Device)
673 { 669 {
674 if (ClipPath.IsNull()) { 670 if (ClipPath.IsNull()) {
675 return; 671 return;
676 } 672 }
677 int fill_mode = 0; 673 int fill_mode = 0;
678 if (m_Options.m_Flags & RENDER_NOPATHSMOOTH) { 674 if (m_Options.m_Flags & RENDER_NOPATHSMOOTH) {
679 fill_mode |= FXFILL_NOPATHSMOOTH; 675 fill_mode |= FXFILL_NOPATHSMOOTH;
680 } 676 }
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 pTextMask = NULL; 848 pTextMask = NULL;
853 } 849 }
854 if (Transparency & PDFTRANS_GROUP && group_alpha != 1.0f) { 850 if (Transparency & PDFTRANS_GROUP && group_alpha != 1.0f) {
855 bitmap->MultiplyAlpha((int32_t)(group_alpha * 255)); 851 bitmap->MultiplyAlpha((int32_t)(group_alpha * 255));
856 } 852 }
857 Transparency = m_Transparency; 853 Transparency = m_Transparency;
858 if (pPageObj->m_Type == PDFPAGE_FORM) { 854 if (pPageObj->m_Type == PDFPAGE_FORM) {
859 Transparency |= PDFTRANS_GROUP; 855 Transparency |= PDFTRANS_GROUP;
860 } 856 }
861 CompositeDIBitmap(bitmap, rect.left, rect.top, 0, 255, blend_type, Transpare ncy); 857 CompositeDIBitmap(bitmap, rect.left, rect.top, 0, 255, blend_type, Transpare ncy);
862 if (oriDevice) { 858 delete oriDevice;
863 delete oriDevice;
864 }
865 return TRUE; 859 return TRUE;
866 } 860 }
867 CFX_DIBitmap* CPDF_RenderStatus::GetBackdrop(const CPDF_PageObject* pObj, const FX_RECT& rect, int& left, int& top, 861 CFX_DIBitmap* CPDF_RenderStatus::GetBackdrop(const CPDF_PageObject* pObj, const FX_RECT& rect, int& left, int& top,
868 FX_BOOL bBackAlphaRequired) 862 FX_BOOL bBackAlphaRequired)
869 { 863 {
870 FX_RECT bbox = rect; 864 FX_RECT bbox = rect;
871 bbox.Intersect(m_pDevice->GetClipBox()); 865 bbox.Intersect(m_pDevice->GetClipBox());
872 left = bbox.left; 866 left = bbox.left;
873 top = bbox.top; 867 top = bbox.top;
874 CFX_Matrix deviceCTM = m_pDevice->GetCTM(); 868 CFX_Matrix deviceCTM = m_pDevice->GetCTM();
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 } 1258 }
1265 CPDF_DeviceBuffer::CPDF_DeviceBuffer() 1259 CPDF_DeviceBuffer::CPDF_DeviceBuffer()
1266 { 1260 {
1267 m_pBitmap = NULL; 1261 m_pBitmap = NULL;
1268 m_pDevice = NULL; 1262 m_pDevice = NULL;
1269 m_pContext = NULL; 1263 m_pContext = NULL;
1270 m_pObject = NULL; 1264 m_pObject = NULL;
1271 } 1265 }
1272 CPDF_DeviceBuffer::~CPDF_DeviceBuffer() 1266 CPDF_DeviceBuffer::~CPDF_DeviceBuffer()
1273 { 1267 {
1274 if (m_pBitmap) { 1268 delete m_pBitmap;
1275 delete m_pBitmap;
1276 }
1277 } 1269 }
1278 FX_BOOL CPDF_DeviceBuffer::Initialize(CPDF_RenderContext* pContext, CFX_RenderDe vice* pDevice, FX_RECT* pRect, 1270 FX_BOOL CPDF_DeviceBuffer::Initialize(CPDF_RenderContext* pContext, CFX_RenderDe vice* pDevice, FX_RECT* pRect,
1279 const CPDF_PageObject* pObj, int max_dpi) 1271 const CPDF_PageObject* pObj, int max_dpi)
1280 { 1272 {
1281 m_pDevice = pDevice; 1273 m_pDevice = pDevice;
1282 m_pContext = pContext; 1274 m_pContext = pContext;
1283 m_Rect = *pRect; 1275 m_Rect = *pRect;
1284 m_pObject = pObj; 1276 m_pObject = pObj;
1285 m_Matrix.TranslateI(-pRect->left, -pRect->top); 1277 m_Matrix.TranslateI(-pRect->left, -pRect->top);
1286 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ 1278 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1323 buffer.CompositeBitmap(0, 0, buffer.GetWidth(), buffer.GetHeight(), m_pB itmap, 0, 0); 1315 buffer.CompositeBitmap(0, 0, buffer.GetWidth(), buffer.GetHeight(), m_pB itmap, 0, 0);
1324 m_pDevice->StretchDIBits(&buffer, m_Rect.left, m_Rect.top, m_Rect.Width( ), m_Rect.Height()); 1316 m_pDevice->StretchDIBits(&buffer, m_Rect.left, m_Rect.top, m_Rect.Width( ), m_Rect.Height());
1325 } 1317 }
1326 } 1318 }
1327 CPDF_ScaledRenderBuffer::CPDF_ScaledRenderBuffer() 1319 CPDF_ScaledRenderBuffer::CPDF_ScaledRenderBuffer()
1328 { 1320 {
1329 m_pBitmapDevice = NULL; 1321 m_pBitmapDevice = NULL;
1330 } 1322 }
1331 CPDF_ScaledRenderBuffer::~CPDF_ScaledRenderBuffer() 1323 CPDF_ScaledRenderBuffer::~CPDF_ScaledRenderBuffer()
1332 { 1324 {
1333 if (m_pBitmapDevice) { 1325 delete m_pBitmapDevice;
1334 delete m_pBitmapDevice;
1335 }
1336 } 1326 }
1337 #define _FPDFAPI_IMAGESIZE_LIMIT_ (30 * 1024 * 1024) 1327 #define _FPDFAPI_IMAGESIZE_LIMIT_ (30 * 1024 * 1024)
1338 FX_BOOL CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext, CFX_Re nderDevice* pDevice, FX_RECT* pRect, 1328 FX_BOOL CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext, CFX_Re nderDevice* pDevice, FX_RECT* pRect,
1339 const CPDF_PageObject* pObj, const CPDF_RenderOptions *pOptions, int max _dpi) 1329 const CPDF_PageObject* pObj, const CPDF_RenderOptions *pOptions, int max _dpi)
1340 { 1330 {
1341 FXSYS_assert(pRect != NULL); 1331 FXSYS_assert(pRect != NULL);
1342 m_pDevice = pDevice; 1332 m_pDevice = pDevice;
1343 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_GET_BITS) { 1333 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_GET_BITS) {
1344 return TRUE; 1334 return TRUE;
1345 } 1335 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 CPDF_ContentMarkItem& item = pData->GetItem(i); 1391 CPDF_ContentMarkItem& item = pData->GetItem(i);
1402 if (item.GetName() == FX_BSTRC("OC") && item.GetParamType() == CPDF_Cont entMarkItem::PropertiesDict) { 1392 if (item.GetName() == FX_BSTRC("OC") && item.GetParamType() == CPDF_Cont entMarkItem::PropertiesDict) {
1403 CPDF_Dictionary* pOCG = (CPDF_Dictionary*)item.GetParam(); 1393 CPDF_Dictionary* pOCG = (CPDF_Dictionary*)item.GetParam();
1404 if (!CheckOCGVisible(pOCG)) { 1394 if (!CheckOCGVisible(pOCG)) {
1405 return FALSE; 1395 return FALSE;
1406 } 1396 }
1407 } 1397 }
1408 } 1398 }
1409 return TRUE; 1399 return TRUE;
1410 } 1400 }
OLDNEW
« no previous file with comments | « no previous file | core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698