| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 bool bBackAlphaRequired = blend_mode && bIsolated && !m_bDropObjects; | 69 bool bBackAlphaRequired = blend_mode && bIsolated && !m_bDropObjects; |
| 70 bool bGetBackGround = | 70 bool bGetBackGround = |
| 71 ((m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT)) || | 71 ((m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT)) || |
| 72 (!(m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT) && | 72 (!(m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT) && |
| 73 (m_pDevice->GetRenderCaps() & FXRC_GET_BITS) && !bBackAlphaRequired); | 73 (m_pDevice->GetRenderCaps() & FXRC_GET_BITS) && !bBackAlphaRequired); |
| 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->SetDIBits(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 = NULL; |
| 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()) |
| 95 pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(), | 95 pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(), |
| 96 pDIBitmap, left, top, blend_mode); | 96 pDIBitmap, left, top, blend_mode); |
| 97 else | 97 else |
| 98 pClone->CompositeMask(0, 0, pClone->GetWidth(), pClone->GetHeight(), | 98 pClone->CompositeMask(0, 0, pClone->GetWidth(), pClone->GetHeight(), |
| 99 pDIBitmap, mask_argb, left, top, blend_mode); | 99 pDIBitmap, mask_argb, left, top, blend_mode); |
| 100 } else { | 100 } else { |
| 101 pClone = pDIBitmap; | 101 pClone = pDIBitmap; |
| 102 } | 102 } |
| 103 if (m_pDevice->GetBackDrop()) { | 103 if (m_pDevice->GetBackDrop()) { |
| 104 m_pDevice->SetDIBits(pClone, rect.left, rect.top); | 104 m_pDevice->SetDIBits(pClone, rect.left, rect.top); |
| 105 } else { | 105 } else { |
| 106 if (pDIBitmap->IsAlphaMask()) { | 106 if (pDIBitmap->IsAlphaMask()) { |
| 107 return; | 107 return; |
| 108 } | 108 } |
| 109 m_pDevice->SetDIBits(pDIBitmap, rect.left, rect.top, blend_mode); | 109 m_pDevice->SetDIBitsWithBlend(pDIBitmap, rect.left, rect.top, |
| 110 blend_mode); |
| 110 } | 111 } |
| 111 if (bClone) { | 112 if (bClone) { |
| 112 delete pClone; | 113 delete pClone; |
| 113 } | 114 } |
| 114 } | 115 } |
| 115 return; | 116 return; |
| 116 } | 117 } |
| 117 int back_left, back_top; | 118 int back_left, back_top; |
| 118 FX_RECT rect(left, top, left + pDIBitmap->GetWidth(), | 119 FX_RECT rect(left, top, left + pDIBitmap->GetWidth(), |
| 119 top + pDIBitmap->GetHeight()); | 120 top + pDIBitmap->GetHeight()); |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 } else { | 594 } else { |
| 594 dest_scan += 4; | 595 dest_scan += 4; |
| 595 } | 596 } |
| 596 } | 597 } |
| 597 } | 598 } |
| 598 } | 599 } |
| 599 bitmap_device2.GetBitmap()->ConvertFormat(FXDIB_8bppMask); | 600 bitmap_device2.GetBitmap()->ConvertFormat(FXDIB_8bppMask); |
| 600 bitmap_device1.GetBitmap()->MultiplyAlpha(bitmap_device2.GetBitmap()); | 601 bitmap_device1.GetBitmap()->MultiplyAlpha(bitmap_device2.GetBitmap()); |
| 601 bitmap_device1.GetBitmap()->MultiplyAlpha(255); | 602 bitmap_device1.GetBitmap()->MultiplyAlpha(255); |
| 602 } | 603 } |
| 603 m_pRenderStatus->m_pDevice->SetDIBits(bitmap_device1.GetBitmap(), rect.left, | 604 m_pRenderStatus->m_pDevice->SetDIBitsWithBlend( |
| 604 rect.top, m_BlendType); | 605 bitmap_device1.GetBitmap(), rect.left, rect.top, m_BlendType); |
| 605 return FALSE; | 606 return FALSE; |
| 606 } | 607 } |
| 607 FX_BOOL CPDF_ImageRenderer::DrawMaskedImage() { | 608 FX_BOOL CPDF_ImageRenderer::DrawMaskedImage() { |
| 608 if (m_pRenderStatus->m_bPrint && | 609 if (m_pRenderStatus->m_bPrint && |
| 609 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { | 610 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { |
| 610 m_Result = FALSE; | 611 m_Result = FALSE; |
| 611 return FALSE; | 612 return FALSE; |
| 612 } | 613 } |
| 613 FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOutterRect(); | 614 FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOutterRect(); |
| 614 rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox()); | 615 rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox()); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 } | 689 } |
| 689 } | 690 } |
| 690 } | 691 } |
| 691 } | 692 } |
| 692 bitmap_device2.GetBitmap()->ConvertFormat(FXDIB_8bppMask); | 693 bitmap_device2.GetBitmap()->ConvertFormat(FXDIB_8bppMask); |
| 693 bitmap_device1.GetBitmap()->MultiplyAlpha(bitmap_device2.GetBitmap()); | 694 bitmap_device1.GetBitmap()->MultiplyAlpha(bitmap_device2.GetBitmap()); |
| 694 if (m_BitmapAlpha < 255) { | 695 if (m_BitmapAlpha < 255) { |
| 695 bitmap_device1.GetBitmap()->MultiplyAlpha(m_BitmapAlpha); | 696 bitmap_device1.GetBitmap()->MultiplyAlpha(m_BitmapAlpha); |
| 696 } | 697 } |
| 697 } | 698 } |
| 698 m_pRenderStatus->m_pDevice->SetDIBits(bitmap_device1.GetBitmap(), rect.left, | 699 m_pRenderStatus->m_pDevice->SetDIBitsWithBlend( |
| 699 rect.top, m_BlendType); | 700 bitmap_device1.GetBitmap(), rect.left, rect.top, m_BlendType); |
| 700 return FALSE; | 701 return FALSE; |
| 701 } | 702 } |
| 702 | 703 |
| 703 FX_BOOL CPDF_ImageRenderer::StartDIBSource() { | 704 FX_BOOL CPDF_ImageRenderer::StartDIBSource() { |
| 704 if (!(m_Flags & RENDER_FORCE_DOWNSAMPLE) && m_pDIBSource->GetBPP() > 1) { | 705 if (!(m_Flags & RENDER_FORCE_DOWNSAMPLE) && m_pDIBSource->GetBPP() > 1) { |
| 705 int image_size = m_pDIBSource->GetBPP() / 8 * m_pDIBSource->GetWidth() * | 706 int image_size = m_pDIBSource->GetBPP() / 8 * m_pDIBSource->GetWidth() * |
| 706 m_pDIBSource->GetHeight(); | 707 m_pDIBSource->GetHeight(); |
| 707 if (image_size > FPDF_HUGE_IMAGE_SIZE && | 708 if (image_size > FPDF_HUGE_IMAGE_SIZE && |
| 708 !(m_Flags & RENDER_FORCE_HALFTONE)) { | 709 !(m_Flags & RENDER_FORCE_HALFTONE)) { |
| 709 m_Flags |= RENDER_FORCE_DOWNSAMPLE; | 710 m_Flags |= RENDER_FORCE_DOWNSAMPLE; |
| 710 } | 711 } |
| 711 } | 712 } |
| 712 if (m_pRenderStatus->m_pDevice->StartDIBits( | 713 if (m_pRenderStatus->m_pDevice->StartDIBitsWithBlend( |
| 713 m_pDIBSource, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags, | 714 m_pDIBSource, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags, |
| 714 m_DeviceHandle, 0, nullptr, m_BlendType)) { | 715 m_DeviceHandle, m_BlendType)) { |
| 715 if (m_DeviceHandle) { | 716 if (m_DeviceHandle) { |
| 716 m_Status = 3; | 717 m_Status = 3; |
| 717 return TRUE; | 718 return TRUE; |
| 718 } | 719 } |
| 719 return FALSE; | 720 return FALSE; |
| 720 } | 721 } |
| 721 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); | 722 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); |
| 722 FX_RECT image_rect = image_rect_f.GetOutterRect(); | 723 FX_RECT image_rect = image_rect_f.GetOutterRect(); |
| 723 int dest_width = image_rect.Width(); | 724 int dest_width = image_rect.Width(); |
| 724 int dest_height = image_rect.Height(); | 725 int dest_height = image_rect.Height(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 739 } | 740 } |
| 740 if (m_ImageMatrix.a < 0) | 741 if (m_ImageMatrix.a < 0) |
| 741 dest_width = -dest_width; | 742 dest_width = -dest_width; |
| 742 | 743 |
| 743 if (m_ImageMatrix.d > 0) | 744 if (m_ImageMatrix.d > 0) |
| 744 dest_height = -dest_height; | 745 dest_height = -dest_height; |
| 745 | 746 |
| 746 int dest_left = dest_width > 0 ? image_rect.left : image_rect.right; | 747 int dest_left = dest_width > 0 ? image_rect.left : image_rect.right; |
| 747 int dest_top = dest_height > 0 ? image_rect.top : image_rect.bottom; | 748 int dest_top = dest_height > 0 ? image_rect.top : image_rect.bottom; |
| 748 if (m_pDIBSource->IsOpaqueImage() && m_BitmapAlpha == 255) { | 749 if (m_pDIBSource->IsOpaqueImage() && m_BitmapAlpha == 255) { |
| 749 if (m_pRenderStatus->m_pDevice->StretchDIBits( | 750 if (m_pRenderStatus->m_pDevice->StretchDIBitsWithFlagsAndBlend( |
| 750 m_pDIBSource, dest_left, dest_top, dest_width, dest_height, m_Flags, | 751 m_pDIBSource, dest_left, dest_top, dest_width, dest_height, m_Flags, |
| 751 nullptr, m_BlendType)) { | 752 m_BlendType)) { |
| 752 return FALSE; | 753 return FALSE; |
| 753 } | 754 } |
| 754 } | 755 } |
| 755 if (m_pDIBSource->IsAlphaMask()) { | 756 if (m_pDIBSource->IsAlphaMask()) { |
| 756 if (m_BitmapAlpha != 255) | 757 if (m_BitmapAlpha != 255) |
| 757 m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha); | 758 m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha); |
| 758 if (m_pRenderStatus->m_pDevice->StretchBitMask( | 759 if (m_pRenderStatus->m_pDevice->StretchBitMaskWithFlags( |
| 759 m_pDIBSource, dest_left, dest_top, dest_width, dest_height, | 760 m_pDIBSource, dest_left, dest_top, dest_width, dest_height, |
| 760 m_FillArgb, m_Flags)) { | 761 m_FillArgb, m_Flags)) { |
| 761 return FALSE; | 762 return FALSE; |
| 762 } | 763 } |
| 763 } | 764 } |
| 764 if (m_pRenderStatus->m_bPrint && | 765 if (m_pRenderStatus->m_bPrint && |
| 765 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { | 766 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { |
| 766 m_Result = FALSE; | 767 m_Result = FALSE; |
| 767 return TRUE; | 768 return TRUE; |
| 768 } | 769 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 | 839 |
| 839 if (pBitmap->IsAlphaMask()) { | 840 if (pBitmap->IsAlphaMask()) { |
| 840 if (m_BitmapAlpha != 255) | 841 if (m_BitmapAlpha != 255) |
| 841 m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha); | 842 m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha); |
| 842 m_Result = m_pRenderStatus->m_pDevice->SetBitMask( | 843 m_Result = m_pRenderStatus->m_pDevice->SetBitMask( |
| 843 pBitmap.get(), m_pTransformer->result().left, | 844 pBitmap.get(), m_pTransformer->result().left, |
| 844 m_pTransformer->result().top, m_FillArgb); | 845 m_pTransformer->result().top, m_FillArgb); |
| 845 } else { | 846 } else { |
| 846 if (m_BitmapAlpha != 255) | 847 if (m_BitmapAlpha != 255) |
| 847 pBitmap->MultiplyAlpha(m_BitmapAlpha); | 848 pBitmap->MultiplyAlpha(m_BitmapAlpha); |
| 848 m_Result = m_pRenderStatus->m_pDevice->SetDIBits( | 849 m_Result = m_pRenderStatus->m_pDevice->SetDIBitsWithBlend( |
| 849 pBitmap.get(), m_pTransformer->result().left, | 850 pBitmap.get(), m_pTransformer->result().left, |
| 850 m_pTransformer->result().top, m_BlendType); | 851 m_pTransformer->result().top, m_BlendType); |
| 851 } | 852 } |
| 852 return FALSE; | 853 return FALSE; |
| 853 } | 854 } |
| 854 if (m_Status == 3) | 855 if (m_Status == 3) |
| 855 return m_pRenderStatus->m_pDevice->ContinueDIBits(m_DeviceHandle, pPause); | 856 return m_pRenderStatus->m_pDevice->ContinueDIBits(m_DeviceHandle, pPause); |
| 856 | 857 |
| 857 if (m_Status == 4) { | 858 if (m_Status == 4) { |
| 858 if (m_Loader.Continue(m_LoadHandle, pPause)) | 859 if (m_Loader.Continue(m_LoadHandle, pPause)) |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } |
| OLD | NEW |