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

Side by Side Diff: core/fpdfapi/page/cpdf_image.cpp

Issue 2477443002: Remove FX_BOOL from core (Closed)
Patch Set: Created 4 years, 1 month 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/fpdfapi/page/cpdf_image.h ('k') | core/fpdfapi/page/cpdf_meshstream.h » ('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 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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 "core/fpdfapi/page/cpdf_image.h" 7 #include "core/fpdfapi/page/cpdf_image.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 108 }
109 pDict->SetNameFor("ColorSpace", csname); 109 pDict->SetNameFor("ColorSpace", csname);
110 pDict->SetIntegerFor("BitsPerComponent", bits); 110 pDict->SetIntegerFor("BitsPerComponent", bits);
111 pDict->SetNameFor("Filter", "DCTDecode"); 111 pDict->SetNameFor("Filter", "DCTDecode");
112 if (!color_trans) { 112 if (!color_trans) {
113 CPDF_Dictionary* pParms = 113 CPDF_Dictionary* pParms =
114 new CPDF_Dictionary(m_pDocument->GetByteStringPool()); 114 new CPDF_Dictionary(m_pDocument->GetByteStringPool());
115 pDict->SetFor("DecodeParms", pParms); 115 pDict->SetFor("DecodeParms", pParms);
116 pParms->SetIntegerFor("ColorTransform", 0); 116 pParms->SetIntegerFor("ColorTransform", 0);
117 } 117 }
118 m_bIsMask = FALSE; 118 m_bIsMask = false;
119 m_Width = width; 119 m_Width = width;
120 m_Height = height; 120 m_Height = height;
121 if (!m_pStream) 121 if (!m_pStream)
122 m_pStream = new CPDF_Stream; 122 m_pStream = new CPDF_Stream;
123 return pDict; 123 return pDict;
124 } 124 }
125 125
126 void CPDF_Image::SetJpegImage(IFX_SeekableReadStream* pFile) { 126 void CPDF_Image::SetJpegImage(IFX_SeekableReadStream* pFile) {
127 uint32_t size = (uint32_t)pFile->GetSize(); 127 uint32_t size = (uint32_t)pFile->GetSize();
128 if (!size) 128 if (!size)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 FX_STRSIZE dest_pitch = 0, dest_size = 0, opType = -1; 163 FX_STRSIZE dest_pitch = 0, dest_size = 0, opType = -1;
164 if (bpp == 1) { 164 if (bpp == 1) {
165 int32_t reset_a = 0, reset_r = 0, reset_g = 0, reset_b = 0; 165 int32_t reset_a = 0, reset_r = 0, reset_g = 0, reset_b = 0;
166 int32_t set_a = 0, set_r = 0, set_g = 0, set_b = 0; 166 int32_t set_a = 0, set_r = 0, set_g = 0, set_b = 0;
167 if (!pBitmap->IsAlphaMask()) { 167 if (!pBitmap->IsAlphaMask()) {
168 ArgbDecode(pBitmap->GetPaletteArgb(0), reset_a, reset_r, reset_g, 168 ArgbDecode(pBitmap->GetPaletteArgb(0), reset_a, reset_r, reset_g,
169 reset_b); 169 reset_b);
170 ArgbDecode(pBitmap->GetPaletteArgb(1), set_a, set_r, set_g, set_b); 170 ArgbDecode(pBitmap->GetPaletteArgb(1), set_a, set_r, set_g, set_b);
171 } 171 }
172 if (set_a == 0 || reset_a == 0) { 172 if (set_a == 0 || reset_a == 0) {
173 pDict->SetFor("ImageMask", new CPDF_Boolean(TRUE)); 173 pDict->SetFor("ImageMask", new CPDF_Boolean(true));
174 if (reset_a == 0) { 174 if (reset_a == 0) {
175 CPDF_Array* pArray = new CPDF_Array; 175 CPDF_Array* pArray = new CPDF_Array;
176 pArray->AddInteger(1); 176 pArray->AddInteger(1);
177 pArray->AddInteger(0); 177 pArray->AddInteger(0);
178 pDict->SetFor("Decode", pArray); 178 pDict->SetFor("Decode", pArray);
179 } 179 }
180 } else { 180 } else {
181 CPDF_Array* pCS = new CPDF_Array; 181 CPDF_Array* pCS = new CPDF_Array;
182 pCS->AddName("Indexed"); 182 pCS->AddName("Indexed");
183 pCS->AddName("DeviceRGB"); 183 pCS->AddName("DeviceRGB");
184 pCS->AddInteger(1); 184 pCS->AddInteger(1);
185 CFX_ByteString ct; 185 CFX_ByteString ct;
186 FX_CHAR* pBuf = ct.GetBuffer(6); 186 FX_CHAR* pBuf = ct.GetBuffer(6);
187 pBuf[0] = (FX_CHAR)reset_r; 187 pBuf[0] = (FX_CHAR)reset_r;
188 pBuf[1] = (FX_CHAR)reset_g; 188 pBuf[1] = (FX_CHAR)reset_g;
189 pBuf[2] = (FX_CHAR)reset_b; 189 pBuf[2] = (FX_CHAR)reset_b;
190 pBuf[3] = (FX_CHAR)set_r; 190 pBuf[3] = (FX_CHAR)set_r;
191 pBuf[4] = (FX_CHAR)set_g; 191 pBuf[4] = (FX_CHAR)set_g;
192 pBuf[5] = (FX_CHAR)set_b; 192 pBuf[5] = (FX_CHAR)set_b;
193 ct.ReleaseBuffer(6); 193 ct.ReleaseBuffer(6);
194 pCS->Add(new CPDF_String(ct, TRUE)); 194 pCS->Add(new CPDF_String(ct, true));
195 pDict->SetFor("ColorSpace", pCS); 195 pDict->SetFor("ColorSpace", pCS);
196 } 196 }
197 pDict->SetIntegerFor("BitsPerComponent", 1); 197 pDict->SetIntegerFor("BitsPerComponent", 1);
198 dest_pitch = (BitmapWidth + 7) / 8; 198 dest_pitch = (BitmapWidth + 7) / 8;
199 if ((iCompress & 0x03) == PDF_IMAGE_NO_COMPRESS) { 199 if ((iCompress & 0x03) == PDF_IMAGE_NO_COMPRESS) {
200 opType = 1; 200 opType = 1;
201 } else { 201 } else {
202 opType = 0; 202 opType = 0;
203 } 203 }
204 } else if (bpp == 8) { 204 } else if (bpp == 8) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 pDict->SetNameFor("ColorSpace", "DeviceRGB"); 237 pDict->SetNameFor("ColorSpace", "DeviceRGB");
238 pDict->SetIntegerFor("BitsPerComponent", 8); 238 pDict->SetIntegerFor("BitsPerComponent", 8);
239 if ((iCompress & 0x03) == PDF_IMAGE_NO_COMPRESS) { 239 if ((iCompress & 0x03) == PDF_IMAGE_NO_COMPRESS) {
240 dest_pitch = BitmapWidth * 3; 240 dest_pitch = BitmapWidth * 3;
241 opType = 2; 241 opType = 2;
242 } else { 242 } else {
243 opType = 0; 243 opType = 0;
244 } 244 }
245 } 245 }
246 const CFX_DIBitmap* pMaskBitmap = nullptr; 246 const CFX_DIBitmap* pMaskBitmap = nullptr;
247 FX_BOOL bDeleteMask = FALSE; 247 bool bDeleteMask = false;
248 if (pBitmap->HasAlpha()) { 248 if (pBitmap->HasAlpha()) {
249 pMaskBitmap = pBitmap->GetAlphaMask(); 249 pMaskBitmap = pBitmap->GetAlphaMask();
250 bDeleteMask = TRUE; 250 bDeleteMask = true;
251 } 251 }
252 if (pMaskBitmap) { 252 if (pMaskBitmap) {
253 int32_t maskWidth = pMaskBitmap->GetWidth(); 253 int32_t maskWidth = pMaskBitmap->GetWidth();
254 int32_t maskHeight = pMaskBitmap->GetHeight(); 254 int32_t maskHeight = pMaskBitmap->GetHeight();
255 uint8_t* mask_buf = nullptr; 255 uint8_t* mask_buf = nullptr;
256 FX_STRSIZE mask_size = 0; 256 FX_STRSIZE mask_size = 0;
257 CPDF_Dictionary* pMaskDict = 257 CPDF_Dictionary* pMaskDict =
258 new CPDF_Dictionary(m_pDocument->GetByteStringPool()); 258 new CPDF_Dictionary(m_pDocument->GetByteStringPool());
259 pMaskDict->SetNameFor("Type", "XObject"); 259 pMaskDict->SetNameFor("Type", "XObject");
260 pMaskDict->SetNameFor("Subtype", "Image"); 260 pMaskDict->SetNameFor("Subtype", "Image");
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 m_Height = BitmapHeight; 341 m_Height = BitmapHeight;
342 FX_Free(dest_buf); 342 FX_Free(dest_buf);
343 } 343 }
344 344
345 void CPDF_Image::ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pBitmap) { 345 void CPDF_Image::ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pBitmap) {
346 pPage->GetRenderCache()->ResetBitmap(m_pStream, pBitmap); 346 pPage->GetRenderCache()->ResetBitmap(m_pStream, pBitmap);
347 } 347 }
348 348
349 CFX_DIBSource* CPDF_Image::LoadDIBSource(CFX_DIBSource** ppMask, 349 CFX_DIBSource* CPDF_Image::LoadDIBSource(CFX_DIBSource** ppMask,
350 uint32_t* pMatteColor, 350 uint32_t* pMatteColor,
351 FX_BOOL bStdCS, 351 bool bStdCS,
352 uint32_t GroupFamily, 352 uint32_t GroupFamily,
353 FX_BOOL bLoadMask) const { 353 bool bLoadMask) const {
354 std::unique_ptr<CPDF_DIBSource> source(new CPDF_DIBSource); 354 std::unique_ptr<CPDF_DIBSource> source(new CPDF_DIBSource);
355 if (source->Load(m_pDocument, m_pStream, 355 if (source->Load(m_pDocument, m_pStream,
356 reinterpret_cast<CPDF_DIBSource**>(ppMask), pMatteColor, 356 reinterpret_cast<CPDF_DIBSource**>(ppMask), pMatteColor,
357 nullptr, nullptr, bStdCS, GroupFamily, bLoadMask)) { 357 nullptr, nullptr, bStdCS, GroupFamily, bLoadMask)) {
358 return source.release(); 358 return source.release();
359 } 359 }
360 return nullptr; 360 return nullptr;
361 } 361 }
362 362
363 CFX_DIBSource* CPDF_Image::DetachBitmap() { 363 CFX_DIBSource* CPDF_Image::DetachBitmap() {
364 CFX_DIBSource* pBitmap = m_pDIBSource; 364 CFX_DIBSource* pBitmap = m_pDIBSource;
365 m_pDIBSource = nullptr; 365 m_pDIBSource = nullptr;
366 return pBitmap; 366 return pBitmap;
367 } 367 }
368 368
369 CFX_DIBSource* CPDF_Image::DetachMask() { 369 CFX_DIBSource* CPDF_Image::DetachMask() {
370 CFX_DIBSource* pBitmap = m_pMask; 370 CFX_DIBSource* pBitmap = m_pMask;
371 m_pMask = nullptr; 371 m_pMask = nullptr;
372 return pBitmap; 372 return pBitmap;
373 } 373 }
374 374
375 FX_BOOL CPDF_Image::StartLoadDIBSource(CPDF_Dictionary* pFormResource, 375 bool CPDF_Image::StartLoadDIBSource(CPDF_Dictionary* pFormResource,
376 CPDF_Dictionary* pPageResource, 376 CPDF_Dictionary* pPageResource,
377 FX_BOOL bStdCS, 377 bool bStdCS,
378 uint32_t GroupFamily, 378 uint32_t GroupFamily,
379 FX_BOOL bLoadMask) { 379 bool bLoadMask) {
380 std::unique_ptr<CPDF_DIBSource> source(new CPDF_DIBSource); 380 std::unique_ptr<CPDF_DIBSource> source(new CPDF_DIBSource);
381 int ret = 381 int ret =
382 source->StartLoadDIBSource(m_pDocument, m_pStream, TRUE, pFormResource, 382 source->StartLoadDIBSource(m_pDocument, m_pStream, true, pFormResource,
383 pPageResource, bStdCS, GroupFamily, bLoadMask); 383 pPageResource, bStdCS, GroupFamily, bLoadMask);
384 if (ret == 2) { 384 if (ret == 2) {
385 m_pDIBSource = source.release(); 385 m_pDIBSource = source.release();
386 return TRUE; 386 return true;
387 } 387 }
388 if (!ret) { 388 if (!ret) {
389 m_pDIBSource = nullptr; 389 m_pDIBSource = nullptr;
390 return FALSE; 390 return false;
391 } 391 }
392 m_pMask = source->DetachMask(); 392 m_pMask = source->DetachMask();
393 m_MatteColor = source->GetMatteColor(); 393 m_MatteColor = source->GetMatteColor();
394 m_pDIBSource = source.release(); 394 m_pDIBSource = source.release();
395 return FALSE; 395 return false;
396 } 396 }
397 397
398 FX_BOOL CPDF_Image::Continue(IFX_Pause* pPause) { 398 bool CPDF_Image::Continue(IFX_Pause* pPause) {
399 CPDF_DIBSource* pSource = static_cast<CPDF_DIBSource*>(m_pDIBSource); 399 CPDF_DIBSource* pSource = static_cast<CPDF_DIBSource*>(m_pDIBSource);
400 int ret = pSource->ContinueLoadDIBSource(pPause); 400 int ret = pSource->ContinueLoadDIBSource(pPause);
401 if (ret == 2) { 401 if (ret == 2) {
402 return TRUE; 402 return true;
403 } 403 }
404 if (!ret) { 404 if (!ret) {
405 delete m_pDIBSource; 405 delete m_pDIBSource;
406 m_pDIBSource = nullptr; 406 m_pDIBSource = nullptr;
407 return FALSE; 407 return false;
408 } 408 }
409 m_pMask = pSource->DetachMask(); 409 m_pMask = pSource->DetachMask();
410 m_MatteColor = pSource->GetMatteColor(); 410 m_MatteColor = pSource->GetMatteColor();
411 return FALSE; 411 return false;
412 } 412 }
OLDNEW
« no previous file with comments | « core/fpdfapi/page/cpdf_image.h ('k') | core/fpdfapi/page/cpdf_meshstream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698