| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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/render/cpdf_renderstatus.h" | 7 #include "core/fpdfapi/render/cpdf_renderstatus.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 mtPattern2Bitmap.Concat(mtAdjust); | 886 mtPattern2Bitmap.Concat(mtAdjust); |
| 887 CPDF_RenderOptions options; | 887 CPDF_RenderOptions options; |
| 888 if (!pPattern->colored()) | 888 if (!pPattern->colored()) |
| 889 options.m_ColorMode = RENDER_COLOR_ALPHA; | 889 options.m_ColorMode = RENDER_COLOR_ALPHA; |
| 890 | 890 |
| 891 flags |= RENDER_FORCE_HALFTONE; | 891 flags |= RENDER_FORCE_HALFTONE; |
| 892 options.m_Flags = flags; | 892 options.m_Flags = flags; |
| 893 CPDF_RenderContext context(pDoc, pCache); | 893 CPDF_RenderContext context(pDoc, pCache); |
| 894 context.AppendLayer(pPattern->form(), &mtPattern2Bitmap); | 894 context.AppendLayer(pPattern->form(), &mtPattern2Bitmap); |
| 895 context.Render(&bitmap_device, &options, nullptr); | 895 context.Render(&bitmap_device, &options, nullptr); |
| 896 #if defined _SKIA_SUPPORT_PATHS_ |
| 897 pBitmap->UnPreMultiply(); |
| 898 #endif |
| 896 return pBitmap; | 899 return pBitmap; |
| 897 } | 900 } |
| 898 | 901 |
| 899 bool IsAvailableMatrix(const CFX_Matrix& matrix) { | 902 bool IsAvailableMatrix(const CFX_Matrix& matrix) { |
| 900 if (matrix.a == 0 || matrix.d == 0) | 903 if (matrix.a == 0 || matrix.d == 0) |
| 901 return matrix.b != 0 && matrix.c != 0; | 904 return matrix.b != 0 && matrix.c != 0; |
| 902 | 905 |
| 903 if (matrix.b == 0 || matrix.c == 0) | 906 if (matrix.b == 0 || matrix.c == 0) |
| 904 return matrix.a != 0 && matrix.d != 0; | 907 return matrix.a != 0 && matrix.d != 0; |
| 905 | 908 |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1129 return; | 1132 return; |
| 1130 case CPDF_PageObject::FORM: | 1133 case CPDF_PageObject::FORM: |
| 1131 bRet = ProcessForm(pObj->AsForm(), pObj2Device); | 1134 bRet = ProcessForm(pObj->AsForm(), pObj2Device); |
| 1132 break; | 1135 break; |
| 1133 } | 1136 } |
| 1134 if (!bRet) | 1137 if (!bRet) |
| 1135 DrawObjWithBackground(pObj, pObj2Device); | 1138 DrawObjWithBackground(pObj, pObj2Device); |
| 1136 #if defined _SKIA_SUPPORT_ | 1139 #if defined _SKIA_SUPPORT_ |
| 1137 DebugVerifyDeviceIsPreMultiplied(); | 1140 DebugVerifyDeviceIsPreMultiplied(); |
| 1138 #endif | 1141 #endif |
| 1139 #if defined _SKIA_SUPPORT_PATHS_ | |
| 1140 UnPreMultiplyDevice(); | |
| 1141 #endif | |
| 1142 } | 1142 } |
| 1143 | 1143 |
| 1144 bool CPDF_RenderStatus::DrawObjWithBlend(CPDF_PageObject* pObj, | 1144 bool CPDF_RenderStatus::DrawObjWithBlend(CPDF_PageObject* pObj, |
| 1145 const CFX_Matrix* pObj2Device) { | 1145 const CFX_Matrix* pObj2Device) { |
| 1146 bool bRet = false; | 1146 bool bRet = false; |
| 1147 switch (pObj->GetType()) { | 1147 switch (pObj->GetType()) { |
| 1148 case CPDF_PageObject::PATH: | 1148 case CPDF_PageObject::PATH: |
| 1149 bRet = ProcessPath(pObj->AsPath(), pObj2Device); | 1149 bRet = ProcessPath(pObj->AsPath(), pObj2Device); |
| 1150 break; | 1150 break; |
| 1151 case CPDF_PageObject::IMAGE: | 1151 case CPDF_PageObject::IMAGE: |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1540 textobj->m_pCharPos, textobj->m_TextState.GetFont(), | 1540 textobj->m_pCharPos, textobj->m_TextState.GetFont(), |
| 1541 textobj->m_TextState.GetFontSize(), &text_matrix, &new_matrix, | 1541 textobj->m_TextState.GetFontSize(), &text_matrix, &new_matrix, |
| 1542 textobj->m_GraphState.GetObject(), (FX_ARGB)-1, 0, nullptr, 0); | 1542 textobj->m_GraphState.GetObject(), (FX_ARGB)-1, 0, nullptr, 0); |
| 1543 } | 1543 } |
| 1544 } | 1544 } |
| 1545 CPDF_RenderStatus bitmap_render; | 1545 CPDF_RenderStatus bitmap_render; |
| 1546 bitmap_render.Initialize(m_pContext, &bitmap_device, nullptr, m_pStopObj, | 1546 bitmap_render.Initialize(m_pContext, &bitmap_device, nullptr, m_pStopObj, |
| 1547 nullptr, nullptr, &m_Options, 0, m_bDropObjects, | 1547 nullptr, nullptr, &m_Options, 0, m_bDropObjects, |
| 1548 pFormResource, true); | 1548 pFormResource, true); |
| 1549 bitmap_render.ProcessObjectNoClip(pPageObj, &new_matrix); | 1549 bitmap_render.ProcessObjectNoClip(pPageObj, &new_matrix); |
| 1550 #if defined _SKIA_SUPPORT_PATHS_ |
| 1551 bitmap->UnPreMultiply(); |
| 1552 #endif |
| 1550 m_bStopped = bitmap_render.m_bStopped; | 1553 m_bStopped = bitmap_render.m_bStopped; |
| 1551 if (pSMaskDict) { | 1554 if (pSMaskDict) { |
| 1552 CFX_Matrix smask_matrix = *pPageObj->m_GeneralState.GetSMaskMatrix(); | 1555 CFX_Matrix smask_matrix = *pPageObj->m_GeneralState.GetSMaskMatrix(); |
| 1553 smask_matrix.Concat(*pObj2Device); | 1556 smask_matrix.Concat(*pObj2Device); |
| 1554 std::unique_ptr<CFX_DIBSource> pSMaskSource( | 1557 std::unique_ptr<CFX_DIBSource> pSMaskSource( |
| 1555 LoadSMask(pSMaskDict, &rect, &smask_matrix)); | 1558 LoadSMask(pSMaskDict, &rect, &smask_matrix)); |
| 1556 if (pSMaskSource) | 1559 if (pSMaskSource) |
| 1557 bitmap->MultiplyAlpha(pSMaskSource.get()); | 1560 bitmap->MultiplyAlpha(pSMaskSource.get()); |
| 1558 } | 1561 } |
| 1559 if (pTextMask) { | 1562 if (pTextMask) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1643 } | 1646 } |
| 1644 return pStates; | 1647 return pStates; |
| 1645 } | 1648 } |
| 1646 | 1649 |
| 1647 #if defined _SKIA_SUPPORT_ | 1650 #if defined _SKIA_SUPPORT_ |
| 1648 void CPDF_RenderStatus::DebugVerifyDeviceIsPreMultiplied() const { | 1651 void CPDF_RenderStatus::DebugVerifyDeviceIsPreMultiplied() const { |
| 1649 m_pDevice->DebugVerifyBitmapIsPreMultiplied(); | 1652 m_pDevice->DebugVerifyBitmapIsPreMultiplied(); |
| 1650 } | 1653 } |
| 1651 #endif | 1654 #endif |
| 1652 | 1655 |
| 1653 #if defined _SKIA_SUPPORT_PATHS_ | |
| 1654 void CPDF_RenderStatus::UnPreMultiplyDevice() { | |
| 1655 m_pDevice->UnPreMultiplyDevice(); | |
| 1656 } | |
| 1657 #endif | |
| 1658 | |
| 1659 bool CPDF_RenderStatus::ProcessText(CPDF_TextObject* textobj, | 1656 bool CPDF_RenderStatus::ProcessText(CPDF_TextObject* textobj, |
| 1660 const CFX_Matrix* pObj2Device, | 1657 const CFX_Matrix* pObj2Device, |
| 1661 CFX_PathData* pClippingPath) { | 1658 CFX_PathData* pClippingPath) { |
| 1662 if (textobj->m_nChars == 0) | 1659 if (textobj->m_nChars == 0) |
| 1663 return true; | 1660 return true; |
| 1664 | 1661 |
| 1665 const TextRenderingMode text_render_mode = textobj->m_TextState.GetTextMode(); | 1662 const TextRenderingMode text_render_mode = textobj->m_TextState.GetTextMode(); |
| 1666 if (text_render_mode == TextRenderingMode::MODE_INVISIBLE) | 1663 if (text_render_mode == TextRenderingMode::MODE_INVISIBLE) |
| 1667 return true; | 1664 return true; |
| 1668 | 1665 |
| (...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2627 } else if (pFunc) { | 2624 } else if (pFunc) { |
| 2628 int size = dest_pitch * height; | 2625 int size = dest_pitch * height; |
| 2629 for (int i = 0; i < size; i++) { | 2626 for (int i = 0; i < size; i++) { |
| 2630 dest_buf[i] = transfers[src_buf[i]]; | 2627 dest_buf[i] = transfers[src_buf[i]]; |
| 2631 } | 2628 } |
| 2632 } else { | 2629 } else { |
| 2633 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); | 2630 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); |
| 2634 } | 2631 } |
| 2635 return pMask.release(); | 2632 return pMask.release(); |
| 2636 } | 2633 } |
| OLD | NEW |