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

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

Issue 1512763013: Get rid of most instance of 'foo != NULL' (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: nits Created 5 years 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
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 "render_int.h" 7 #include "render_int.h"
8 8
9 #include "core/include/fpdfapi/fpdf_module.h" 9 #include "core/include/fpdfapi/fpdf_module.h"
10 #include "core/include/fpdfapi/fpdf_render.h" 10 #include "core/include/fpdfapi/fpdf_render.h"
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 FX_RECT rect; 427 FX_RECT rect;
428 if (GetObjectClippedRect(pObj, pObj2Device, FALSE, rect)) { 428 if (GetObjectClippedRect(pObj, pObj2Device, FALSE, rect)) {
429 return; 429 return;
430 } 430 }
431 int res = 300; 431 int res = 300;
432 if (pObj->m_Type == PDFPAGE_IMAGE && 432 if (pObj->m_Type == PDFPAGE_IMAGE &&
433 m_pDevice->GetDeviceCaps(FXDC_DEVICE_CLASS) == FXDC_PRINTER) { 433 m_pDevice->GetDeviceCaps(FXDC_DEVICE_CLASS) == FXDC_PRINTER) {
434 res = 0; 434 res = 0;
435 } 435 }
436 CPDF_ScaledRenderBuffer buffer; 436 CPDF_ScaledRenderBuffer buffer;
437 if (!buffer.Initialize(m_pContext, m_pDevice, &rect, pObj, &m_Options, res)) { 437 if (!buffer.Initialize(m_pContext, m_pDevice, rect, pObj, &m_Options, res)) {
438 return; 438 return;
439 } 439 }
440 CFX_Matrix matrix = *pObj2Device; 440 CFX_Matrix matrix = *pObj2Device;
441 matrix.Concat(*buffer.GetMatrix()); 441 matrix.Concat(*buffer.GetMatrix());
442 GetScaledMatrix(matrix); 442 GetScaledMatrix(matrix);
443 CPDF_Dictionary* pFormResource = NULL; 443 CPDF_Dictionary* pFormResource = NULL;
444 if (pObj->m_Type == PDFPAGE_FORM) { 444 if (pObj->m_Type == PDFPAGE_FORM) {
445 CPDF_FormObject* pFormObj = (CPDF_FormObject*)pObj; 445 CPDF_FormObject* pFormObj = (CPDF_FormObject*)pObj;
446 if (pFormObj->m_pForm && pFormObj->m_pForm->m_pFormDict) { 446 if (pFormObj->m_pForm && pFormObj->m_pForm->m_pFormDict) {
447 pFormResource = pFormObj->m_pForm->m_pFormDict->GetDict("Resources"); 447 pFormResource = pFormObj->m_pForm->m_pFormDict->GetDict("Resources");
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 } 530 }
531 CFX_GraphStateData graphState(*pPathObj->m_GraphState); 531 CFX_GraphStateData graphState(*pPathObj->m_GraphState);
532 if (m_Options.m_Flags & RENDER_THINLINE) { 532 if (m_Options.m_Flags & RENDER_THINLINE) {
533 graphState.m_LineWidth = 0; 533 graphState.m_LineWidth = 0;
534 } 534 }
535 return m_pDevice->DrawPath(pPathObj->m_Path, &path_matrix, &graphState, 535 return m_pDevice->DrawPath(pPathObj->m_Path, &path_matrix, &graphState,
536 fill_argb, stroke_argb, FillType, 0, NULL, 536 fill_argb, stroke_argb, FillType, 0, NULL,
537 m_curBlend); 537 m_curBlend);
538 } 538 }
539 CPDF_TransferFunc* CPDF_RenderStatus::GetTransferFunc(CPDF_Object* pObj) const { 539 CPDF_TransferFunc* CPDF_RenderStatus::GetTransferFunc(CPDF_Object* pObj) const {
540 ASSERT(pObj != NULL); 540 ASSERT(pObj);
541 CPDF_DocRenderData* pDocCache = m_pContext->m_pDocument->GetRenderData(); 541 CPDF_DocRenderData* pDocCache = m_pContext->m_pDocument->GetRenderData();
542 if (!pDocCache) { 542 return pDocCache ? pDocCache->GetTransferFunc(pObj) : nullptr;
543 return NULL;
544 }
545 return pDocCache->GetTransferFunc(pObj);
546 } 543 }
547 FX_ARGB CPDF_RenderStatus::GetFillArgb(const CPDF_PageObject* pObj, 544 FX_ARGB CPDF_RenderStatus::GetFillArgb(const CPDF_PageObject* pObj,
548 FX_BOOL bType3) const { 545 FX_BOOL bType3) const {
549 CPDF_ColorStateData* pColorData = 546 CPDF_ColorStateData* pColorData =
550 (CPDF_ColorStateData*)(const CPDF_ColorStateData*)pObj->m_ColorState; 547 (CPDF_ColorStateData*)(const CPDF_ColorStateData*)pObj->m_ColorState;
551 if (m_pType3Char && !bType3 && 548 if (m_pType3Char && !bType3 &&
552 (!m_pType3Char->m_bColored || 549 (!m_pType3Char->m_bColored ||
553 (m_pType3Char->m_bColored && 550 (m_pType3Char->m_bColored &&
554 (!pColorData || pColorData->m_FillColor.IsNull())))) { 551 (!pColorData || pColorData->m_FillColor.IsNull())))) {
555 return m_T3FillColor; 552 return m_T3FillColor;
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 } 1333 }
1337 } 1334 }
1338 1335
1339 CPDF_ScaledRenderBuffer::CPDF_ScaledRenderBuffer() {} 1336 CPDF_ScaledRenderBuffer::CPDF_ScaledRenderBuffer() {}
1340 1337
1341 CPDF_ScaledRenderBuffer::~CPDF_ScaledRenderBuffer() {} 1338 CPDF_ScaledRenderBuffer::~CPDF_ScaledRenderBuffer() {}
1342 1339
1343 #define _FPDFAPI_IMAGESIZE_LIMIT_ (30 * 1024 * 1024) 1340 #define _FPDFAPI_IMAGESIZE_LIMIT_ (30 * 1024 * 1024)
1344 FX_BOOL CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext, 1341 FX_BOOL CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext,
1345 CFX_RenderDevice* pDevice, 1342 CFX_RenderDevice* pDevice,
1346 FX_RECT* pRect, 1343 const FX_RECT& pRect,
1347 const CPDF_PageObject* pObj, 1344 const CPDF_PageObject* pObj,
1348 const CPDF_RenderOptions* pOptions, 1345 const CPDF_RenderOptions* pOptions,
1349 int max_dpi) { 1346 int max_dpi) {
1350 FXSYS_assert(pRect != NULL);
1351 m_pDevice = pDevice; 1347 m_pDevice = pDevice;
1352 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_GET_BITS) { 1348 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_GET_BITS) {
1353 return TRUE; 1349 return TRUE;
1354 } 1350 }
1355 m_pContext = pContext; 1351 m_pContext = pContext;
1356 m_Rect = *pRect; 1352 m_Rect = pRect;
1357 m_pObject = pObj; 1353 m_pObject = pObj;
1358 m_Matrix.TranslateI(-pRect->left, -pRect->top); 1354 m_Matrix.TranslateI(-pRect.left, -pRect.top);
1359 int horz_size = pDevice->GetDeviceCaps(FXDC_HORZ_SIZE); 1355 int horz_size = pDevice->GetDeviceCaps(FXDC_HORZ_SIZE);
1360 int vert_size = pDevice->GetDeviceCaps(FXDC_VERT_SIZE); 1356 int vert_size = pDevice->GetDeviceCaps(FXDC_VERT_SIZE);
1361 if (horz_size && vert_size && max_dpi) { 1357 if (horz_size && vert_size && max_dpi) {
1362 int dpih = 1358 int dpih =
1363 pDevice->GetDeviceCaps(FXDC_PIXEL_WIDTH) * 254 / (horz_size * 10); 1359 pDevice->GetDeviceCaps(FXDC_PIXEL_WIDTH) * 254 / (horz_size * 10);
1364 int dpiv = 1360 int dpiv =
1365 pDevice->GetDeviceCaps(FXDC_PIXEL_HEIGHT) * 254 / (vert_size * 10); 1361 pDevice->GetDeviceCaps(FXDC_PIXEL_HEIGHT) * 254 / (vert_size * 10);
1366 if (dpih > max_dpi) { 1362 if (dpih > max_dpi) {
1367 m_Matrix.Scale((FX_FLOAT)(max_dpi) / dpih, 1.0f); 1363 m_Matrix.Scale((FX_FLOAT)(max_dpi) / dpih, 1.0f);
1368 } 1364 }
1369 if (dpiv > max_dpi) { 1365 if (dpiv > max_dpi) {
1370 m_Matrix.Scale(1.0f, (FX_FLOAT)(max_dpi) / (FX_FLOAT)dpiv); 1366 m_Matrix.Scale(1.0f, (FX_FLOAT)(max_dpi) / (FX_FLOAT)dpiv);
1371 } 1367 }
1372 } 1368 }
1373 m_pBitmapDevice.reset(new CFX_FxgeDevice); 1369 m_pBitmapDevice.reset(new CFX_FxgeDevice);
1374 FXDIB_Format dibFormat = FXDIB_Rgb; 1370 FXDIB_Format dibFormat = FXDIB_Rgb;
1375 int32_t bpp = 24; 1371 int32_t bpp = 24;
1376 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_ALPHA_OUTPUT) { 1372 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_ALPHA_OUTPUT) {
1377 dibFormat = FXDIB_Argb; 1373 dibFormat = FXDIB_Argb;
1378 bpp = 32; 1374 bpp = 32;
1379 } 1375 }
1380 CFX_FloatRect rect; 1376 CFX_FloatRect rect;
1381 int32_t iWidth, iHeight, iPitch; 1377 int32_t iWidth, iHeight, iPitch;
1382 while (1) { 1378 while (1) {
1383 rect = *pRect; 1379 rect = pRect;
1384 m_Matrix.TransformRect(rect); 1380 m_Matrix.TransformRect(rect);
1385 FX_RECT bitmap_rect = rect.GetOutterRect(); 1381 FX_RECT bitmap_rect = rect.GetOutterRect();
1386 iWidth = bitmap_rect.Width(); 1382 iWidth = bitmap_rect.Width();
1387 iHeight = bitmap_rect.Height(); 1383 iHeight = bitmap_rect.Height();
1388 iPitch = (iWidth * bpp + 31) / 32 * 4; 1384 iPitch = (iWidth * bpp + 31) / 32 * 4;
1389 if (iWidth * iHeight < 1) { 1385 if (iWidth * iHeight < 1) {
1390 return FALSE; 1386 return FALSE;
1391 } 1387 }
1392 if (iPitch * iHeight <= _FPDFAPI_IMAGESIZE_LIMIT_ && 1388 if (iPitch * iHeight <= _FPDFAPI_IMAGESIZE_LIMIT_ &&
1393 m_pBitmapDevice->Create(iWidth, iHeight, dibFormat)) { 1389 m_pBitmapDevice->Create(iWidth, iHeight, dibFormat)) {
(...skipping 20 matching lines...) Expand all
1414 item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict) { 1410 item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict) {
1415 CPDF_Dictionary* pOCG = 1411 CPDF_Dictionary* pOCG =
1416 ToDictionary(static_cast<CPDF_Object*>(item.GetParam())); 1412 ToDictionary(static_cast<CPDF_Object*>(item.GetParam()));
1417 if (!CheckOCGVisible(pOCG)) { 1413 if (!CheckOCGVisible(pOCG)) {
1418 return FALSE; 1414 return FALSE;
1419 } 1415 }
1420 } 1416 }
1421 } 1417 }
1422 return TRUE; 1418 return TRUE;
1423 } 1419 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp ('k') | core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698