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/fpdfapi/fpdf_render/fpdf_render_image.cpp

Issue 1520063002: Get rid of most instance of 'foo == NULL' (Closed) Base URL: https://pdfium.googlesource.com/pdfium@bstr_isnull
Patch Set: rebase 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_pageobj.h" 10 #include "core/include/fpdfapi/fpdf_pageobj.h"
(...skipping 11 matching lines...) Expand all
22 } 22 }
23 return render.m_Result; 23 return render.m_Result;
24 } 24 }
25 void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, 25 void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap,
26 int left, 26 int left,
27 int top, 27 int top,
28 FX_ARGB mask_argb, 28 FX_ARGB mask_argb,
29 int bitmap_alpha, 29 int bitmap_alpha,
30 int blend_mode, 30 int blend_mode,
31 int Transparency) { 31 int Transparency) {
32 if (pDIBitmap == NULL) { 32 if (!pDIBitmap) {
33 return; 33 return;
34 } 34 }
35 FX_BOOL bIsolated = Transparency & PDFTRANS_ISOLATED; 35 FX_BOOL bIsolated = Transparency & PDFTRANS_ISOLATED;
36 FX_BOOL bGroup = Transparency & PDFTRANS_GROUP; 36 FX_BOOL bGroup = Transparency & PDFTRANS_GROUP;
37 if (blend_mode == FXDIB_BLEND_NORMAL) { 37 if (blend_mode == FXDIB_BLEND_NORMAL) {
38 if (!pDIBitmap->IsAlphaMask()) { 38 if (!pDIBitmap->IsAlphaMask()) {
39 if (bitmap_alpha < 255) { 39 if (bitmap_alpha < 255) {
40 pDIBitmap->MultiplyAlpha(bitmap_alpha); 40 pDIBitmap->MultiplyAlpha(bitmap_alpha);
41 } 41 }
42 if (m_pDevice->SetDIBits(pDIBitmap, left, top)) { 42 if (m_pDevice->SetDIBits(pDIBitmap, left, top)) {
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 dest_height)) { 346 dest_height)) {
347 if (m_LoadHandle) { 347 if (m_LoadHandle) {
348 m_Status = 4; 348 m_Status = 4;
349 return TRUE; 349 return TRUE;
350 } 350 }
351 return FALSE; 351 return FALSE;
352 } 352 }
353 return FALSE; 353 return FALSE;
354 } 354 }
355 FX_BOOL CPDF_ImageRenderer::StartRenderDIBSource() { 355 FX_BOOL CPDF_ImageRenderer::StartRenderDIBSource() {
356 if (m_Loader.m_pBitmap == NULL) { 356 if (!m_Loader.m_pBitmap) {
357 return FALSE; 357 return FALSE;
358 } 358 }
359 m_BitmapAlpha = 255; 359 m_BitmapAlpha = 255;
360 const CPDF_GeneralStateData* pGeneralState = m_pImageObject->m_GeneralState; 360 const CPDF_GeneralStateData* pGeneralState = m_pImageObject->m_GeneralState;
361 if (pGeneralState) { 361 if (pGeneralState) {
362 m_BitmapAlpha = FXSYS_round(pGeneralState->m_FillAlpha * 255); 362 m_BitmapAlpha = FXSYS_round(pGeneralState->m_FillAlpha * 255);
363 } 363 }
364 m_pDIBSource = m_Loader.m_pBitmap; 364 m_pDIBSource = m_Loader.m_pBitmap;
365 if (m_pRenderStatus->m_Options.m_ColorMode == RENDER_COLOR_ALPHA && 365 if (m_pRenderStatus->m_Options.m_ColorMode == RENDER_COLOR_ALPHA &&
366 m_Loader.m_pMask == NULL) { 366 !m_Loader.m_pMask) {
367 return StartBitmapAlpha(); 367 return StartBitmapAlpha();
368 } 368 }
369 if (pGeneralState && pGeneralState->m_pTR) { 369 if (pGeneralState && pGeneralState->m_pTR) {
370 if (!pGeneralState->m_pTransferFunc) { 370 if (!pGeneralState->m_pTransferFunc) {
371 ((CPDF_GeneralStateData*)pGeneralState)->m_pTransferFunc = 371 ((CPDF_GeneralStateData*)pGeneralState)->m_pTransferFunc =
372 m_pRenderStatus->GetTransferFunc(pGeneralState->m_pTR); 372 m_pRenderStatus->GetTransferFunc(pGeneralState->m_pTR);
373 } 373 }
374 if (pGeneralState->m_pTransferFunc && 374 if (pGeneralState->m_pTransferFunc &&
375 !pGeneralState->m_pTransferFunc->m_bIdentity) { 375 !pGeneralState->m_pTransferFunc->m_bIdentity) {
376 m_pDIBSource = m_Loader.m_pBitmap = 376 m_pDIBSource = m_Loader.m_pBitmap =
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 m_pRenderStatus->m_pDevice->SetDIBits( 837 m_pRenderStatus->m_pDevice->SetDIBits(
838 m_pQuickStretcher->m_pBitmap, m_pQuickStretcher->m_ResultLeft, 838 m_pQuickStretcher->m_pBitmap, m_pQuickStretcher->m_ResultLeft,
839 m_pQuickStretcher->m_ResultTop, m_BlendType); 839 m_pQuickStretcher->m_ResultTop, m_BlendType);
840 return FALSE; 840 return FALSE;
841 } 841 }
842 if (m_Status == 2) { 842 if (m_Status == 2) {
843 if (m_pTransformer->Continue(pPause)) { 843 if (m_pTransformer->Continue(pPause)) {
844 return TRUE; 844 return TRUE;
845 } 845 }
846 CFX_DIBitmap* pBitmap = m_pTransformer->m_Storer.Detach(); 846 CFX_DIBitmap* pBitmap = m_pTransformer->m_Storer.Detach();
847 if (pBitmap == NULL) { 847 if (!pBitmap) {
848 return FALSE; 848 return FALSE;
849 } 849 }
850 if (pBitmap->IsAlphaMask()) { 850 if (pBitmap->IsAlphaMask()) {
851 if (m_BitmapAlpha != 255) { 851 if (m_BitmapAlpha != 255) {
852 m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha); 852 m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha);
853 } 853 }
854 m_Result = m_pRenderStatus->m_pDevice->SetBitMask( 854 m_Result = m_pRenderStatus->m_pDevice->SetBitMask(
855 pBitmap, m_pTransformer->m_ResultLeft, m_pTransformer->m_ResultTop, 855 pBitmap, m_pTransformer->m_ResultLeft, m_pTransformer->m_ResultTop,
856 m_FillArgb); 856 m_FillArgb);
857 } else { 857 } else {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 return FALSE; 927 return FALSE;
928 } 928 }
929 if (pDict->KeyExist("SMask") || pDict->KeyExist("Mask")) { 929 if (pDict->KeyExist("SMask") || pDict->KeyExist("Mask")) {
930 return FALSE; 930 return FALSE;
931 } 931 }
932 m_SrcWidth = pDict->GetInteger("Width"); 932 m_SrcWidth = pDict->GetInteger("Width");
933 m_SrcHeight = pDict->GetInteger("Height"); 933 m_SrcHeight = pDict->GetInteger("Height");
934 m_pCS = NULL; 934 m_pCS = NULL;
935 m_Bpp = 3; 935 m_Bpp = 3;
936 CPDF_Object* pCSObj = pDict->GetElementValue("ColorSpace"); 936 CPDF_Object* pCSObj = pDict->GetElementValue("ColorSpace");
937 if (pCSObj == NULL) { 937 if (!pCSObj) {
938 return FALSE; 938 return FALSE;
939 } 939 }
940 m_pCS = CPDF_ColorSpace::Load(pImageObj->m_pImage->GetDocument(), pCSObj); 940 m_pCS = CPDF_ColorSpace::Load(pImageObj->m_pImage->GetDocument(), pCSObj);
941 if (m_pCS == NULL) { 941 if (!m_pCS) {
942 return FALSE; 942 return FALSE;
943 } 943 }
944 if (!_IsSupported(m_pCS)) { 944 if (!_IsSupported(m_pCS)) {
945 return FALSE; 945 return FALSE;
946 } 946 }
947 m_Bpp = m_pCS->CountComponents(); 947 m_Bpp = m_pCS->CountComponents();
948 if (m_pCS->sRGB()) { 948 if (m_pCS->sRGB()) {
949 m_pCS->ReleaseCS(); 949 m_pCS->ReleaseCS();
950 m_pCS = NULL; 950 m_pCS = NULL;
951 } 951 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 dest_y = m_ResultHeight - m_LineIndex - 1; 988 dest_y = m_ResultHeight - m_LineIndex - 1;
989 src_y = 989 src_y =
990 (m_DestHeight - (dest_y + m_ClipTop) - 1) * src_height / m_DestHeight; 990 (m_DestHeight - (dest_y + m_ClipTop) - 1) * src_height / m_DestHeight;
991 } else { 991 } else {
992 dest_y = m_LineIndex; 992 dest_y = m_LineIndex;
993 src_y = (dest_y + m_ClipTop) * src_height / m_DestHeight; 993 src_y = (dest_y + m_ClipTop) * src_height / m_DestHeight;
994 } 994 }
995 const uint8_t* src_scan; 995 const uint8_t* src_scan;
996 if (m_pDecoder) { 996 if (m_pDecoder) {
997 src_scan = m_pDecoder->GetScanline(src_y); 997 src_scan = m_pDecoder->GetScanline(src_y);
998 if (src_scan == NULL) { 998 if (!src_scan) {
999 break; 999 break;
1000 } 1000 }
1001 } else { 1001 } else {
1002 src_scan = m_StreamAcc.GetData(); 1002 src_scan = m_StreamAcc.GetData();
1003 if (src_scan == NULL) { 1003 if (!src_scan) {
1004 break; 1004 break;
1005 } 1005 }
1006 src_scan += src_y * src_pitch; 1006 src_scan += src_y * src_pitch;
1007 } 1007 }
1008 uint8_t* result_scan = result_buf + dest_y * m_pBitmap->GetPitch(); 1008 uint8_t* result_scan = result_buf + dest_y * m_pBitmap->GetPitch();
1009 for (int x = 0; x < m_ResultWidth; x++) { 1009 for (int x = 0; x < m_ResultWidth; x++) {
1010 int dest_x = m_ClipLeft + x; 1010 int dest_x = m_ClipLeft + x;
1011 int src_x = (m_bFlipX ? (m_DestWidth - dest_x - 1) : dest_x) * src_width / 1011 int src_x = (m_bFlipX ? (m_DestWidth - dest_x - 1) : dest_x) * src_width /
1012 m_DestWidth; 1012 m_DestWidth;
1013 const uint8_t* src_pixel = src_scan + src_x * m_Bpp; 1013 const uint8_t* src_pixel = src_scan + src_x * m_Bpp;
1014 if (m_pCS == NULL) { 1014 if (!m_pCS) {
1015 *result_scan = src_pixel[2]; 1015 *result_scan = src_pixel[2];
1016 result_scan++; 1016 result_scan++;
1017 *result_scan = src_pixel[1]; 1017 *result_scan = src_pixel[1];
1018 result_scan++; 1018 result_scan++;
1019 *result_scan = src_pixel[0]; 1019 *result_scan = src_pixel[0];
1020 result_scan++; 1020 result_scan++;
1021 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 1021 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
1022 result_scan++; 1022 result_scan++;
1023 #endif 1023 #endif
1024 } else { 1024 } else {
1025 m_pCS->TranslateImageLine(result_scan, src_pixel, 1, 0, 0); 1025 m_pCS->TranslateImageLine(result_scan, src_pixel, 1, 0, 0);
1026 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 1026 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
1027 result_scan += 4; 1027 result_scan += 4;
1028 #else 1028 #else
1029 result_scan += 3; 1029 result_scan += 3;
1030 #endif 1030 #endif
1031 } 1031 }
1032 } 1032 }
1033 m_LineIndex++; 1033 m_LineIndex++;
1034 if (pPause && pPause->NeedToPauseNow()) { 1034 if (pPause && pPause->NeedToPauseNow()) {
1035 return TRUE; 1035 return TRUE;
1036 } 1036 }
1037 } 1037 }
1038 return FALSE; 1038 return FALSE;
1039 } 1039 }
1040 CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict, 1040 CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict,
1041 FX_RECT* pClipRect, 1041 FX_RECT* pClipRect,
1042 const CFX_Matrix* pMatrix) { 1042 const CFX_Matrix* pMatrix) {
1043 if (pSMaskDict == NULL) { 1043 if (!pSMaskDict) {
1044 return NULL; 1044 return NULL;
1045 } 1045 }
1046 int width = pClipRect->right - pClipRect->left; 1046 int width = pClipRect->right - pClipRect->left;
1047 int height = pClipRect->bottom - pClipRect->top; 1047 int height = pClipRect->bottom - pClipRect->top;
1048 FX_BOOL bLuminosity = FALSE; 1048 FX_BOOL bLuminosity = FALSE;
1049 bLuminosity = pSMaskDict->GetConstString("S") != "Alpha"; 1049 bLuminosity = pSMaskDict->GetConstString("S") != "Alpha";
1050 CPDF_Stream* pGroup = pSMaskDict->GetStream("G"); 1050 CPDF_Stream* pGroup = pSMaskDict->GetStream("G");
1051 if (pGroup == NULL) { 1051 if (!pGroup) {
1052 return NULL; 1052 return NULL;
1053 } 1053 }
1054 nonstd::unique_ptr<CPDF_Function> pFunc; 1054 nonstd::unique_ptr<CPDF_Function> pFunc;
1055 CPDF_Object* pFuncObj = pSMaskDict->GetElementValue("TR"); 1055 CPDF_Object* pFuncObj = pSMaskDict->GetElementValue("TR");
1056 if (pFuncObj && (pFuncObj->IsDictionary() || pFuncObj->IsStream())) 1056 if (pFuncObj && (pFuncObj->IsDictionary() || pFuncObj->IsStream()))
1057 pFunc.reset(CPDF_Function::Load(pFuncObj)); 1057 pFunc.reset(CPDF_Function::Load(pFuncObj));
1058 1058
1059 CFX_Matrix matrix = *pMatrix; 1059 CFX_Matrix matrix = *pMatrix;
1060 matrix.TranslateI(-pClipRect->left, -pClipRect->top); 1060 matrix.TranslateI(-pClipRect->left, -pClipRect->top);
1061 CPDF_Form form(m_pContext->m_pDocument, m_pContext->m_pPageResources, pGroup); 1061 CPDF_Form form(m_pContext->m_pDocument, m_pContext->m_pPageResources, pGroup);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 } else if (pFunc) { 1159 } else if (pFunc) {
1160 int size = dest_pitch * height; 1160 int size = dest_pitch * height;
1161 for (int i = 0; i < size; i++) { 1161 for (int i = 0; i < size; i++) {
1162 dest_buf[i] = transfers[src_buf[i]]; 1162 dest_buf[i] = transfers[src_buf[i]];
1163 } 1163 }
1164 } else { 1164 } else {
1165 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); 1165 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height);
1166 } 1166 }
1167 return pMask.release(); 1167 return pMask.release();
1168 } 1168 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp ('k') | core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698