| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 void* dummy; | 56 void* dummy; |
| 57 CFX_Matrix m(pDIBitmap->GetWidth(), 0, 0, -pDIBitmap->GetHeight(), left, | 57 CFX_Matrix m(pDIBitmap->GetWidth(), 0, 0, -pDIBitmap->GetHeight(), left, |
| 58 top + pDIBitmap->GetHeight()); | 58 top + pDIBitmap->GetHeight()); |
| 59 m_pDevice->StartDIBits(pDIBitmap, bitmap_alpha, 0, &m, 0, dummy); | 59 m_pDevice->StartDIBits(pDIBitmap, bitmap_alpha, 0, &m, 0, dummy); |
| 60 return; | 60 return; |
| 61 #else | 61 #else |
| 62 pDIBitmap->MultiplyAlpha(bitmap_alpha); | 62 pDIBitmap->MultiplyAlpha(bitmap_alpha); |
| 63 #endif | 63 #endif |
| 64 } | 64 } |
| 65 #ifdef _SKIA_SUPPORT_ | 65 #ifdef _SKIA_SUPPORT_ |
| 66 static_cast<CFX_SkiaDeviceDriver*>(m_pDevice->GetDeviceDriver()) | 66 CFX_SkiaDeviceDriver::PreMultiply(pDIBitmap); |
| 67 ->PreMultiply(pDIBitmap); | |
| 68 #endif | 67 #endif |
| 69 if (m_pDevice->SetDIBits(pDIBitmap, left, top)) { | 68 if (m_pDevice->SetDIBits(pDIBitmap, left, top)) { |
| 70 return; | 69 return; |
| 71 } | 70 } |
| 72 } else { | 71 } else { |
| 73 uint32_t fill_argb = m_Options.TranslateColor(mask_argb); | 72 uint32_t fill_argb = m_Options.TranslateColor(mask_argb); |
| 74 if (bitmap_alpha < 255) { | 73 if (bitmap_alpha < 255) { |
| 75 ((uint8_t*)&fill_argb)[3] = | 74 ((uint8_t*)&fill_argb)[3] = |
| 76 ((uint8_t*)&fill_argb)[3] * bitmap_alpha / 255; | 75 ((uint8_t*)&fill_argb)[3] * bitmap_alpha / 255; |
| 77 } | 76 } |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 dest_scan++; | 709 dest_scan++; |
| 711 } else { | 710 } else { |
| 712 dest_scan += 4; | 711 dest_scan += 4; |
| 713 } | 712 } |
| 714 } | 713 } |
| 715 } | 714 } |
| 716 } | 715 } |
| 717 bitmap_device2.GetBitmap()->ConvertFormat(FXDIB_8bppMask); | 716 bitmap_device2.GetBitmap()->ConvertFormat(FXDIB_8bppMask); |
| 718 bitmap_device1.GetBitmap()->MultiplyAlpha(bitmap_device2.GetBitmap()); | 717 bitmap_device1.GetBitmap()->MultiplyAlpha(bitmap_device2.GetBitmap()); |
| 719 #ifdef _SKIA_SUPPORT_ | 718 #ifdef _SKIA_SUPPORT_ |
| 720 bitmap_device1.PreMultiply(); // convert unpremultiplied to premultiplied | 719 CFX_SkiaDeviceDriver::PreMultiply(bitmap_device1.GetBitmap()); |
| 721 #endif | 720 #endif |
| 722 if (m_BitmapAlpha < 255) { | 721 if (m_BitmapAlpha < 255) { |
| 723 bitmap_device1.GetBitmap()->MultiplyAlpha(m_BitmapAlpha); | 722 bitmap_device1.GetBitmap()->MultiplyAlpha(m_BitmapAlpha); |
| 724 } | 723 } |
| 725 } | 724 } |
| 726 m_pRenderStatus->m_pDevice->SetDIBitsWithBlend( | 725 m_pRenderStatus->m_pDevice->SetDIBitsWithBlend( |
| 727 bitmap_device1.GetBitmap(), rect.left, rect.top, m_BlendType); | 726 bitmap_device1.GetBitmap(), rect.left, rect.top, m_BlendType); |
| 728 return FALSE; | 727 return FALSE; |
| 729 } | 728 } |
| 730 | 729 |
| 731 FX_BOOL CPDF_ImageRenderer::StartDIBSource() { | 730 FX_BOOL CPDF_ImageRenderer::StartDIBSource() { |
| 732 if (!(m_Flags & RENDER_FORCE_DOWNSAMPLE) && m_pDIBSource->GetBPP() > 1) { | 731 if (!(m_Flags & RENDER_FORCE_DOWNSAMPLE) && m_pDIBSource->GetBPP() > 1) { |
| 733 int image_size = m_pDIBSource->GetBPP() / 8 * m_pDIBSource->GetWidth() * | 732 int image_size = m_pDIBSource->GetBPP() / 8 * m_pDIBSource->GetWidth() * |
| 734 m_pDIBSource->GetHeight(); | 733 m_pDIBSource->GetHeight(); |
| 735 if (image_size > FPDF_HUGE_IMAGE_SIZE && | 734 if (image_size > FPDF_HUGE_IMAGE_SIZE && |
| 736 !(m_Flags & RENDER_FORCE_HALFTONE)) { | 735 !(m_Flags & RENDER_FORCE_HALFTONE)) { |
| 737 m_Flags |= RENDER_FORCE_DOWNSAMPLE; | 736 m_Flags |= RENDER_FORCE_DOWNSAMPLE; |
| 738 } | 737 } |
| 739 } | 738 } |
| 739 #ifdef _SKIA_SUPPORT_ |
| 740 CFX_DIBitmap* premultiplied = m_pDIBSource->Clone(); |
| 741 CFX_SkiaDeviceDriver::PreMultiply(premultiplied); |
| 742 if (m_pRenderStatus->m_pDevice->StartDIBitsWithBlend( |
| 743 premultiplied, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags, |
| 744 m_DeviceHandle, m_BlendType)) { |
| 745 if (m_DeviceHandle) { |
| 746 m_Status = 3; |
| 747 return TRUE; |
| 748 } |
| 749 return FALSE; |
| 750 } |
| 751 #else |
| 740 if (m_pRenderStatus->m_pDevice->StartDIBitsWithBlend( | 752 if (m_pRenderStatus->m_pDevice->StartDIBitsWithBlend( |
| 741 m_pDIBSource, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags, | 753 m_pDIBSource, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags, |
| 742 m_DeviceHandle, m_BlendType)) { | 754 m_DeviceHandle, m_BlendType)) { |
| 743 if (m_DeviceHandle) { | 755 if (m_DeviceHandle) { |
| 744 m_Status = 3; | 756 m_Status = 3; |
| 745 return TRUE; | 757 return TRUE; |
| 746 } | 758 } |
| 747 return FALSE; | 759 return FALSE; |
| 748 } | 760 } |
| 761 #endif |
| 749 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); | 762 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); |
| 750 FX_RECT image_rect = image_rect_f.GetOutterRect(); | 763 FX_RECT image_rect = image_rect_f.GetOutterRect(); |
| 751 int dest_width = image_rect.Width(); | 764 int dest_width = image_rect.Width(); |
| 752 int dest_height = image_rect.Height(); | 765 int dest_height = image_rect.Height(); |
| 753 if ((FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || m_ImageMatrix.a == 0) || | 766 if ((FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || m_ImageMatrix.a == 0) || |
| 754 (FXSYS_fabs(m_ImageMatrix.c) >= 0.5f || m_ImageMatrix.d == 0)) { | 767 (FXSYS_fabs(m_ImageMatrix.c) >= 0.5f || m_ImageMatrix.d == 0)) { |
| 755 if (m_pRenderStatus->m_bPrint && | 768 if (m_pRenderStatus->m_bPrint && |
| 756 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { | 769 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { |
| 757 m_Result = FALSE; | 770 m_Result = FALSE; |
| 758 return FALSE; | 771 return FALSE; |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1023 } else if (pFunc) { | 1036 } else if (pFunc) { |
| 1024 int size = dest_pitch * height; | 1037 int size = dest_pitch * height; |
| 1025 for (int i = 0; i < size; i++) { | 1038 for (int i = 0; i < size; i++) { |
| 1026 dest_buf[i] = transfers[src_buf[i]]; | 1039 dest_buf[i] = transfers[src_buf[i]]; |
| 1027 } | 1040 } |
| 1028 } else { | 1041 } else { |
| 1029 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); | 1042 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); |
| 1030 } | 1043 } |
| 1031 return pMask.release(); | 1044 return pMask.release(); |
| 1032 } | 1045 } |
| OLD | NEW |