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

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

Issue 1135893008: Re-land: 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 }
355 for (int row = 0; row < height; row ++) { 352 for (int row = 0; row < height; row ++) {
356 FX_LPCBYTE src_scan = pSource->GetScanline(row); 353 FX_LPCBYTE src_scan = pSource->GetScanline(row);
357 FXSYS_memcpy32(src_buf + row * pitch, src_scan, pitch); 354 FXSYS_memcpy32(src_buf + row * pitch, src_scan, pitch);
358 } 355 }
359 FX_LPBYTE output_buf; 356 FX_LPBYTE output_buf;
360 FX_DWORD output_size; 357 FX_DWORD output_size;
361 FaxCompressData(src_buf, width, height, output_buf, output_size); 358 FaxCompressData(src_buf, width, height, output_buf, output_size);
362 if (pSource->IsAlphaMask()) { 359 if (pSource->IsAlphaMask()) {
363 SetColor(color, alpha_flag, pIccTransform); 360 SetColor(color, alpha_flag, pIccTransform);
364 m_bColorSet = FALSE; 361 m_bColorSet = FALSE;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 if (flags & FXRENDER_IMAGE_LOSSY) { 415 if (flags & FXRENDER_IMAGE_LOSSY) {
419 CCodec_ModuleMgr* pEncoders = CFX_GEModule::Get()->GetCodecModule(); 416 CCodec_ModuleMgr* pEncoders = CFX_GEModule::Get()->GetCodecModule();
420 if (pEncoders && pEncoders->GetJpegModule()->Encode(pConverted, outp ut_buf, output_size)) { 417 if (pEncoders && pEncoders->GetJpegModule()->Encode(pConverted, outp ut_buf, output_size)) {
421 filter = "/DCTDecode filter "; 418 filter = "/DCTDecode filter ";
422 } 419 }
423 } 420 }
424 if (filter == NULL) { 421 if (filter == NULL) {
425 int src_pitch = width * Bpp; 422 int src_pitch = width * Bpp;
426 output_size = height * src_pitch; 423 output_size = height * src_pitch;
427 output_buf = FX_Alloc(FX_BYTE, output_size); 424 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 }
435 for (int row = 0; row < height; row ++) { 425 for (int row = 0; row < height; row ++) {
436 FX_LPCBYTE src_scan = pConverted->GetScanline(row); 426 FX_LPCBYTE src_scan = pConverted->GetScanline(row);
437 FX_LPBYTE dest_scan = output_buf + row * src_pitch; 427 FX_LPBYTE dest_scan = output_buf + row * src_pitch;
438 if (Bpp == 3) { 428 if (Bpp == 3) {
439 for (int col = 0; col < width; col ++) { 429 for (int col = 0; col < width; col ++) {
440 *dest_scan++ = src_scan[2]; 430 *dest_scan++ = src_scan[2];
441 *dest_scan++ = src_scan[1]; 431 *dest_scan++ = src_scan[1];
442 *dest_scan++ = *src_scan; 432 *dest_scan++ = *src_scan;
443 src_scan += 3; 433 src_scan += 3;
444 } 434 }
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 FX_LPBYTE dest_buf; 635 FX_LPBYTE dest_buf;
646 FX_DWORD dest_size; 636 FX_DWORD dest_size;
647 CCodec_ModuleMgr* pEncoders = CFX_GEModule::Get()->GetCodecModule(); 637 CCodec_ModuleMgr* pEncoders = CFX_GEModule::Get()->GetCodecModule();
648 if (pEncoders && pEncoders->GetBasicModule()->A85Encode(data, len, dest_buf, dest_size)) { 638 if (pEncoders && pEncoders->GetBasicModule()->A85Encode(data, len, dest_buf, dest_size)) {
649 m_pOutput->OutputPS((FX_LPCSTR)dest_buf, dest_size); 639 m_pOutput->OutputPS((FX_LPCSTR)dest_buf, dest_size);
650 FX_Free(dest_buf); 640 FX_Free(dest_buf);
651 } else { 641 } else {
652 m_pOutput->OutputPS((FX_LPCSTR)data, len); 642 m_pOutput->OutputPS((FX_LPCSTR)data, len);
653 } 643 }
654 } 644 }
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