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

Side by Side Diff: core/src/fxge/ge/fx_ge_ps.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
« 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 "core/include/fxge/fx_ge.h" 7 #include "core/include/fxge/fx_ge.h"
8 #include "core/include/fxcodec/fx_codec.h" 8 #include "core/include/fxcodec/fx_codec.h"
9 #include "text_int.h" 9 #include "text_int.h"
10 10
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 if (pSource->IsAlphaMask() && (alpha < 255 || pSource->GetBPP() != 1)) { 367 if (pSource->IsAlphaMask() && (alpha < 255 || pSource->GetBPP() != 1)) {
368 return FALSE; 368 return FALSE;
369 } 369 }
370 OUTPUT_PS("q\n"); 370 OUTPUT_PS("q\n");
371 CFX_ByteTextBuf buf; 371 CFX_ByteTextBuf buf;
372 buf << "[" << pMatrix->a << " " << pMatrix->b << " " << pMatrix->c << " " 372 buf << "[" << pMatrix->a << " " << pMatrix->b << " " << pMatrix->c << " "
373 << pMatrix->d << " " << pMatrix->e << " " << pMatrix->f << "]cm "; 373 << pMatrix->d << " " << pMatrix->e << " " << pMatrix->f << "]cm ";
374 int width = pSource->GetWidth(); 374 int width = pSource->GetWidth();
375 int height = pSource->GetHeight(); 375 int height = pSource->GetHeight();
376 buf << width << " " << height; 376 buf << width << " " << height;
377 if (pSource->GetBPP() == 1 && pSource->GetPalette() == NULL) { 377 if (pSource->GetBPP() == 1 && !pSource->GetPalette()) {
378 int pitch = (width + 7) / 8; 378 int pitch = (width + 7) / 8;
379 FX_DWORD src_size = height * pitch; 379 FX_DWORD src_size = height * pitch;
380 uint8_t* src_buf = FX_Alloc(uint8_t, src_size); 380 uint8_t* src_buf = FX_Alloc(uint8_t, src_size);
381 for (int row = 0; row < height; row++) { 381 for (int row = 0; row < height; row++) {
382 const uint8_t* src_scan = pSource->GetScanline(row); 382 const uint8_t* src_scan = pSource->GetScanline(row);
383 FXSYS_memcpy(src_buf + row * pitch, src_scan, pitch); 383 FXSYS_memcpy(src_buf + row * pitch, src_scan, pitch);
384 } 384 }
385 uint8_t* output_buf; 385 uint8_t* output_buf;
386 FX_DWORD output_size; 386 FX_DWORD output_size;
387 FaxCompressData(src_buf, width, height, output_buf, output_size); 387 FaxCompressData(src_buf, width, height, output_buf, output_size);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 break; 426 break;
427 case FXDIB_8bppCmyk: 427 case FXDIB_8bppCmyk:
428 if (pSource->GetPalette()) { 428 if (pSource->GetPalette()) {
429 pConverted = pSource->CloneConvert(FXDIB_Cmyk); 429 pConverted = pSource->CloneConvert(FXDIB_Cmyk);
430 } 430 }
431 break; 431 break;
432 default: 432 default:
433 break; 433 break;
434 } 434 }
435 } 435 }
436 if (pConverted == NULL) { 436 if (!pConverted) {
437 OUTPUT_PS("\nQ\n"); 437 OUTPUT_PS("\nQ\n");
438 return FALSE; 438 return FALSE;
439 } 439 }
440 int Bpp = pConverted->GetBPP() / 8; 440 int Bpp = pConverted->GetBPP() / 8;
441 uint8_t* output_buf = NULL; 441 uint8_t* output_buf = NULL;
442 FX_STRSIZE output_size = 0; 442 FX_STRSIZE output_size = 0;
443 const FX_CHAR* filter = NULL; 443 const FX_CHAR* filter = NULL;
444 if (flags & FXRENDER_IMAGE_LOSSY) { 444 if (flags & FXRENDER_IMAGE_LOSSY) {
445 CCodec_ModuleMgr* pEncoders = CFX_GEModule::Get()->GetCodecModule(); 445 CCodec_ModuleMgr* pEncoders = CFX_GEModule::Get()->GetCodecModule();
446 if (pEncoders && 446 if (pEncoders &&
447 pEncoders->GetJpegModule()->Encode(pConverted, output_buf, 447 pEncoders->GetJpegModule()->Encode(pConverted, output_buf,
448 output_size)) { 448 output_size)) {
449 filter = "/DCTDecode filter "; 449 filter = "/DCTDecode filter ";
450 } 450 }
451 } 451 }
452 if (filter == NULL) { 452 if (!filter) {
453 int src_pitch = width * Bpp; 453 int src_pitch = width * Bpp;
454 output_size = height * src_pitch; 454 output_size = height * src_pitch;
455 output_buf = FX_Alloc(uint8_t, output_size); 455 output_buf = FX_Alloc(uint8_t, output_size);
456 for (int row = 0; row < height; row++) { 456 for (int row = 0; row < height; row++) {
457 const uint8_t* src_scan = pConverted->GetScanline(row); 457 const uint8_t* src_scan = pConverted->GetScanline(row);
458 uint8_t* dest_scan = output_buf + row * src_pitch; 458 uint8_t* dest_scan = output_buf + row * src_pitch;
459 if (Bpp == 3) { 459 if (Bpp == 3) {
460 for (int col = 0; col < width; col++) { 460 for (int col = 0; col < width; col++) {
461 *dest_scan++ = src_scan[2]; 461 *dest_scan++ = src_scan[2];
462 *dest_scan++ = src_scan[1]; 462 *dest_scan++ = src_scan[1];
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 charpos.m_AdjustMatrix[3]; 596 charpos.m_AdjustMatrix[3];
597 } 597 }
598 pPSFont->m_nGlyphs++; 598 pPSFont->m_nGlyphs++;
599 CFX_Matrix matrix; 599 CFX_Matrix matrix;
600 if (charpos.m_bGlyphAdjust) 600 if (charpos.m_bGlyphAdjust)
601 matrix.Set(charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1], 601 matrix.Set(charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1],
602 charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0); 602 charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0);
603 matrix.Concat(1.0f, 0, 0, 1.0f, 0, 0); 603 matrix.Concat(1.0f, 0, 0, 1.0f, 0, 0);
604 const CFX_PathData* pPathData = pFaceCache->LoadGlyphPath( 604 const CFX_PathData* pPathData = pFaceCache->LoadGlyphPath(
605 pFont, charpos.m_GlyphIndex, charpos.m_FontCharWidth); 605 pFont, charpos.m_GlyphIndex, charpos.m_FontCharWidth);
606 if (pPathData == NULL) { 606 if (!pPathData) {
607 return; 607 return;
608 } 608 }
609 CFX_PathData TransformedPath(*pPathData); 609 CFX_PathData TransformedPath(*pPathData);
610 if (charpos.m_bGlyphAdjust) { 610 if (charpos.m_bGlyphAdjust) {
611 TransformedPath.Transform(&matrix); 611 TransformedPath.Transform(&matrix);
612 } 612 }
613 CFX_ByteTextBuf buf; 613 CFX_ByteTextBuf buf;
614 buf << "/X" << ps_fontnum << " Ff/CharProcs get begin/" << ps_glyphindex 614 buf << "/X" << ps_fontnum << " Ff/CharProcs get begin/" << ps_glyphindex
615 << "{n "; 615 << "{n ";
616 for (int p = 0; p < TransformedPath.GetPointCount(); p++) { 616 for (int p = 0; p < TransformedPath.GetPointCount(); p++) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 } 656 }
657 if ((pObject2Device->a == 0 && pObject2Device->b == 0) || 657 if ((pObject2Device->a == 0 && pObject2Device->b == 0) ||
658 (pObject2Device->c == 0 && pObject2Device->d == 0)) { 658 (pObject2Device->c == 0 && pObject2Device->d == 0)) {
659 return TRUE; 659 return TRUE;
660 } 660 }
661 SetColor(color, alpha_flag, pIccTransform); 661 SetColor(color, alpha_flag, pIccTransform);
662 CFX_ByteTextBuf buf; 662 CFX_ByteTextBuf buf;
663 buf << "q[" << pObject2Device->a << " " << pObject2Device->b << " " 663 buf << "q[" << pObject2Device->a << " " << pObject2Device->b << " "
664 << pObject2Device->c << " " << pObject2Device->d << " " 664 << pObject2Device->c << " " << pObject2Device->d << " "
665 << pObject2Device->e << " " << pObject2Device->f << "]cm\n"; 665 << pObject2Device->e << " " << pObject2Device->f << "]cm\n";
666 if (pCache == NULL) { 666 if (!pCache) {
667 pCache = CFX_GEModule::Get()->GetFontCache(); 667 pCache = CFX_GEModule::Get()->GetFontCache();
668 } 668 }
669 CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont); 669 CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont);
670 FX_FONTCACHE_DEFINE(pCache, pFont); 670 FX_FONTCACHE_DEFINE(pCache, pFont);
671 int last_fontnum = -1; 671 int last_fontnum = -1;
672 for (int i = 0; i < nChars; i++) { 672 for (int i = 0; i < nChars; i++) {
673 int ps_fontnum, ps_glyphindex; 673 int ps_fontnum, ps_glyphindex;
674 FindPSFontGlyph(pFaceCache, pFont, pCharPos[i], ps_fontnum, ps_glyphindex); 674 FindPSFontGlyph(pFaceCache, pFont, pCharPos[i], ps_fontnum, ps_glyphindex);
675 if (last_fontnum != ps_fontnum) { 675 if (last_fontnum != ps_fontnum) {
676 buf << "/X" << ps_fontnum << " Ff " << font_size << " Fs Sf "; 676 buf << "/X" << ps_fontnum << " Ff " << font_size << " Fs Sf ";
(...skipping 13 matching lines...) Expand all
690 FX_DWORD dest_size; 690 FX_DWORD dest_size;
691 CCodec_ModuleMgr* pEncoders = CFX_GEModule::Get()->GetCodecModule(); 691 CCodec_ModuleMgr* pEncoders = CFX_GEModule::Get()->GetCodecModule();
692 if (pEncoders && 692 if (pEncoders &&
693 pEncoders->GetBasicModule()->A85Encode(data, len, dest_buf, dest_size)) { 693 pEncoders->GetBasicModule()->A85Encode(data, len, dest_buf, dest_size)) {
694 m_pOutput->OutputPS((const FX_CHAR*)dest_buf, dest_size); 694 m_pOutput->OutputPS((const FX_CHAR*)dest_buf, dest_size);
695 FX_Free(dest_buf); 695 FX_Free(dest_buf);
696 } else { 696 } else {
697 m_pOutput->OutputPS((const FX_CHAR*)data, len); 697 m_pOutput->OutputPS((const FX_CHAR*)data, len);
698 } 698 }
699 } 699 }
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