| OLD | NEW |
| 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 Loading... |
| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 if (bGetBackGround) { | 82 if (bGetBackGround) { |
| 83 if (bIsolated || !bGroup) { | 83 if (bIsolated || !bGroup) { |
| 84 if (pDIBitmap->IsAlphaMask()) { | 84 if (pDIBitmap->IsAlphaMask()) { |
| 85 return; | 85 return; |
| 86 } | 86 } |
| 87 m_pDevice->SetDIBitsWithBlend(pDIBitmap, left, top, blend_mode); | 87 m_pDevice->SetDIBitsWithBlend(pDIBitmap, left, top, blend_mode); |
| 88 } else { | 88 } else { |
| 89 FX_RECT rect(left, top, left + pDIBitmap->GetWidth(), | 89 FX_RECT rect(left, top, left + pDIBitmap->GetWidth(), |
| 90 top + pDIBitmap->GetHeight()); | 90 top + pDIBitmap->GetHeight()); |
| 91 rect.Intersect(m_pDevice->GetClipBox()); | 91 rect.Intersect(m_pDevice->GetClipBox()); |
| 92 CFX_DIBitmap* pClone = NULL; | 92 CFX_DIBitmap* pClone = nullptr; |
| 93 FX_BOOL bClone = FALSE; | 93 FX_BOOL bClone = FALSE; |
| 94 if (m_pDevice->GetBackDrop() && m_pDevice->GetBitmap()) { | 94 if (m_pDevice->GetBackDrop() && m_pDevice->GetBitmap()) { |
| 95 bClone = TRUE; | 95 bClone = TRUE; |
| 96 pClone = m_pDevice->GetBackDrop()->Clone(&rect); | 96 pClone = m_pDevice->GetBackDrop()->Clone(&rect); |
| 97 CFX_DIBitmap* pForeBitmap = m_pDevice->GetBitmap(); | 97 CFX_DIBitmap* pForeBitmap = m_pDevice->GetBitmap(); |
| 98 pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(), | 98 pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(), |
| 99 pForeBitmap, rect.left, rect.top); | 99 pForeBitmap, rect.left, rect.top); |
| 100 left = left >= 0 ? 0 : left; | 100 left = left >= 0 ? 0 : left; |
| 101 top = top >= 0 ? 0 : top; | 101 top = top >= 0 ? 0 : top; |
| 102 if (!pDIBitmap->IsAlphaMask()) | 102 if (!pDIBitmap->IsAlphaMask()) |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 *dest_buf++ = m_RampG[*(src_buf++)]; | 308 *dest_buf++ = m_RampG[*(src_buf++)]; |
| 309 *dest_buf++ = m_RampR[*(src_buf++)]; | 309 *dest_buf++ = m_RampR[*(src_buf++)]; |
| 310 *dest_buf++ = *(src_buf++); | 310 *dest_buf++ = *(src_buf++); |
| 311 } | 311 } |
| 312 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 312 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| 313 } | 313 } |
| 314 #endif | 314 #endif |
| 315 } | 315 } |
| 316 } | 316 } |
| 317 CPDF_ImageRenderer::CPDF_ImageRenderer() { | 317 CPDF_ImageRenderer::CPDF_ImageRenderer() { |
| 318 m_pRenderStatus = NULL; | 318 m_pRenderStatus = nullptr; |
| 319 m_pImageObject = NULL; | 319 m_pImageObject = nullptr; |
| 320 m_Result = TRUE; | 320 m_Result = TRUE; |
| 321 m_Status = 0; | 321 m_Status = 0; |
| 322 m_pTransformer = NULL; | 322 m_pTransformer = nullptr; |
| 323 m_DeviceHandle = NULL; | 323 m_DeviceHandle = nullptr; |
| 324 m_LoadHandle = NULL; | 324 m_LoadHandle = nullptr; |
| 325 m_pClone = NULL; | 325 m_pClone = nullptr; |
| 326 m_bStdCS = FALSE; | 326 m_bStdCS = FALSE; |
| 327 m_bPatternColor = FALSE; | 327 m_bPatternColor = FALSE; |
| 328 m_BlendType = FXDIB_BLEND_NORMAL; | 328 m_BlendType = FXDIB_BLEND_NORMAL; |
| 329 m_pPattern = NULL; | 329 m_pPattern = nullptr; |
| 330 m_pObj2Device = NULL; | 330 m_pObj2Device = nullptr; |
| 331 } | 331 } |
| 332 CPDF_ImageRenderer::~CPDF_ImageRenderer() { | 332 CPDF_ImageRenderer::~CPDF_ImageRenderer() { |
| 333 delete m_pTransformer; | 333 delete m_pTransformer; |
| 334 if (m_DeviceHandle) { | 334 if (m_DeviceHandle) { |
| 335 m_pRenderStatus->m_pDevice->CancelDIBits(m_DeviceHandle); | 335 m_pRenderStatus->m_pDevice->CancelDIBits(m_DeviceHandle); |
| 336 } | 336 } |
| 337 delete m_LoadHandle; | 337 delete m_LoadHandle; |
| 338 delete m_pClone; | 338 delete m_pClone; |
| 339 } | 339 } |
| 340 FX_BOOL CPDF_ImageRenderer::StartLoadDIBSource() { | 340 FX_BOOL CPDF_ImageRenderer::StartLoadDIBSource() { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 pGeneralState->m_pTransferFunc->TranslateImage(m_Loader.m_pBitmap, | 385 pGeneralState->m_pTransferFunc->TranslateImage(m_Loader.m_pBitmap, |
| 386 !m_Loader.m_bCached); | 386 !m_Loader.m_bCached); |
| 387 if (m_Loader.m_bCached && m_Loader.m_pMask) { | 387 if (m_Loader.m_bCached && m_Loader.m_pMask) { |
| 388 m_Loader.m_pMask = m_Loader.m_pMask->Clone(); | 388 m_Loader.m_pMask = m_Loader.m_pMask->Clone(); |
| 389 } | 389 } |
| 390 m_Loader.m_bCached = FALSE; | 390 m_Loader.m_bCached = FALSE; |
| 391 } | 391 } |
| 392 } | 392 } |
| 393 m_FillArgb = 0; | 393 m_FillArgb = 0; |
| 394 m_bPatternColor = FALSE; | 394 m_bPatternColor = FALSE; |
| 395 m_pPattern = NULL; | 395 m_pPattern = nullptr; |
| 396 if (m_pDIBSource->IsAlphaMask()) { | 396 if (m_pDIBSource->IsAlphaMask()) { |
| 397 CPDF_Color* pColor = m_pImageObject->m_ColorState.GetFillColor(); | 397 CPDF_Color* pColor = m_pImageObject->m_ColorState.GetFillColor(); |
| 398 if (pColor && pColor->IsPattern()) { | 398 if (pColor && pColor->IsPattern()) { |
| 399 m_pPattern = pColor->GetPattern(); | 399 m_pPattern = pColor->GetPattern(); |
| 400 if (m_pPattern) { | 400 if (m_pPattern) { |
| 401 m_bPatternColor = TRUE; | 401 m_bPatternColor = TRUE; |
| 402 } | 402 } |
| 403 } | 403 } |
| 404 m_FillArgb = m_pRenderStatus->GetFillArgb(m_pImageObject); | 404 m_FillArgb = m_pRenderStatus->GetFillArgb(m_pImageObject); |
| 405 } else if (m_pRenderStatus->m_Options.m_ColorMode == RENDER_COLOR_GRAY) { | 405 } else if (m_pRenderStatus->m_Options.m_ColorMode == RENDER_COLOR_GRAY) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 if (m_Loader.m_pMask) { | 443 if (m_Loader.m_pMask) { |
| 444 return DrawMaskedImage(); | 444 return DrawMaskedImage(); |
| 445 } | 445 } |
| 446 if (m_bPatternColor) { | 446 if (m_bPatternColor) { |
| 447 return DrawPatternImage(m_pObj2Device); | 447 return DrawPatternImage(m_pObj2Device); |
| 448 } | 448 } |
| 449 if (m_BitmapAlpha == 255 && pGeneralState && pGeneralState->m_FillOP && | 449 if (m_BitmapAlpha == 255 && pGeneralState && pGeneralState->m_FillOP && |
| 450 pGeneralState->m_OPMode == 0 && | 450 pGeneralState->m_OPMode == 0 && |
| 451 pGeneralState->m_BlendType == FXDIB_BLEND_NORMAL && | 451 pGeneralState->m_BlendType == FXDIB_BLEND_NORMAL && |
| 452 pGeneralState->m_StrokeAlpha == 1 && pGeneralState->m_FillAlpha == 1) { | 452 pGeneralState->m_StrokeAlpha == 1 && pGeneralState->m_FillAlpha == 1) { |
| 453 CPDF_Document* pDocument = NULL; | 453 CPDF_Document* pDocument = nullptr; |
| 454 CPDF_Page* pPage = NULL; | 454 CPDF_Page* pPage = nullptr; |
| 455 if (m_pRenderStatus->m_pContext->GetPageCache()) { | 455 if (m_pRenderStatus->m_pContext->GetPageCache()) { |
| 456 pPage = m_pRenderStatus->m_pContext->GetPageCache()->GetPage(); | 456 pPage = m_pRenderStatus->m_pContext->GetPageCache()->GetPage(); |
| 457 pDocument = pPage->m_pDocument; | 457 pDocument = pPage->m_pDocument; |
| 458 } else { | 458 } else { |
| 459 pDocument = m_pImageObject->m_pImage->GetDocument(); | 459 pDocument = m_pImageObject->m_pImage->GetDocument(); |
| 460 } | 460 } |
| 461 CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : NULL; | 461 CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : nullptr; |
| 462 CPDF_Object* pCSObj = | 462 CPDF_Object* pCSObj = |
| 463 m_pImageObject->m_pImage->GetStream()->GetDict()->GetDirectObjectBy( | 463 m_pImageObject->m_pImage->GetStream()->GetDict()->GetDirectObjectBy( |
| 464 "ColorSpace"); | 464 "ColorSpace"); |
| 465 CPDF_ColorSpace* pColorSpace = | 465 CPDF_ColorSpace* pColorSpace = |
| 466 pDocument->LoadColorSpace(pCSObj, pPageResources); | 466 pDocument->LoadColorSpace(pCSObj, pPageResources); |
| 467 if (pColorSpace) { | 467 if (pColorSpace) { |
| 468 int format = pColorSpace->GetFamily(); | 468 int format = pColorSpace->GetFamily(); |
| 469 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION || | 469 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION || |
| 470 format == PDFCS_DEVICEN) { | 470 format == PDFCS_DEVICEN) { |
| 471 m_BlendType = FXDIB_BLEND_DARKEN; | 471 m_BlendType = FXDIB_BLEND_DARKEN; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 new_matrix.TranslateI(-rect.left, -rect.top); | 530 new_matrix.TranslateI(-rect.left, -rect.top); |
| 531 int width = rect.Width(); | 531 int width = rect.Width(); |
| 532 int height = rect.Height(); | 532 int height = rect.Height(); |
| 533 CFX_FxgeDevice bitmap_device1; | 533 CFX_FxgeDevice bitmap_device1; |
| 534 if (!bitmap_device1.Create(rect.Width(), rect.Height(), FXDIB_Rgb32, nullptr)) | 534 if (!bitmap_device1.Create(rect.Width(), rect.Height(), FXDIB_Rgb32, nullptr)) |
| 535 return TRUE; | 535 return TRUE; |
| 536 | 536 |
| 537 bitmap_device1.GetBitmap()->Clear(0xffffff); | 537 bitmap_device1.GetBitmap()->Clear(0xffffff); |
| 538 { | 538 { |
| 539 CPDF_RenderStatus bitmap_render; | 539 CPDF_RenderStatus bitmap_render; |
| 540 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, NULL, | 540 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, |
| 541 NULL, NULL, NULL, &m_pRenderStatus->m_Options, 0, | 541 nullptr, nullptr, nullptr, nullptr, |
| 542 m_pRenderStatus->m_bDropObjects, NULL, TRUE); | 542 &m_pRenderStatus->m_Options, 0, |
| 543 m_pRenderStatus->m_bDropObjects, nullptr, TRUE); |
| 543 CFX_Matrix patternDevice = *pObj2Device; | 544 CFX_Matrix patternDevice = *pObj2Device; |
| 544 patternDevice.Translate((FX_FLOAT)-rect.left, (FX_FLOAT)-rect.top); | 545 patternDevice.Translate((FX_FLOAT)-rect.left, (FX_FLOAT)-rect.top); |
| 545 if (CPDF_TilingPattern* pTilingPattern = m_pPattern->AsTilingPattern()) { | 546 if (CPDF_TilingPattern* pTilingPattern = m_pPattern->AsTilingPattern()) { |
| 546 bitmap_render.DrawTilingPattern(pTilingPattern, m_pImageObject, | 547 bitmap_render.DrawTilingPattern(pTilingPattern, m_pImageObject, |
| 547 &patternDevice, FALSE); | 548 &patternDevice, FALSE); |
| 548 } else if (CPDF_ShadingPattern* pShadingPattern = | 549 } else if (CPDF_ShadingPattern* pShadingPattern = |
| 549 m_pPattern->AsShadingPattern()) { | 550 m_pPattern->AsShadingPattern()) { |
| 550 bitmap_render.DrawShadingPattern(pShadingPattern, m_pImageObject, | 551 bitmap_render.DrawShadingPattern(pShadingPattern, m_pImageObject, |
| 551 &patternDevice, FALSE); | 552 &patternDevice, FALSE); |
| 552 } | 553 } |
| 553 } | 554 } |
| 554 { | 555 { |
| 555 CFX_FxgeDevice bitmap_device2; | 556 CFX_FxgeDevice bitmap_device2; |
| 556 if (!bitmap_device2.Create(rect.Width(), rect.Height(), FXDIB_8bppRgb, | 557 if (!bitmap_device2.Create(rect.Width(), rect.Height(), FXDIB_8bppRgb, |
| 557 nullptr)) { | 558 nullptr)) { |
| 558 return TRUE; | 559 return TRUE; |
| 559 } | 560 } |
| 560 bitmap_device2.GetBitmap()->Clear(0); | 561 bitmap_device2.GetBitmap()->Clear(0); |
| 561 CPDF_RenderStatus bitmap_render; | 562 CPDF_RenderStatus bitmap_render; |
| 562 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2, NULL, | 563 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2, |
| 563 NULL, NULL, NULL, NULL, 0, | 564 nullptr, nullptr, nullptr, nullptr, nullptr, 0, |
| 564 m_pRenderStatus->m_bDropObjects, NULL, TRUE); | 565 m_pRenderStatus->m_bDropObjects, nullptr, TRUE); |
| 565 CPDF_ImageRenderer image_render; | 566 CPDF_ImageRenderer image_render; |
| 566 if (image_render.Start(&bitmap_render, m_pDIBSource, 0xffffffff, 255, | 567 if (image_render.Start(&bitmap_render, m_pDIBSource, 0xffffffff, 255, |
| 567 &new_matrix, m_Flags, TRUE)) { | 568 &new_matrix, m_Flags, TRUE)) { |
| 568 image_render.Continue(NULL); | 569 image_render.Continue(nullptr); |
| 569 } | 570 } |
| 570 if (m_Loader.m_MatteColor != 0xffffffff) { | 571 if (m_Loader.m_MatteColor != 0xffffffff) { |
| 571 int matte_r = FXARGB_R(m_Loader.m_MatteColor); | 572 int matte_r = FXARGB_R(m_Loader.m_MatteColor); |
| 572 int matte_g = FXARGB_G(m_Loader.m_MatteColor); | 573 int matte_g = FXARGB_G(m_Loader.m_MatteColor); |
| 573 int matte_b = FXARGB_B(m_Loader.m_MatteColor); | 574 int matte_b = FXARGB_B(m_Loader.m_MatteColor); |
| 574 for (int row = 0; row < height; row++) { | 575 for (int row = 0; row < height; row++) { |
| 575 uint8_t* dest_scan = | 576 uint8_t* dest_scan = |
| 576 (uint8_t*)bitmap_device1.GetBitmap()->GetScanline(row); | 577 (uint8_t*)bitmap_device1.GetBitmap()->GetScanline(row); |
| 577 const uint8_t* mask_scan = bitmap_device2.GetBitmap()->GetScanline(row); | 578 const uint8_t* mask_scan = bitmap_device2.GetBitmap()->GetScanline(row); |
| 578 for (int col = 0; col < width; col++) { | 579 for (int col = 0; col < width; col++) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 new_matrix.TranslateI(-rect.left, -rect.top); | 630 new_matrix.TranslateI(-rect.left, -rect.top); |
| 630 int width = rect.Width(); | 631 int width = rect.Width(); |
| 631 int height = rect.Height(); | 632 int height = rect.Height(); |
| 632 CFX_FxgeDevice bitmap_device1; | 633 CFX_FxgeDevice bitmap_device1; |
| 633 if (!bitmap_device1.Create(width, height, FXDIB_Rgb32, nullptr)) | 634 if (!bitmap_device1.Create(width, height, FXDIB_Rgb32, nullptr)) |
| 634 return TRUE; | 635 return TRUE; |
| 635 | 636 |
| 636 bitmap_device1.GetBitmap()->Clear(0xffffff); | 637 bitmap_device1.GetBitmap()->Clear(0xffffff); |
| 637 { | 638 { |
| 638 CPDF_RenderStatus bitmap_render; | 639 CPDF_RenderStatus bitmap_render; |
| 639 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, NULL, | 640 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, |
| 640 NULL, NULL, NULL, NULL, 0, | 641 nullptr, nullptr, nullptr, nullptr, nullptr, 0, |
| 641 m_pRenderStatus->m_bDropObjects, NULL, TRUE); | 642 m_pRenderStatus->m_bDropObjects, nullptr, TRUE); |
| 642 CPDF_ImageRenderer image_render; | 643 CPDF_ImageRenderer image_render; |
| 643 if (image_render.Start(&bitmap_render, m_pDIBSource, 0, 255, &new_matrix, | 644 if (image_render.Start(&bitmap_render, m_pDIBSource, 0, 255, &new_matrix, |
| 644 m_Flags, TRUE)) { | 645 m_Flags, TRUE)) { |
| 645 image_render.Continue(NULL); | 646 image_render.Continue(nullptr); |
| 646 } | 647 } |
| 647 } | 648 } |
| 648 { | 649 { |
| 649 CFX_FxgeDevice bitmap_device2; | 650 CFX_FxgeDevice bitmap_device2; |
| 650 if (!bitmap_device2.Create(width, height, FXDIB_8bppRgb, nullptr)) | 651 if (!bitmap_device2.Create(width, height, FXDIB_8bppRgb, nullptr)) |
| 651 return TRUE; | 652 return TRUE; |
| 652 | 653 |
| 653 bitmap_device2.GetBitmap()->Clear(0); | 654 bitmap_device2.GetBitmap()->Clear(0); |
| 654 CPDF_RenderStatus bitmap_render; | 655 CPDF_RenderStatus bitmap_render; |
| 655 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2, NULL, | 656 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2, |
| 656 NULL, NULL, NULL, NULL, 0, | 657 nullptr, nullptr, nullptr, nullptr, nullptr, 0, |
| 657 m_pRenderStatus->m_bDropObjects, NULL, TRUE); | 658 m_pRenderStatus->m_bDropObjects, nullptr, TRUE); |
| 658 CPDF_ImageRenderer image_render; | 659 CPDF_ImageRenderer image_render; |
| 659 if (image_render.Start(&bitmap_render, m_Loader.m_pMask, 0xffffffff, 255, | 660 if (image_render.Start(&bitmap_render, m_Loader.m_pMask, 0xffffffff, 255, |
| 660 &new_matrix, m_Flags, TRUE)) { | 661 &new_matrix, m_Flags, TRUE)) { |
| 661 image_render.Continue(NULL); | 662 image_render.Continue(nullptr); |
| 662 } | 663 } |
| 663 if (m_Loader.m_MatteColor != 0xffffffff) { | 664 if (m_Loader.m_MatteColor != 0xffffffff) { |
| 664 int matte_r = FXARGB_R(m_Loader.m_MatteColor); | 665 int matte_r = FXARGB_R(m_Loader.m_MatteColor); |
| 665 int matte_g = FXARGB_G(m_Loader.m_MatteColor); | 666 int matte_g = FXARGB_G(m_Loader.m_MatteColor); |
| 666 int matte_b = FXARGB_B(m_Loader.m_MatteColor); | 667 int matte_b = FXARGB_B(m_Loader.m_MatteColor); |
| 667 for (int row = 0; row < height; row++) { | 668 for (int row = 0; row < height; row++) { |
| 668 uint8_t* dest_scan = | 669 uint8_t* dest_scan = |
| 669 (uint8_t*)bitmap_device1.GetBitmap()->GetScanline(row); | 670 (uint8_t*)bitmap_device1.GetBitmap()->GetScanline(row); |
| 670 const uint8_t* mask_scan = bitmap_device2.GetBitmap()->GetScanline(row); | 671 const uint8_t* mask_scan = bitmap_device2.GetBitmap()->GetScanline(row); |
| 671 for (int col = 0; col < width; col++) { | 672 for (int col = 0; col < width; col++) { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 return FALSE; | 797 return FALSE; |
| 797 } | 798 } |
| 798 | 799 |
| 799 FX_BOOL CPDF_ImageRenderer::StartBitmapAlpha() { | 800 FX_BOOL CPDF_ImageRenderer::StartBitmapAlpha() { |
| 800 if (m_pDIBSource->IsOpaqueImage()) { | 801 if (m_pDIBSource->IsOpaqueImage()) { |
| 801 CFX_PathData path; | 802 CFX_PathData path; |
| 802 path.AppendRect(0, 0, 1, 1); | 803 path.AppendRect(0, 0, 1, 1); |
| 803 path.Transform(&m_ImageMatrix); | 804 path.Transform(&m_ImageMatrix); |
| 804 uint32_t fill_color = | 805 uint32_t fill_color = |
| 805 ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha); | 806 ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha); |
| 806 m_pRenderStatus->m_pDevice->DrawPath(&path, NULL, NULL, fill_color, 0, | 807 m_pRenderStatus->m_pDevice->DrawPath(&path, nullptr, nullptr, fill_color, 0, |
| 807 FXFILL_WINDING); | 808 FXFILL_WINDING); |
| 808 } else { | 809 } else { |
| 809 const CFX_DIBSource* pAlphaMask = m_pDIBSource->IsAlphaMask() | 810 const CFX_DIBSource* pAlphaMask = m_pDIBSource->IsAlphaMask() |
| 810 ? m_pDIBSource | 811 ? m_pDIBSource |
| 811 : m_pDIBSource->GetAlphaMask(); | 812 : m_pDIBSource->GetAlphaMask(); |
| 812 if (FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || | 813 if (FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || |
| 813 FXSYS_fabs(m_ImageMatrix.c) >= 0.5f) { | 814 FXSYS_fabs(m_ImageMatrix.c) >= 0.5f) { |
| 814 int left, top; | 815 int left, top; |
| 815 std::unique_ptr<CFX_DIBitmap> pTransformed( | 816 std::unique_ptr<CFX_DIBitmap> pTransformed( |
| 816 pAlphaMask->TransformTo(&m_ImageMatrix, left, top)); | 817 pAlphaMask->TransformTo(&m_ImageMatrix, left, top)); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 FXDIB_Format format; | 916 FXDIB_Format format; |
| 916 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 917 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| 917 format = bLuminosity ? FXDIB_Rgb32 : FXDIB_8bppMask; | 918 format = bLuminosity ? FXDIB_Rgb32 : FXDIB_8bppMask; |
| 918 #else | 919 #else |
| 919 format = bLuminosity ? FXDIB_Rgb : FXDIB_8bppMask; | 920 format = bLuminosity ? FXDIB_Rgb : FXDIB_8bppMask; |
| 920 #endif | 921 #endif |
| 921 if (!bitmap_device.Create(width, height, format, nullptr)) | 922 if (!bitmap_device.Create(width, height, format, nullptr)) |
| 922 return nullptr; | 923 return nullptr; |
| 923 | 924 |
| 924 CFX_DIBitmap& bitmap = *bitmap_device.GetBitmap(); | 925 CFX_DIBitmap& bitmap = *bitmap_device.GetBitmap(); |
| 925 CPDF_Object* pCSObj = NULL; | 926 CPDF_Object* pCSObj = nullptr; |
| 926 CPDF_ColorSpace* pCS = NULL; | 927 CPDF_ColorSpace* pCS = nullptr; |
| 927 if (bLuminosity) { | 928 if (bLuminosity) { |
| 928 CPDF_Array* pBC = pSMaskDict->GetArrayBy("BC"); | 929 CPDF_Array* pBC = pSMaskDict->GetArrayBy("BC"); |
| 929 FX_ARGB back_color = 0xff000000; | 930 FX_ARGB back_color = 0xff000000; |
| 930 if (pBC) { | 931 if (pBC) { |
| 931 CPDF_Dictionary* pDict = pGroup->GetDict(); | 932 CPDF_Dictionary* pDict = pGroup->GetDict(); |
| 932 if (pDict && pDict->GetDictBy("Group")) | 933 if (pDict && pDict->GetDictBy("Group")) |
| 933 pCSObj = pDict->GetDictBy("Group")->GetDirectObjectBy("CS"); | 934 pCSObj = pDict->GetDictBy("Group")->GetDirectObjectBy("CS"); |
| 934 else | 935 else |
| 935 pCSObj = NULL; | 936 pCSObj = nullptr; |
| 936 pCS = m_pContext->GetDocument()->LoadColorSpace(pCSObj); | 937 pCS = m_pContext->GetDocument()->LoadColorSpace(pCSObj); |
| 937 if (pCS) { | 938 if (pCS) { |
| 938 FX_FLOAT R, G, B; | 939 FX_FLOAT R, G, B; |
| 939 uint32_t comps = 8; | 940 uint32_t comps = 8; |
| 940 if (pCS->CountComponents() > comps) { | 941 if (pCS->CountComponents() > comps) { |
| 941 comps = pCS->CountComponents(); | 942 comps = pCS->CountComponents(); |
| 942 } | 943 } |
| 943 CFX_FixedBufGrow<FX_FLOAT, 8> float_array(comps); | 944 CFX_FixedBufGrow<FX_FLOAT, 8> float_array(comps); |
| 944 FX_FLOAT* pFloats = float_array; | 945 FX_FLOAT* pFloats = float_array; |
| 945 FX_SAFE_UINT32 num_floats = comps; | 946 FX_SAFE_UINT32 num_floats = comps; |
| 946 num_floats *= sizeof(FX_FLOAT); | 947 num_floats *= sizeof(FX_FLOAT); |
| 947 if (!num_floats.IsValid()) { | 948 if (!num_floats.IsValid()) { |
| 948 return NULL; | 949 return nullptr; |
| 949 } | 950 } |
| 950 FXSYS_memset(pFloats, 0, num_floats.ValueOrDie()); | 951 FXSYS_memset(pFloats, 0, num_floats.ValueOrDie()); |
| 951 size_t count = pBC->GetCount() > 8 ? 8 : pBC->GetCount(); | 952 size_t count = pBC->GetCount() > 8 ? 8 : pBC->GetCount(); |
| 952 for (size_t i = 0; i < count; i++) { | 953 for (size_t i = 0; i < count; i++) { |
| 953 pFloats[i] = pBC->GetNumberAt(i); | 954 pFloats[i] = pBC->GetNumberAt(i); |
| 954 } | 955 } |
| 955 pCS->GetRGB(pFloats, R, G, B); | 956 pCS->GetRGB(pFloats, R, G, B); |
| 956 back_color = 0xff000000 | ((int32_t)(R * 255) << 16) | | 957 back_color = 0xff000000 | ((int32_t)(R * 255) << 16) | |
| 957 ((int32_t)(G * 255) << 8) | (int32_t)(B * 255); | 958 ((int32_t)(G * 255) << 8) | (int32_t)(B * 255); |
| 958 m_pContext->GetDocument()->GetPageData()->ReleaseColorSpace(pCSObj); | 959 m_pContext->GetDocument()->GetPageData()->ReleaseColorSpace(pCSObj); |
| 959 } | 960 } |
| 960 } | 961 } |
| 961 bitmap.Clear(back_color); | 962 bitmap.Clear(back_color); |
| 962 } else { | 963 } else { |
| 963 bitmap.Clear(0); | 964 bitmap.Clear(0); |
| 964 } | 965 } |
| 965 CPDF_Dictionary* pFormResource = NULL; | 966 CPDF_Dictionary* pFormResource = nullptr; |
| 966 if (form.m_pFormDict) { | 967 if (form.m_pFormDict) { |
| 967 pFormResource = form.m_pFormDict->GetDictBy("Resources"); | 968 pFormResource = form.m_pFormDict->GetDictBy("Resources"); |
| 968 } | 969 } |
| 969 CPDF_RenderOptions options; | 970 CPDF_RenderOptions options; |
| 970 options.m_ColorMode = bLuminosity ? RENDER_COLOR_NORMAL : RENDER_COLOR_ALPHA; | 971 options.m_ColorMode = bLuminosity ? RENDER_COLOR_NORMAL : RENDER_COLOR_ALPHA; |
| 971 CPDF_RenderStatus status; | 972 CPDF_RenderStatus status; |
| 972 status.Initialize(m_pContext, &bitmap_device, NULL, NULL, NULL, NULL, | 973 status.Initialize(m_pContext, &bitmap_device, nullptr, nullptr, nullptr, |
| 973 &options, 0, m_bDropObjects, pFormResource, TRUE, NULL, 0, | 974 nullptr, &options, 0, m_bDropObjects, pFormResource, TRUE, |
| 974 pCS ? pCS->GetFamily() : 0, bLuminosity); | 975 nullptr, 0, pCS ? pCS->GetFamily() : 0, bLuminosity); |
| 975 status.RenderObjectList(&form, &matrix); | 976 status.RenderObjectList(&form, &matrix); |
| 976 std::unique_ptr<CFX_DIBitmap> pMask(new CFX_DIBitmap); | 977 std::unique_ptr<CFX_DIBitmap> pMask(new CFX_DIBitmap); |
| 977 if (!pMask->Create(width, height, FXDIB_8bppMask)) | 978 if (!pMask->Create(width, height, FXDIB_8bppMask)) |
| 978 return nullptr; | 979 return nullptr; |
| 979 | 980 |
| 980 uint8_t* dest_buf = pMask->GetBuffer(); | 981 uint8_t* dest_buf = pMask->GetBuffer(); |
| 981 int dest_pitch = pMask->GetPitch(); | 982 int dest_pitch = pMask->GetPitch(); |
| 982 uint8_t* src_buf = bitmap.GetBuffer(); | 983 uint8_t* src_buf = bitmap.GetBuffer(); |
| 983 int src_pitch = bitmap.GetPitch(); | 984 int src_pitch = bitmap.GetPitch(); |
| 984 std::vector<uint8_t> transfers(256); | 985 std::vector<uint8_t> transfers(256); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1008 } else if (pFunc) { | 1009 } else if (pFunc) { |
| 1009 int size = dest_pitch * height; | 1010 int size = dest_pitch * height; |
| 1010 for (int i = 0; i < size; i++) { | 1011 for (int i = 0; i < size; i++) { |
| 1011 dest_buf[i] = transfers[src_buf[i]]; | 1012 dest_buf[i] = transfers[src_buf[i]]; |
| 1012 } | 1013 } |
| 1013 } else { | 1014 } else { |
| 1014 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); | 1015 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); |
| 1015 } | 1016 } |
| 1016 return pMask.release(); | 1017 return pMask.release(); |
| 1017 } | 1018 } |
| OLD | NEW |