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

Side by Side Diff: core/src/fpdfapi/fpdf_page/fpdf_page_pattern.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 "pageint.h" 7 #include "pageint.h"
8 8
9 #include "core/include/fpdfapi/fpdf_page.h" 9 #include "core/include/fpdfapi/fpdf_page.h"
10 10
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 m_pCountedCS = NULL; 122 m_pCountedCS = NULL;
123 m_nFuncs = 0; 123 m_nFuncs = 0;
124 } 124 }
125 125
126 FX_BOOL CPDF_ShadingPattern::Load() { 126 FX_BOOL CPDF_ShadingPattern::Load() {
127 if (m_ShadingType != kInvalidShading) 127 if (m_ShadingType != kInvalidShading)
128 return TRUE; 128 return TRUE;
129 129
130 CPDF_Dictionary* pShadingDict = 130 CPDF_Dictionary* pShadingDict =
131 m_pShadingObj ? m_pShadingObj->GetDict() : NULL; 131 m_pShadingObj ? m_pShadingObj->GetDict() : NULL;
132 if (pShadingDict == NULL) { 132 if (!pShadingDict) {
133 return FALSE; 133 return FALSE;
134 } 134 }
135 if (m_nFuncs) { 135 if (m_nFuncs) {
136 for (int i = 0; i < m_nFuncs; i++) 136 for (int i = 0; i < m_nFuncs; i++)
137 delete m_pFunctions[i]; 137 delete m_pFunctions[i];
138 m_nFuncs = 0; 138 m_nFuncs = 0;
139 } 139 }
140 CPDF_Object* pFunc = pShadingDict->GetElementValue("Function"); 140 CPDF_Object* pFunc = pShadingDict->GetElementValue("Function");
141 if (pFunc) { 141 if (pFunc) {
142 if (CPDF_Array* pArray = pFunc->AsArray()) { 142 if (CPDF_Array* pArray = pFunc->AsArray()) {
143 m_nFuncs = std::min<int>(pArray->GetCount(), 4); 143 m_nFuncs = std::min<int>(pArray->GetCount(), 4);
144 144
145 for (int i = 0; i < m_nFuncs; i++) { 145 for (int i = 0; i < m_nFuncs; i++) {
146 m_pFunctions[i] = CPDF_Function::Load(pArray->GetElementValue(i)); 146 m_pFunctions[i] = CPDF_Function::Load(pArray->GetElementValue(i));
147 } 147 }
148 } else { 148 } else {
149 m_pFunctions[0] = CPDF_Function::Load(pFunc); 149 m_pFunctions[0] = CPDF_Function::Load(pFunc);
150 m_nFuncs = 1; 150 m_nFuncs = 1;
151 } 151 }
152 } 152 }
153 CPDF_Object* pCSObj = pShadingDict->GetElementValue("ColorSpace"); 153 CPDF_Object* pCSObj = pShadingDict->GetElementValue("ColorSpace");
154 if (pCSObj == NULL) { 154 if (!pCSObj) {
155 return FALSE; 155 return FALSE;
156 } 156 }
157 CPDF_DocPageData* pDocPageData = m_pDocument->GetPageData(); 157 CPDF_DocPageData* pDocPageData = m_pDocument->GetPageData();
158 m_pCS = pDocPageData->GetColorSpace(pCSObj, NULL); 158 m_pCS = pDocPageData->GetColorSpace(pCSObj, NULL);
159 if (m_pCS) { 159 if (m_pCS) {
160 m_pCountedCS = pDocPageData->FindColorSpacePtr(m_pCS->GetArray()); 160 m_pCountedCS = pDocPageData->FindColorSpacePtr(m_pCS->GetArray());
161 } 161 }
162 162
163 m_ShadingType = ToShadingType(pShadingDict->GetInteger("ShadingType")); 163 m_ShadingType = ToShadingType(pShadingDict->GetInteger("ShadingType"));
164 164
(...skipping 27 matching lines...) Expand all
192 if (nComps > 8) { 192 if (nComps > 8) {
193 return FALSE; 193 return FALSE;
194 } 194 }
195 m_nComps = nFuncs ? 1 : nComps; 195 m_nComps = nFuncs ? 1 : nComps;
196 if (((int)m_nComps < 0) || m_nComps > 8) { 196 if (((int)m_nComps < 0) || m_nComps > 8) {
197 return FALSE; 197 return FALSE;
198 } 198 }
199 m_CoordMax = m_nCoordBits == 32 ? -1 : (1 << m_nCoordBits) - 1; 199 m_CoordMax = m_nCoordBits == 32 ? -1 : (1 << m_nCoordBits) - 1;
200 m_CompMax = (1 << m_nCompBits) - 1; 200 m_CompMax = (1 << m_nCompBits) - 1;
201 CPDF_Array* pDecode = pDict->GetArray("Decode"); 201 CPDF_Array* pDecode = pDict->GetArray("Decode");
202 if (pDecode == NULL || pDecode->GetCount() != 4 + m_nComps * 2) { 202 if (!pDecode || pDecode->GetCount() != 4 + m_nComps * 2) {
203 return FALSE; 203 return FALSE;
204 } 204 }
205 m_xmin = pDecode->GetNumber(0); 205 m_xmin = pDecode->GetNumber(0);
206 m_xmax = pDecode->GetNumber(1); 206 m_xmax = pDecode->GetNumber(1);
207 m_ymin = pDecode->GetNumber(2); 207 m_ymin = pDecode->GetNumber(2);
208 m_ymax = pDecode->GetNumber(3); 208 m_ymax = pDecode->GetNumber(3);
209 for (FX_DWORD i = 0; i < m_nComps; i++) { 209 for (FX_DWORD i = 0; i < m_nComps; i++) {
210 m_ColorMin[i] = pDecode->GetNumber(i * 2 + 4); 210 m_ColorMin[i] = pDecode->GetNumber(i * 2 + 4);
211 m_ColorMax[i] = pDecode->GetNumber(i * 2 + 5); 211 m_ColorMax[i] = pDecode->GetNumber(i * 2 + 5);
212 } 212 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 } 324 }
325 } 325 }
326 stream.m_BitStream.SkipBits(stream.m_nComps * stream.m_nCompBits * 326 stream.m_BitStream.SkipBits(stream.m_nComps * stream.m_nCompBits *
327 color_count); 327 color_count);
328 if (bGouraud) 328 if (bGouraud)
329 stream.m_BitStream.ByteAlign(); 329 stream.m_BitStream.ByteAlign();
330 } 330 }
331 rect.Transform(pMatrix); 331 rect.Transform(pMatrix);
332 return rect; 332 return rect;
333 } 333 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp ('k') | core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698