| 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 <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 } | 358 } |
| 359 | 359 |
| 360 CPDF_ImageRenderer::~CPDF_ImageRenderer() { | 360 CPDF_ImageRenderer::~CPDF_ImageRenderer() { |
| 361 if (m_DeviceHandle) { | 361 if (m_DeviceHandle) { |
| 362 m_pRenderStatus->m_pDevice->CancelDIBits(m_DeviceHandle); | 362 m_pRenderStatus->m_pDevice->CancelDIBits(m_DeviceHandle); |
| 363 } | 363 } |
| 364 } | 364 } |
| 365 | 365 |
| 366 FX_BOOL CPDF_ImageRenderer::StartLoadDIBSource() { | 366 FX_BOOL CPDF_ImageRenderer::StartLoadDIBSource() { |
| 367 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); | 367 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); |
| 368 FX_RECT image_rect = image_rect_f.GetOutterRect(); | 368 FX_RECT image_rect = image_rect_f.GetOuterRect(); |
| 369 int dest_width = image_rect.Width(); | 369 int dest_width = image_rect.Width(); |
| 370 int dest_height = image_rect.Height(); | 370 int dest_height = image_rect.Height(); |
| 371 if (m_ImageMatrix.a < 0) { | 371 if (m_ImageMatrix.a < 0) { |
| 372 dest_width = -dest_width; | 372 dest_width = -dest_width; |
| 373 } | 373 } |
| 374 if (m_ImageMatrix.d > 0) { | 374 if (m_ImageMatrix.d > 0) { |
| 375 dest_height = -dest_height; | 375 dest_height = -dest_height; |
| 376 } | 376 } |
| 377 if (m_Loader.Start(m_pImageObject, | 377 if (m_Loader.Start(m_pImageObject, |
| 378 m_pRenderStatus->m_pContext->GetPageCache(), &m_LoadHandle, | 378 m_pRenderStatus->m_pContext->GetPageCache(), &m_LoadHandle, |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 m_BlendType = blendType; | 545 m_BlendType = blendType; |
| 546 return StartDIBSource(); | 546 return StartDIBSource(); |
| 547 } | 547 } |
| 548 | 548 |
| 549 FX_BOOL CPDF_ImageRenderer::DrawPatternImage(const CFX_Matrix* pObj2Device) { | 549 FX_BOOL CPDF_ImageRenderer::DrawPatternImage(const CFX_Matrix* pObj2Device) { |
| 550 if (m_pRenderStatus->m_bPrint && | 550 if (m_pRenderStatus->m_bPrint && |
| 551 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { | 551 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { |
| 552 m_Result = FALSE; | 552 m_Result = FALSE; |
| 553 return FALSE; | 553 return FALSE; |
| 554 } | 554 } |
| 555 FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOutterRect(); | 555 FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOuterRect(); |
| 556 rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox()); | 556 rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox()); |
| 557 if (rect.IsEmpty()) { | 557 if (rect.IsEmpty()) { |
| 558 return FALSE; | 558 return FALSE; |
| 559 } | 559 } |
| 560 CFX_Matrix new_matrix = m_ImageMatrix; | 560 CFX_Matrix new_matrix = m_ImageMatrix; |
| 561 new_matrix.TranslateI(-rect.left, -rect.top); | 561 new_matrix.TranslateI(-rect.left, -rect.top); |
| 562 int width = rect.Width(); | 562 int width = rect.Width(); |
| 563 int height = rect.Height(); | 563 int height = rect.Height(); |
| 564 CFX_FxgeDevice bitmap_device1; | 564 CFX_FxgeDevice bitmap_device1; |
| 565 if (!bitmap_device1.Create(rect.Width(), rect.Height(), FXDIB_Rgb32, nullptr)) | 565 if (!bitmap_device1.Create(rect.Width(), rect.Height(), FXDIB_Rgb32, nullptr)) |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 m_pRenderStatus->m_pDevice->SetDIBitsWithBlend( | 645 m_pRenderStatus->m_pDevice->SetDIBitsWithBlend( |
| 646 bitmap_device1.GetBitmap(), rect.left, rect.top, m_BlendType); | 646 bitmap_device1.GetBitmap(), rect.left, rect.top, m_BlendType); |
| 647 return FALSE; | 647 return FALSE; |
| 648 } | 648 } |
| 649 FX_BOOL CPDF_ImageRenderer::DrawMaskedImage() { | 649 FX_BOOL CPDF_ImageRenderer::DrawMaskedImage() { |
| 650 if (m_pRenderStatus->m_bPrint && | 650 if (m_pRenderStatus->m_bPrint && |
| 651 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { | 651 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { |
| 652 m_Result = FALSE; | 652 m_Result = FALSE; |
| 653 return FALSE; | 653 return FALSE; |
| 654 } | 654 } |
| 655 FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOutterRect(); | 655 FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOuterRect(); |
| 656 rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox()); | 656 rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox()); |
| 657 if (rect.IsEmpty()) { | 657 if (rect.IsEmpty()) { |
| 658 return FALSE; | 658 return FALSE; |
| 659 } | 659 } |
| 660 CFX_Matrix new_matrix = m_ImageMatrix; | 660 CFX_Matrix new_matrix = m_ImageMatrix; |
| 661 new_matrix.TranslateI(-rect.left, -rect.top); | 661 new_matrix.TranslateI(-rect.left, -rect.top); |
| 662 int width = rect.Width(); | 662 int width = rect.Width(); |
| 663 int height = rect.Height(); | 663 int height = rect.Height(); |
| 664 CFX_FxgeDevice bitmap_device1; | 664 CFX_FxgeDevice bitmap_device1; |
| 665 if (!bitmap_device1.Create(width, height, FXDIB_Rgb32, nullptr)) | 665 if (!bitmap_device1.Create(width, height, FXDIB_Rgb32, nullptr)) |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 m_pDIBSource, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags, | 771 m_pDIBSource, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags, |
| 772 m_DeviceHandle, m_BlendType)) { | 772 m_DeviceHandle, m_BlendType)) { |
| 773 if (m_DeviceHandle) { | 773 if (m_DeviceHandle) { |
| 774 m_Status = 3; | 774 m_Status = 3; |
| 775 return TRUE; | 775 return TRUE; |
| 776 } | 776 } |
| 777 return FALSE; | 777 return FALSE; |
| 778 } | 778 } |
| 779 #endif | 779 #endif |
| 780 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); | 780 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); |
| 781 FX_RECT image_rect = image_rect_f.GetOutterRect(); | 781 FX_RECT image_rect = image_rect_f.GetOuterRect(); |
| 782 int dest_width = image_rect.Width(); | 782 int dest_width = image_rect.Width(); |
| 783 int dest_height = image_rect.Height(); | 783 int dest_height = image_rect.Height(); |
| 784 if ((FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || m_ImageMatrix.a == 0) || | 784 if ((FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || m_ImageMatrix.a == 0) || |
| 785 (FXSYS_fabs(m_ImageMatrix.c) >= 0.5f || m_ImageMatrix.d == 0)) { | 785 (FXSYS_fabs(m_ImageMatrix.c) >= 0.5f || m_ImageMatrix.d == 0)) { |
| 786 if (m_pRenderStatus->m_bPrint && | 786 if (m_pRenderStatus->m_bPrint && |
| 787 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { | 787 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { |
| 788 m_Result = FALSE; | 788 m_Result = FALSE; |
| 789 return FALSE; | 789 return FALSE; |
| 790 } | 790 } |
| 791 FX_RECT clip_box = m_pRenderStatus->m_pDevice->GetClipBox(); | 791 FX_RECT clip_box = m_pRenderStatus->m_pDevice->GetClipBox(); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 std::unique_ptr<CFX_DIBitmap> pTransformed( | 861 std::unique_ptr<CFX_DIBitmap> pTransformed( |
| 862 pAlphaMask->TransformTo(&m_ImageMatrix, left, top)); | 862 pAlphaMask->TransformTo(&m_ImageMatrix, left, top)); |
| 863 if (!pTransformed) | 863 if (!pTransformed) |
| 864 return TRUE; | 864 return TRUE; |
| 865 | 865 |
| 866 m_pRenderStatus->m_pDevice->SetBitMask( | 866 m_pRenderStatus->m_pDevice->SetBitMask( |
| 867 pTransformed.get(), left, top, | 867 pTransformed.get(), left, top, |
| 868 ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha)); | 868 ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha)); |
| 869 } else { | 869 } else { |
| 870 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); | 870 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); |
| 871 FX_RECT image_rect = image_rect_f.GetOutterRect(); | 871 FX_RECT image_rect = image_rect_f.GetOuterRect(); |
| 872 int dest_width = | 872 int dest_width = |
| 873 m_ImageMatrix.a > 0 ? image_rect.Width() : -image_rect.Width(); | 873 m_ImageMatrix.a > 0 ? image_rect.Width() : -image_rect.Width(); |
| 874 int dest_height = | 874 int dest_height = |
| 875 m_ImageMatrix.d > 0 ? -image_rect.Height() : image_rect.Height(); | 875 m_ImageMatrix.d > 0 ? -image_rect.Height() : image_rect.Height(); |
| 876 int left = dest_width > 0 ? image_rect.left : image_rect.right; | 876 int left = dest_width > 0 ? image_rect.left : image_rect.right; |
| 877 int top = dest_height > 0 ? image_rect.top : image_rect.bottom; | 877 int top = dest_height > 0 ? image_rect.top : image_rect.bottom; |
| 878 m_pRenderStatus->m_pDevice->StretchBitMask( | 878 m_pRenderStatus->m_pDevice->StretchBitMask( |
| 879 pAlphaMask, left, top, dest_width, dest_height, | 879 pAlphaMask, left, top, dest_width, dest_height, |
| 880 ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha)); | 880 ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha)); |
| 881 } | 881 } |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 } else if (pFunc) { | 1054 } else if (pFunc) { |
| 1055 int size = dest_pitch * height; | 1055 int size = dest_pitch * height; |
| 1056 for (int i = 0; i < size; i++) { | 1056 for (int i = 0; i < size; i++) { |
| 1057 dest_buf[i] = transfers[src_buf[i]]; | 1057 dest_buf[i] = transfers[src_buf[i]]; |
| 1058 } | 1058 } |
| 1059 } else { | 1059 } else { |
| 1060 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); | 1060 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); |
| 1061 } | 1061 } |
| 1062 return pMask.release(); | 1062 return pMask.release(); |
| 1063 } | 1063 } |
| OLD | NEW |