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

Side by Side Diff: core/src/fxge/ge/fx_ge_ps.cpp

Issue 1145843005: Revert "Remove FX_Alloc() null checks now that it can't return NULL." (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 7 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 | « core/src/fxge/ge/fx_ge_path.cpp ('k') | core/src/fxge/ge/fx_ge_text.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/fxge/fx_ge.h" 7 #include "../../../include/fxge/fx_ge.h"
8 #include "../../../include/fxcodec/fx_codec.h" 8 #include "../../../include/fxcodec/fx_codec.h"
9 #include "text_int.h" 9 #include "text_int.h"
10 struct PSGlyph { 10 struct PSGlyph {
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 buf << FX_BSTRC("[") << pMatrix->a << FX_BSTRC(" ") << pMatrix->b << FX_BSTR C(" ") << 342 buf << FX_BSTRC("[") << pMatrix->a << FX_BSTRC(" ") << pMatrix->b << FX_BSTR C(" ") <<
343 pMatrix->c << FX_BSTRC(" ") << pMatrix->d << FX_BSTRC(" ") << pMatrix->e << 343 pMatrix->c << FX_BSTRC(" ") << pMatrix->d << FX_BSTRC(" ") << pMatrix->e <<
344 FX_BSTRC(" ") << pMatrix->f << FX_BSTRC("]cm "); 344 FX_BSTRC(" ") << pMatrix->f << FX_BSTRC("]cm ");
345 int width = pSource->GetWidth(); 345 int width = pSource->GetWidth();
346 int height = pSource->GetHeight(); 346 int height = pSource->GetHeight();
347 buf << width << FX_BSTRC(" ") << height; 347 buf << width << FX_BSTRC(" ") << height;
348 if (pSource->GetBPP() == 1 && pSource->GetPalette() == NULL) { 348 if (pSource->GetBPP() == 1 && pSource->GetPalette() == NULL) {
349 int pitch = (width + 7) / 8; 349 int pitch = (width + 7) / 8;
350 FX_DWORD src_size = height * pitch; 350 FX_DWORD src_size = height * pitch;
351 FX_LPBYTE src_buf = FX_Alloc(FX_BYTE, src_size); 351 FX_LPBYTE src_buf = FX_Alloc(FX_BYTE, src_size);
352 if (!src_buf) {
353 return FALSE;
354 }
352 for (int row = 0; row < height; row ++) { 355 for (int row = 0; row < height; row ++) {
353 FX_LPCBYTE src_scan = pSource->GetScanline(row); 356 FX_LPCBYTE src_scan = pSource->GetScanline(row);
354 FXSYS_memcpy32(src_buf + row * pitch, src_scan, pitch); 357 FXSYS_memcpy32(src_buf + row * pitch, src_scan, pitch);
355 } 358 }
356 FX_LPBYTE output_buf; 359 FX_LPBYTE output_buf;
357 FX_DWORD output_size; 360 FX_DWORD output_size;
358 FaxCompressData(src_buf, width, height, output_buf, output_size); 361 FaxCompressData(src_buf, width, height, output_buf, output_size);
359 if (pSource->IsAlphaMask()) { 362 if (pSource->IsAlphaMask()) {
360 SetColor(color, alpha_flag, pIccTransform); 363 SetColor(color, alpha_flag, pIccTransform);
361 m_bColorSet = FALSE; 364 m_bColorSet = FALSE;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 if (flags & FXRENDER_IMAGE_LOSSY) { 418 if (flags & FXRENDER_IMAGE_LOSSY) {
416 CCodec_ModuleMgr* pEncoders = CFX_GEModule::Get()->GetCodecModule(); 419 CCodec_ModuleMgr* pEncoders = CFX_GEModule::Get()->GetCodecModule();
417 if (pEncoders && pEncoders->GetJpegModule()->Encode(pConverted, outp ut_buf, output_size)) { 420 if (pEncoders && pEncoders->GetJpegModule()->Encode(pConverted, outp ut_buf, output_size)) {
418 filter = "/DCTDecode filter "; 421 filter = "/DCTDecode filter ";
419 } 422 }
420 } 423 }
421 if (filter == NULL) { 424 if (filter == NULL) {
422 int src_pitch = width * Bpp; 425 int src_pitch = width * Bpp;
423 output_size = height * src_pitch; 426 output_size = height * src_pitch;
424 output_buf = FX_Alloc(FX_BYTE, output_size); 427 output_buf = FX_Alloc(FX_BYTE, output_size);
428 if (!output_buf) {
429 if (pConverted != pSource) {
430 delete pConverted;
431 pConverted = NULL;
432 }
433 return FALSE;
434 }
425 for (int row = 0; row < height; row ++) { 435 for (int row = 0; row < height; row ++) {
426 FX_LPCBYTE src_scan = pConverted->GetScanline(row); 436 FX_LPCBYTE src_scan = pConverted->GetScanline(row);
427 FX_LPBYTE dest_scan = output_buf + row * src_pitch; 437 FX_LPBYTE dest_scan = output_buf + row * src_pitch;
428 if (Bpp == 3) { 438 if (Bpp == 3) {
429 for (int col = 0; col < width; col ++) { 439 for (int col = 0; col < width; col ++) {
430 *dest_scan++ = src_scan[2]; 440 *dest_scan++ = src_scan[2];
431 *dest_scan++ = src_scan[1]; 441 *dest_scan++ = src_scan[1];
432 *dest_scan++ = *src_scan; 442 *dest_scan++ = *src_scan;
433 src_scan += 3; 443 src_scan += 3;
434 } 444 }
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 FX_LPBYTE dest_buf; 645 FX_LPBYTE dest_buf;
636 FX_DWORD dest_size; 646 FX_DWORD dest_size;
637 CCodec_ModuleMgr* pEncoders = CFX_GEModule::Get()->GetCodecModule(); 647 CCodec_ModuleMgr* pEncoders = CFX_GEModule::Get()->GetCodecModule();
638 if (pEncoders && pEncoders->GetBasicModule()->A85Encode(data, len, dest_buf, dest_size)) { 648 if (pEncoders && pEncoders->GetBasicModule()->A85Encode(data, len, dest_buf, dest_size)) {
639 m_pOutput->OutputPS((FX_LPCSTR)dest_buf, dest_size); 649 m_pOutput->OutputPS((FX_LPCSTR)dest_buf, dest_size);
640 FX_Free(dest_buf); 650 FX_Free(dest_buf);
641 } else { 651 } else {
642 m_pOutput->OutputPS((FX_LPCSTR)data, len); 652 m_pOutput->OutputPS((FX_LPCSTR)data, len);
643 } 653 }
644 } 654 }
OLDNEW
« no previous file with comments | « core/src/fxge/ge/fx_ge_path.cpp ('k') | core/src/fxge/ge/fx_ge_text.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698