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

Side by Side Diff: core/fpdfapi/fpdf_render/fpdf_render_image.cpp

Issue 2032613003: Get rid of NULLs in core/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: s/NULL/nullptr/ Created 4 years, 6 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
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/fpdfapi/fpdf_render/render_int.h" 7 #include "core/fpdfapi/fpdf_render/render_int.h"
8 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 13 matching lines...) Expand all
24 #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" 24 #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h"
25 #include "core/fpdfdoc/include/fpdf_doc.h" 25 #include "core/fpdfdoc/include/fpdf_doc.h"
26 #include "core/fxcodec/include/fx_codec.h" 26 #include "core/fxcodec/include/fx_codec.h"
27 #include "core/fxcrt/include/fx_safe_types.h" 27 #include "core/fxcrt/include/fx_safe_types.h"
28 #include "core/fxge/include/fx_ge.h" 28 #include "core/fxge/include/fx_ge.h"
29 29
30 FX_BOOL CPDF_RenderStatus::ProcessImage(const CPDF_ImageObject* pImageObj, 30 FX_BOOL CPDF_RenderStatus::ProcessImage(const CPDF_ImageObject* pImageObj,
31 const CFX_Matrix* pObj2Device) { 31 const CFX_Matrix* pObj2Device) {
32 CPDF_ImageRenderer render; 32 CPDF_ImageRenderer render;
33 if (render.Start(this, pImageObj, pObj2Device, m_bStdCS, m_curBlend)) { 33 if (render.Start(this, pImageObj, pObj2Device, m_bStdCS, m_curBlend)) {
34 render.Continue(NULL); 34 render.Continue(nullptr);
35 } 35 }
36 return render.m_Result; 36 return render.m_Result;
37 } 37 }
38 void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, 38 void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap,
39 int left, 39 int left,
40 int top, 40 int top,
41 FX_ARGB mask_argb, 41 FX_ARGB mask_argb,
42 int bitmap_alpha, 42 int bitmap_alpha,
43 int blend_mode, 43 int blend_mode,
44 int Transparency) { 44 int Transparency) {
(...skipping 29 matching lines...) Expand all
74 if (bGetBackGround) { 74 if (bGetBackGround) {
75 if (bIsolated || !bGroup) { 75 if (bIsolated || !bGroup) {
76 if (pDIBitmap->IsAlphaMask()) { 76 if (pDIBitmap->IsAlphaMask()) {
77 return; 77 return;
78 } 78 }
79 m_pDevice->SetDIBitsWithBlend(pDIBitmap, left, top, blend_mode); 79 m_pDevice->SetDIBitsWithBlend(pDIBitmap, left, top, blend_mode);
80 } else { 80 } else {
81 FX_RECT rect(left, top, left + pDIBitmap->GetWidth(), 81 FX_RECT rect(left, top, left + pDIBitmap->GetWidth(),
82 top + pDIBitmap->GetHeight()); 82 top + pDIBitmap->GetHeight());
83 rect.Intersect(m_pDevice->GetClipBox()); 83 rect.Intersect(m_pDevice->GetClipBox());
84 CFX_DIBitmap* pClone = NULL; 84 CFX_DIBitmap* pClone = nullptr;
85 FX_BOOL bClone = FALSE; 85 FX_BOOL bClone = FALSE;
86 if (m_pDevice->GetBackDrop() && m_pDevice->GetBitmap()) { 86 if (m_pDevice->GetBackDrop() && m_pDevice->GetBitmap()) {
87 bClone = TRUE; 87 bClone = TRUE;
88 pClone = m_pDevice->GetBackDrop()->Clone(&rect); 88 pClone = m_pDevice->GetBackDrop()->Clone(&rect);
89 CFX_DIBitmap* pForeBitmap = m_pDevice->GetBitmap(); 89 CFX_DIBitmap* pForeBitmap = m_pDevice->GetBitmap();
90 pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(), 90 pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(),
91 pForeBitmap, rect.left, rect.top); 91 pForeBitmap, rect.left, rect.top);
92 left = left >= 0 ? 0 : left; 92 left = left >= 0 ? 0 : left;
93 top = top >= 0 ? 0 : top; 93 top = top >= 0 ? 0 : top;
94 if (!pDIBitmap->IsAlphaMask()) 94 if (!pDIBitmap->IsAlphaMask())
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 *dest_buf++ = m_RampG[*(src_buf++)]; 300 *dest_buf++ = m_RampG[*(src_buf++)];
301 *dest_buf++ = m_RampR[*(src_buf++)]; 301 *dest_buf++ = m_RampR[*(src_buf++)];
302 *dest_buf++ = *(src_buf++); 302 *dest_buf++ = *(src_buf++);
303 } 303 }
304 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 304 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
305 } 305 }
306 #endif 306 #endif
307 } 307 }
308 } 308 }
309 CPDF_ImageRenderer::CPDF_ImageRenderer() { 309 CPDF_ImageRenderer::CPDF_ImageRenderer() {
310 m_pRenderStatus = NULL; 310 m_pRenderStatus = nullptr;
311 m_pImageObject = NULL; 311 m_pImageObject = nullptr;
312 m_Result = TRUE; 312 m_Result = TRUE;
313 m_Status = 0; 313 m_Status = 0;
314 m_pTransformer = NULL; 314 m_pTransformer = nullptr;
315 m_DeviceHandle = NULL; 315 m_DeviceHandle = nullptr;
316 m_LoadHandle = NULL; 316 m_LoadHandle = nullptr;
317 m_pClone = NULL; 317 m_pClone = nullptr;
318 m_bStdCS = FALSE; 318 m_bStdCS = FALSE;
319 m_bPatternColor = FALSE; 319 m_bPatternColor = FALSE;
320 m_BlendType = FXDIB_BLEND_NORMAL; 320 m_BlendType = FXDIB_BLEND_NORMAL;
321 m_pPattern = NULL; 321 m_pPattern = nullptr;
322 m_pObj2Device = NULL; 322 m_pObj2Device = nullptr;
323 } 323 }
324 CPDF_ImageRenderer::~CPDF_ImageRenderer() { 324 CPDF_ImageRenderer::~CPDF_ImageRenderer() {
325 delete m_pTransformer; 325 delete m_pTransformer;
326 if (m_DeviceHandle) { 326 if (m_DeviceHandle) {
327 m_pRenderStatus->m_pDevice->CancelDIBits(m_DeviceHandle); 327 m_pRenderStatus->m_pDevice->CancelDIBits(m_DeviceHandle);
328 } 328 }
329 delete m_LoadHandle; 329 delete m_LoadHandle;
330 delete m_pClone; 330 delete m_pClone;
331 } 331 }
332 FX_BOOL CPDF_ImageRenderer::StartLoadDIBSource() { 332 FX_BOOL CPDF_ImageRenderer::StartLoadDIBSource() {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 pGeneralState->m_pTransferFunc->TranslateImage(m_Loader.m_pBitmap, 377 pGeneralState->m_pTransferFunc->TranslateImage(m_Loader.m_pBitmap,
378 !m_Loader.m_bCached); 378 !m_Loader.m_bCached);
379 if (m_Loader.m_bCached && m_Loader.m_pMask) { 379 if (m_Loader.m_bCached && m_Loader.m_pMask) {
380 m_Loader.m_pMask = m_Loader.m_pMask->Clone(); 380 m_Loader.m_pMask = m_Loader.m_pMask->Clone();
381 } 381 }
382 m_Loader.m_bCached = FALSE; 382 m_Loader.m_bCached = FALSE;
383 } 383 }
384 } 384 }
385 m_FillArgb = 0; 385 m_FillArgb = 0;
386 m_bPatternColor = FALSE; 386 m_bPatternColor = FALSE;
387 m_pPattern = NULL; 387 m_pPattern = nullptr;
388 if (m_pDIBSource->IsAlphaMask()) { 388 if (m_pDIBSource->IsAlphaMask()) {
389 CPDF_Color* pColor = m_pImageObject->m_ColorState.GetFillColor(); 389 CPDF_Color* pColor = m_pImageObject->m_ColorState.GetFillColor();
390 if (pColor && pColor->IsPattern()) { 390 if (pColor && pColor->IsPattern()) {
391 m_pPattern = pColor->GetPattern(); 391 m_pPattern = pColor->GetPattern();
392 if (m_pPattern) { 392 if (m_pPattern) {
393 m_bPatternColor = TRUE; 393 m_bPatternColor = TRUE;
394 } 394 }
395 } 395 }
396 m_FillArgb = m_pRenderStatus->GetFillArgb(m_pImageObject); 396 m_FillArgb = m_pRenderStatus->GetFillArgb(m_pImageObject);
397 } else if (m_pRenderStatus->m_Options.m_ColorMode == RENDER_COLOR_GRAY) { 397 } else if (m_pRenderStatus->m_Options.m_ColorMode == RENDER_COLOR_GRAY) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 if (m_Loader.m_pMask) { 435 if (m_Loader.m_pMask) {
436 return DrawMaskedImage(); 436 return DrawMaskedImage();
437 } 437 }
438 if (m_bPatternColor) { 438 if (m_bPatternColor) {
439 return DrawPatternImage(m_pObj2Device); 439 return DrawPatternImage(m_pObj2Device);
440 } 440 }
441 if (m_BitmapAlpha == 255 && pGeneralState && pGeneralState->m_FillOP && 441 if (m_BitmapAlpha == 255 && pGeneralState && pGeneralState->m_FillOP &&
442 pGeneralState->m_OPMode == 0 && 442 pGeneralState->m_OPMode == 0 &&
443 pGeneralState->m_BlendType == FXDIB_BLEND_NORMAL && 443 pGeneralState->m_BlendType == FXDIB_BLEND_NORMAL &&
444 pGeneralState->m_StrokeAlpha == 1 && pGeneralState->m_FillAlpha == 1) { 444 pGeneralState->m_StrokeAlpha == 1 && pGeneralState->m_FillAlpha == 1) {
445 CPDF_Document* pDocument = NULL; 445 CPDF_Document* pDocument = nullptr;
446 CPDF_Page* pPage = NULL; 446 CPDF_Page* pPage = nullptr;
447 if (m_pRenderStatus->m_pContext->GetPageCache()) { 447 if (m_pRenderStatus->m_pContext->GetPageCache()) {
448 pPage = m_pRenderStatus->m_pContext->GetPageCache()->GetPage(); 448 pPage = m_pRenderStatus->m_pContext->GetPageCache()->GetPage();
449 pDocument = pPage->m_pDocument; 449 pDocument = pPage->m_pDocument;
450 } else { 450 } else {
451 pDocument = m_pImageObject->m_pImage->GetDocument(); 451 pDocument = m_pImageObject->m_pImage->GetDocument();
452 } 452 }
453 CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : NULL; 453 CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : nullptr;
454 CPDF_Object* pCSObj = 454 CPDF_Object* pCSObj =
455 m_pImageObject->m_pImage->GetStream()->GetDict()->GetDirectObjectBy( 455 m_pImageObject->m_pImage->GetStream()->GetDict()->GetDirectObjectBy(
456 "ColorSpace"); 456 "ColorSpace");
457 CPDF_ColorSpace* pColorSpace = 457 CPDF_ColorSpace* pColorSpace =
458 pDocument->LoadColorSpace(pCSObj, pPageResources); 458 pDocument->LoadColorSpace(pCSObj, pPageResources);
459 if (pColorSpace) { 459 if (pColorSpace) {
460 int format = pColorSpace->GetFamily(); 460 int format = pColorSpace->GetFamily();
461 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION || 461 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION ||
462 format == PDFCS_DEVICEN) { 462 format == PDFCS_DEVICEN) {
463 m_BlendType = FXDIB_BLEND_DARKEN; 463 m_BlendType = FXDIB_BLEND_DARKEN;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 new_matrix.TranslateI(-rect.left, -rect.top); 522 new_matrix.TranslateI(-rect.left, -rect.top);
523 int width = rect.Width(); 523 int width = rect.Width();
524 int height = rect.Height(); 524 int height = rect.Height();
525 CFX_FxgeDevice bitmap_device1; 525 CFX_FxgeDevice bitmap_device1;
526 if (!bitmap_device1.Create(rect.Width(), rect.Height(), FXDIB_Rgb32, nullptr)) 526 if (!bitmap_device1.Create(rect.Width(), rect.Height(), FXDIB_Rgb32, nullptr))
527 return TRUE; 527 return TRUE;
528 528
529 bitmap_device1.GetBitmap()->Clear(0xffffff); 529 bitmap_device1.GetBitmap()->Clear(0xffffff);
530 { 530 {
531 CPDF_RenderStatus bitmap_render; 531 CPDF_RenderStatus bitmap_render;
532 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, NULL, 532 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1,
533 NULL, NULL, NULL, &m_pRenderStatus->m_Options, 0, 533 nullptr, nullptr, nullptr, nullptr,
534 m_pRenderStatus->m_bDropObjects, NULL, TRUE); 534 &m_pRenderStatus->m_Options, 0,
535 m_pRenderStatus->m_bDropObjects, nullptr, TRUE);
535 CFX_Matrix patternDevice = *pObj2Device; 536 CFX_Matrix patternDevice = *pObj2Device;
536 patternDevice.Translate((FX_FLOAT)-rect.left, (FX_FLOAT)-rect.top); 537 patternDevice.Translate((FX_FLOAT)-rect.left, (FX_FLOAT)-rect.top);
537 if (CPDF_TilingPattern* pTilingPattern = m_pPattern->AsTilingPattern()) { 538 if (CPDF_TilingPattern* pTilingPattern = m_pPattern->AsTilingPattern()) {
538 bitmap_render.DrawTilingPattern(pTilingPattern, m_pImageObject, 539 bitmap_render.DrawTilingPattern(pTilingPattern, m_pImageObject,
539 &patternDevice, FALSE); 540 &patternDevice, FALSE);
540 } else if (CPDF_ShadingPattern* pShadingPattern = 541 } else if (CPDF_ShadingPattern* pShadingPattern =
541 m_pPattern->AsShadingPattern()) { 542 m_pPattern->AsShadingPattern()) {
542 bitmap_render.DrawShadingPattern(pShadingPattern, m_pImageObject, 543 bitmap_render.DrawShadingPattern(pShadingPattern, m_pImageObject,
543 &patternDevice, FALSE); 544 &patternDevice, FALSE);
544 } 545 }
545 } 546 }
546 { 547 {
547 CFX_FxgeDevice bitmap_device2; 548 CFX_FxgeDevice bitmap_device2;
548 if (!bitmap_device2.Create(rect.Width(), rect.Height(), FXDIB_8bppRgb, 549 if (!bitmap_device2.Create(rect.Width(), rect.Height(), FXDIB_8bppRgb,
549 nullptr)) { 550 nullptr)) {
550 return TRUE; 551 return TRUE;
551 } 552 }
552 bitmap_device2.GetBitmap()->Clear(0); 553 bitmap_device2.GetBitmap()->Clear(0);
553 CPDF_RenderStatus bitmap_render; 554 CPDF_RenderStatus bitmap_render;
554 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2, NULL, 555 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2,
555 NULL, NULL, NULL, NULL, 0, 556 nullptr, nullptr, nullptr, nullptr, nullptr, 0,
556 m_pRenderStatus->m_bDropObjects, NULL, TRUE); 557 m_pRenderStatus->m_bDropObjects, nullptr, TRUE);
557 CPDF_ImageRenderer image_render; 558 CPDF_ImageRenderer image_render;
558 if (image_render.Start(&bitmap_render, m_pDIBSource, 0xffffffff, 255, 559 if (image_render.Start(&bitmap_render, m_pDIBSource, 0xffffffff, 255,
559 &new_matrix, m_Flags, TRUE)) { 560 &new_matrix, m_Flags, TRUE)) {
560 image_render.Continue(NULL); 561 image_render.Continue(nullptr);
561 } 562 }
562 if (m_Loader.m_MatteColor != 0xffffffff) { 563 if (m_Loader.m_MatteColor != 0xffffffff) {
563 int matte_r = FXARGB_R(m_Loader.m_MatteColor); 564 int matte_r = FXARGB_R(m_Loader.m_MatteColor);
564 int matte_g = FXARGB_G(m_Loader.m_MatteColor); 565 int matte_g = FXARGB_G(m_Loader.m_MatteColor);
565 int matte_b = FXARGB_B(m_Loader.m_MatteColor); 566 int matte_b = FXARGB_B(m_Loader.m_MatteColor);
566 for (int row = 0; row < height; row++) { 567 for (int row = 0; row < height; row++) {
567 uint8_t* dest_scan = 568 uint8_t* dest_scan =
568 (uint8_t*)bitmap_device1.GetBitmap()->GetScanline(row); 569 (uint8_t*)bitmap_device1.GetBitmap()->GetScanline(row);
569 const uint8_t* mask_scan = bitmap_device2.GetBitmap()->GetScanline(row); 570 const uint8_t* mask_scan = bitmap_device2.GetBitmap()->GetScanline(row);
570 for (int col = 0; col < width; col++) { 571 for (int col = 0; col < width; col++) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 new_matrix.TranslateI(-rect.left, -rect.top); 622 new_matrix.TranslateI(-rect.left, -rect.top);
622 int width = rect.Width(); 623 int width = rect.Width();
623 int height = rect.Height(); 624 int height = rect.Height();
624 CFX_FxgeDevice bitmap_device1; 625 CFX_FxgeDevice bitmap_device1;
625 if (!bitmap_device1.Create(width, height, FXDIB_Rgb32, nullptr)) 626 if (!bitmap_device1.Create(width, height, FXDIB_Rgb32, nullptr))
626 return TRUE; 627 return TRUE;
627 628
628 bitmap_device1.GetBitmap()->Clear(0xffffff); 629 bitmap_device1.GetBitmap()->Clear(0xffffff);
629 { 630 {
630 CPDF_RenderStatus bitmap_render; 631 CPDF_RenderStatus bitmap_render;
631 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, NULL, 632 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1,
632 NULL, NULL, NULL, NULL, 0, 633 nullptr, nullptr, nullptr, nullptr, nullptr, 0,
633 m_pRenderStatus->m_bDropObjects, NULL, TRUE); 634 m_pRenderStatus->m_bDropObjects, nullptr, TRUE);
634 CPDF_ImageRenderer image_render; 635 CPDF_ImageRenderer image_render;
635 if (image_render.Start(&bitmap_render, m_pDIBSource, 0, 255, &new_matrix, 636 if (image_render.Start(&bitmap_render, m_pDIBSource, 0, 255, &new_matrix,
636 m_Flags, TRUE)) { 637 m_Flags, TRUE)) {
637 image_render.Continue(NULL); 638 image_render.Continue(nullptr);
638 } 639 }
639 } 640 }
640 { 641 {
641 CFX_FxgeDevice bitmap_device2; 642 CFX_FxgeDevice bitmap_device2;
642 if (!bitmap_device2.Create(width, height, FXDIB_8bppRgb, nullptr)) 643 if (!bitmap_device2.Create(width, height, FXDIB_8bppRgb, nullptr))
643 return TRUE; 644 return TRUE;
644 645
645 bitmap_device2.GetBitmap()->Clear(0); 646 bitmap_device2.GetBitmap()->Clear(0);
646 CPDF_RenderStatus bitmap_render; 647 CPDF_RenderStatus bitmap_render;
647 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2, NULL, 648 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2,
648 NULL, NULL, NULL, NULL, 0, 649 nullptr, nullptr, nullptr, nullptr, nullptr, 0,
649 m_pRenderStatus->m_bDropObjects, NULL, TRUE); 650 m_pRenderStatus->m_bDropObjects, nullptr, TRUE);
650 CPDF_ImageRenderer image_render; 651 CPDF_ImageRenderer image_render;
651 if (image_render.Start(&bitmap_render, m_Loader.m_pMask, 0xffffffff, 255, 652 if (image_render.Start(&bitmap_render, m_Loader.m_pMask, 0xffffffff, 255,
652 &new_matrix, m_Flags, TRUE)) { 653 &new_matrix, m_Flags, TRUE)) {
653 image_render.Continue(NULL); 654 image_render.Continue(nullptr);
654 } 655 }
655 if (m_Loader.m_MatteColor != 0xffffffff) { 656 if (m_Loader.m_MatteColor != 0xffffffff) {
656 int matte_r = FXARGB_R(m_Loader.m_MatteColor); 657 int matte_r = FXARGB_R(m_Loader.m_MatteColor);
657 int matte_g = FXARGB_G(m_Loader.m_MatteColor); 658 int matte_g = FXARGB_G(m_Loader.m_MatteColor);
658 int matte_b = FXARGB_B(m_Loader.m_MatteColor); 659 int matte_b = FXARGB_B(m_Loader.m_MatteColor);
659 for (int row = 0; row < height; row++) { 660 for (int row = 0; row < height; row++) {
660 uint8_t* dest_scan = 661 uint8_t* dest_scan =
661 (uint8_t*)bitmap_device1.GetBitmap()->GetScanline(row); 662 (uint8_t*)bitmap_device1.GetBitmap()->GetScanline(row);
662 const uint8_t* mask_scan = bitmap_device2.GetBitmap()->GetScanline(row); 663 const uint8_t* mask_scan = bitmap_device2.GetBitmap()->GetScanline(row);
663 for (int col = 0; col < width; col++) { 664 for (int col = 0; col < width; col++) {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 return FALSE; 786 return FALSE;
786 } 787 }
787 788
788 FX_BOOL CPDF_ImageRenderer::StartBitmapAlpha() { 789 FX_BOOL CPDF_ImageRenderer::StartBitmapAlpha() {
789 if (m_pDIBSource->IsOpaqueImage()) { 790 if (m_pDIBSource->IsOpaqueImage()) {
790 CFX_PathData path; 791 CFX_PathData path;
791 path.AppendRect(0, 0, 1, 1); 792 path.AppendRect(0, 0, 1, 1);
792 path.Transform(&m_ImageMatrix); 793 path.Transform(&m_ImageMatrix);
793 uint32_t fill_color = 794 uint32_t fill_color =
794 ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha); 795 ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha);
795 m_pRenderStatus->m_pDevice->DrawPath(&path, NULL, NULL, fill_color, 0, 796 m_pRenderStatus->m_pDevice->DrawPath(&path, nullptr, nullptr, fill_color, 0,
796 FXFILL_WINDING); 797 FXFILL_WINDING);
797 } else { 798 } else {
798 const CFX_DIBSource* pAlphaMask = m_pDIBSource->IsAlphaMask() 799 const CFX_DIBSource* pAlphaMask = m_pDIBSource->IsAlphaMask()
799 ? m_pDIBSource 800 ? m_pDIBSource
800 : m_pDIBSource->GetAlphaMask(); 801 : m_pDIBSource->GetAlphaMask();
801 if (FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || 802 if (FXSYS_fabs(m_ImageMatrix.b) >= 0.5f ||
802 FXSYS_fabs(m_ImageMatrix.c) >= 0.5f) { 803 FXSYS_fabs(m_ImageMatrix.c) >= 0.5f) {
803 int left, top; 804 int left, top;
804 std::unique_ptr<CFX_DIBitmap> pTransformed( 805 std::unique_ptr<CFX_DIBitmap> pTransformed(
805 pAlphaMask->TransformTo(&m_ImageMatrix, left, top)); 806 pAlphaMask->TransformTo(&m_ImageMatrix, left, top));
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 FXDIB_Format format; 905 FXDIB_Format format;
905 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 906 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
906 format = bLuminosity ? FXDIB_Rgb32 : FXDIB_8bppMask; 907 format = bLuminosity ? FXDIB_Rgb32 : FXDIB_8bppMask;
907 #else 908 #else
908 format = bLuminosity ? FXDIB_Rgb : FXDIB_8bppMask; 909 format = bLuminosity ? FXDIB_Rgb : FXDIB_8bppMask;
909 #endif 910 #endif
910 if (!bitmap_device.Create(width, height, format, nullptr)) 911 if (!bitmap_device.Create(width, height, format, nullptr))
911 return nullptr; 912 return nullptr;
912 913
913 CFX_DIBitmap& bitmap = *bitmap_device.GetBitmap(); 914 CFX_DIBitmap& bitmap = *bitmap_device.GetBitmap();
914 CPDF_Object* pCSObj = NULL; 915 CPDF_Object* pCSObj = nullptr;
915 CPDF_ColorSpace* pCS = NULL; 916 CPDF_ColorSpace* pCS = nullptr;
916 if (bLuminosity) { 917 if (bLuminosity) {
917 CPDF_Array* pBC = pSMaskDict->GetArrayBy("BC"); 918 CPDF_Array* pBC = pSMaskDict->GetArrayBy("BC");
918 FX_ARGB back_color = 0xff000000; 919 FX_ARGB back_color = 0xff000000;
919 if (pBC) { 920 if (pBC) {
920 CPDF_Dictionary* pDict = pGroup->GetDict(); 921 CPDF_Dictionary* pDict = pGroup->GetDict();
921 if (pDict && pDict->GetDictBy("Group")) 922 if (pDict && pDict->GetDictBy("Group"))
922 pCSObj = pDict->GetDictBy("Group")->GetDirectObjectBy("CS"); 923 pCSObj = pDict->GetDictBy("Group")->GetDirectObjectBy("CS");
923 else 924 else
924 pCSObj = NULL; 925 pCSObj = nullptr;
925 pCS = m_pContext->GetDocument()->LoadColorSpace(pCSObj); 926 pCS = m_pContext->GetDocument()->LoadColorSpace(pCSObj);
926 if (pCS) { 927 if (pCS) {
927 FX_FLOAT R, G, B; 928 FX_FLOAT R, G, B;
928 uint32_t comps = 8; 929 uint32_t comps = 8;
929 if (pCS->CountComponents() > comps) { 930 if (pCS->CountComponents() > comps) {
930 comps = pCS->CountComponents(); 931 comps = pCS->CountComponents();
931 } 932 }
932 CFX_FixedBufGrow<FX_FLOAT, 8> float_array(comps); 933 CFX_FixedBufGrow<FX_FLOAT, 8> float_array(comps);
933 FX_FLOAT* pFloats = float_array; 934 FX_FLOAT* pFloats = float_array;
934 FX_SAFE_UINT32 num_floats = comps; 935 FX_SAFE_UINT32 num_floats = comps;
935 num_floats *= sizeof(FX_FLOAT); 936 num_floats *= sizeof(FX_FLOAT);
936 if (!num_floats.IsValid()) { 937 if (!num_floats.IsValid()) {
937 return NULL; 938 return nullptr;
938 } 939 }
939 FXSYS_memset(pFloats, 0, num_floats.ValueOrDie()); 940 FXSYS_memset(pFloats, 0, num_floats.ValueOrDie());
940 size_t count = pBC->GetCount() > 8 ? 8 : pBC->GetCount(); 941 size_t count = pBC->GetCount() > 8 ? 8 : pBC->GetCount();
941 for (size_t i = 0; i < count; i++) { 942 for (size_t i = 0; i < count; i++) {
942 pFloats[i] = pBC->GetNumberAt(i); 943 pFloats[i] = pBC->GetNumberAt(i);
943 } 944 }
944 pCS->GetRGB(pFloats, R, G, B); 945 pCS->GetRGB(pFloats, R, G, B);
945 back_color = 0xff000000 | ((int32_t)(R * 255) << 16) | 946 back_color = 0xff000000 | ((int32_t)(R * 255) << 16) |
946 ((int32_t)(G * 255) << 8) | (int32_t)(B * 255); 947 ((int32_t)(G * 255) << 8) | (int32_t)(B * 255);
947 m_pContext->GetDocument()->GetPageData()->ReleaseColorSpace(pCSObj); 948 m_pContext->GetDocument()->GetPageData()->ReleaseColorSpace(pCSObj);
948 } 949 }
949 } 950 }
950 bitmap.Clear(back_color); 951 bitmap.Clear(back_color);
951 } else { 952 } else {
952 bitmap.Clear(0); 953 bitmap.Clear(0);
953 } 954 }
954 CPDF_Dictionary* pFormResource = NULL; 955 CPDF_Dictionary* pFormResource = nullptr;
955 if (form.m_pFormDict) { 956 if (form.m_pFormDict) {
956 pFormResource = form.m_pFormDict->GetDictBy("Resources"); 957 pFormResource = form.m_pFormDict->GetDictBy("Resources");
957 } 958 }
958 CPDF_RenderOptions options; 959 CPDF_RenderOptions options;
959 options.m_ColorMode = bLuminosity ? RENDER_COLOR_NORMAL : RENDER_COLOR_ALPHA; 960 options.m_ColorMode = bLuminosity ? RENDER_COLOR_NORMAL : RENDER_COLOR_ALPHA;
960 CPDF_RenderStatus status; 961 CPDF_RenderStatus status;
961 status.Initialize(m_pContext, &bitmap_device, NULL, NULL, NULL, NULL, 962 status.Initialize(m_pContext, &bitmap_device, nullptr, nullptr, nullptr,
962 &options, 0, m_bDropObjects, pFormResource, TRUE, NULL, 0, 963 nullptr, &options, 0, m_bDropObjects, pFormResource, TRUE,
963 pCS ? pCS->GetFamily() : 0, bLuminosity); 964 nullptr, 0, pCS ? pCS->GetFamily() : 0, bLuminosity);
964 status.RenderObjectList(&form, &matrix); 965 status.RenderObjectList(&form, &matrix);
965 std::unique_ptr<CFX_DIBitmap> pMask(new CFX_DIBitmap); 966 std::unique_ptr<CFX_DIBitmap> pMask(new CFX_DIBitmap);
966 if (!pMask->Create(width, height, FXDIB_8bppMask)) 967 if (!pMask->Create(width, height, FXDIB_8bppMask))
967 return nullptr; 968 return nullptr;
968 969
969 uint8_t* dest_buf = pMask->GetBuffer(); 970 uint8_t* dest_buf = pMask->GetBuffer();
970 int dest_pitch = pMask->GetPitch(); 971 int dest_pitch = pMask->GetPitch();
971 uint8_t* src_buf = bitmap.GetBuffer(); 972 uint8_t* src_buf = bitmap.GetBuffer();
972 int src_pitch = bitmap.GetPitch(); 973 int src_pitch = bitmap.GetPitch();
973 std::vector<uint8_t> transfers(256); 974 std::vector<uint8_t> transfers(256);
(...skipping 23 matching lines...) Expand all
997 } else if (pFunc) { 998 } else if (pFunc) {
998 int size = dest_pitch * height; 999 int size = dest_pitch * height;
999 for (int i = 0; i < size; i++) { 1000 for (int i = 0; i < size; i++) {
1000 dest_buf[i] = transfers[src_buf[i]]; 1001 dest_buf[i] = transfers[src_buf[i]];
1001 } 1002 }
1002 } else { 1003 } else {
1003 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); 1004 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height);
1004 } 1005 }
1005 return pMask.release(); 1006 return pMask.release();
1006 } 1007 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698