| 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 "render_int.h" | 7 #include "render_int.h" |
| 8 | 8 |
| 9 #include "core/include/fpdfapi/fpdf_module.h" | 9 #include "core/include/fpdfapi/fpdf_module.h" |
| 10 #include "core/include/fpdfapi/fpdf_render.h" | 10 #include "core/include/fpdfapi/fpdf_render.h" |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 } | 643 } |
| 644 int textcount = ClipPath.GetTextCount(); | 644 int textcount = ClipPath.GetTextCount(); |
| 645 if (textcount == 0) | 645 if (textcount == 0) |
| 646 return; | 646 return; |
| 647 | 647 |
| 648 if (m_pDevice->GetDeviceClass() == FXDC_DISPLAY && | 648 if (m_pDevice->GetDeviceClass() == FXDC_DISPLAY && |
| 649 !(m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP)) { | 649 !(m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP)) { |
| 650 return; | 650 return; |
| 651 } | 651 } |
| 652 | 652 |
| 653 nonstd::unique_ptr<CFX_PathData> pTextClippingPath; | 653 std::unique_ptr<CFX_PathData> pTextClippingPath; |
| 654 for (int i = 0; i < textcount; ++i) { | 654 for (int i = 0; i < textcount; ++i) { |
| 655 CPDF_TextObject* pText = ClipPath.GetText(i); | 655 CPDF_TextObject* pText = ClipPath.GetText(i); |
| 656 if (pText) { | 656 if (pText) { |
| 657 if (!pTextClippingPath) | 657 if (!pTextClippingPath) |
| 658 pTextClippingPath.reset(new CFX_PathData); | 658 pTextClippingPath.reset(new CFX_PathData); |
| 659 ProcessText(pText, pObj2Device, pTextClippingPath.get()); | 659 ProcessText(pText, pObj2Device, pTextClippingPath.get()); |
| 660 continue; | 660 continue; |
| 661 } | 661 } |
| 662 | 662 |
| 663 if (!pTextClippingPath) | 663 if (!pTextClippingPath) |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 rect.Intersect(m_pDevice->GetClipBox()); | 804 rect.Intersect(m_pDevice->GetClipBox()); |
| 805 if (rect.IsEmpty()) { | 805 if (rect.IsEmpty()) { |
| 806 return TRUE; | 806 return TRUE; |
| 807 } | 807 } |
| 808 CFX_Matrix deviceCTM = m_pDevice->GetCTM(); | 808 CFX_Matrix deviceCTM = m_pDevice->GetCTM(); |
| 809 FX_FLOAT scaleX = FXSYS_fabs(deviceCTM.a); | 809 FX_FLOAT scaleX = FXSYS_fabs(deviceCTM.a); |
| 810 FX_FLOAT scaleY = FXSYS_fabs(deviceCTM.d); | 810 FX_FLOAT scaleY = FXSYS_fabs(deviceCTM.d); |
| 811 int width = FXSYS_round((FX_FLOAT)rect.Width() * scaleX); | 811 int width = FXSYS_round((FX_FLOAT)rect.Width() * scaleX); |
| 812 int height = FXSYS_round((FX_FLOAT)rect.Height() * scaleY); | 812 int height = FXSYS_round((FX_FLOAT)rect.Height() * scaleY); |
| 813 CFX_FxgeDevice bitmap_device; | 813 CFX_FxgeDevice bitmap_device; |
| 814 nonstd::unique_ptr<CFX_DIBitmap> oriDevice; | 814 std::unique_ptr<CFX_DIBitmap> oriDevice; |
| 815 if (!isolated && (m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) { | 815 if (!isolated && (m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) { |
| 816 oriDevice.reset(new CFX_DIBitmap); | 816 oriDevice.reset(new CFX_DIBitmap); |
| 817 if (!m_pDevice->CreateCompatibleBitmap(oriDevice.get(), width, height)) | 817 if (!m_pDevice->CreateCompatibleBitmap(oriDevice.get(), width, height)) |
| 818 return TRUE; | 818 return TRUE; |
| 819 | 819 |
| 820 m_pDevice->GetDIBits(oriDevice.get(), rect.left, rect.top); | 820 m_pDevice->GetDIBits(oriDevice.get(), rect.left, rect.top); |
| 821 } | 821 } |
| 822 if (!bitmap_device.Create(width, height, FXDIB_Argb, 0, oriDevice.get())) | 822 if (!bitmap_device.Create(width, height, FXDIB_Argb, 0, oriDevice.get())) |
| 823 return TRUE; | 823 return TRUE; |
| 824 | 824 |
| 825 CFX_DIBitmap* bitmap = bitmap_device.GetBitmap(); | 825 CFX_DIBitmap* bitmap = bitmap_device.GetBitmap(); |
| 826 bitmap->Clear(0); | 826 bitmap->Clear(0); |
| 827 CFX_Matrix new_matrix = *pObj2Device; | 827 CFX_Matrix new_matrix = *pObj2Device; |
| 828 new_matrix.TranslateI(-rect.left, -rect.top); | 828 new_matrix.TranslateI(-rect.left, -rect.top); |
| 829 new_matrix.Scale(scaleX, scaleY); | 829 new_matrix.Scale(scaleX, scaleY); |
| 830 nonstd::unique_ptr<CFX_DIBitmap> pTextMask; | 830 std::unique_ptr<CFX_DIBitmap> pTextMask; |
| 831 if (bTextClip) { | 831 if (bTextClip) { |
| 832 pTextMask.reset(new CFX_DIBitmap); | 832 pTextMask.reset(new CFX_DIBitmap); |
| 833 if (!pTextMask->Create(width, height, FXDIB_8bppMask)) | 833 if (!pTextMask->Create(width, height, FXDIB_8bppMask)) |
| 834 return TRUE; | 834 return TRUE; |
| 835 | 835 |
| 836 pTextMask->Clear(0); | 836 pTextMask->Clear(0); |
| 837 CFX_FxgeDevice text_device; | 837 CFX_FxgeDevice text_device; |
| 838 text_device.Attach(pTextMask.get()); | 838 text_device.Attach(pTextMask.get()); |
| 839 for (FX_DWORD i = 0; i < pPageObj->m_ClipPath.GetTextCount(); i++) { | 839 for (FX_DWORD i = 0; i < pPageObj->m_ClipPath.GetTextCount(); i++) { |
| 840 CPDF_TextObject* textobj = pPageObj->m_ClipPath.GetText(i); | 840 CPDF_TextObject* textobj = pPageObj->m_ClipPath.GetText(i); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 854 bitmap_render.Initialize(m_pContext, &bitmap_device, NULL, m_pStopObj, NULL, | 854 bitmap_render.Initialize(m_pContext, &bitmap_device, NULL, m_pStopObj, NULL, |
| 855 NULL, &m_Options, 0, m_bDropObjects, pFormResource, | 855 NULL, &m_Options, 0, m_bDropObjects, pFormResource, |
| 856 TRUE); | 856 TRUE); |
| 857 bitmap_render.ProcessObjectNoClip(pPageObj, &new_matrix); | 857 bitmap_render.ProcessObjectNoClip(pPageObj, &new_matrix); |
| 858 m_bStopped = bitmap_render.m_bStopped; | 858 m_bStopped = bitmap_render.m_bStopped; |
| 859 if (pSMaskDict) { | 859 if (pSMaskDict) { |
| 860 CFX_Matrix smask_matrix; | 860 CFX_Matrix smask_matrix; |
| 861 FXSYS_memcpy(&smask_matrix, pGeneralState->m_SMaskMatrix, | 861 FXSYS_memcpy(&smask_matrix, pGeneralState->m_SMaskMatrix, |
| 862 sizeof smask_matrix); | 862 sizeof smask_matrix); |
| 863 smask_matrix.Concat(*pObj2Device); | 863 smask_matrix.Concat(*pObj2Device); |
| 864 nonstd::unique_ptr<CFX_DIBSource> pSMaskSource( | 864 std::unique_ptr<CFX_DIBSource> pSMaskSource( |
| 865 LoadSMask(pSMaskDict, &rect, &smask_matrix)); | 865 LoadSMask(pSMaskDict, &rect, &smask_matrix)); |
| 866 if (pSMaskSource) | 866 if (pSMaskSource) |
| 867 bitmap->MultiplyAlpha(pSMaskSource.get()); | 867 bitmap->MultiplyAlpha(pSMaskSource.get()); |
| 868 } | 868 } |
| 869 if (pTextMask) { | 869 if (pTextMask) { |
| 870 bitmap->MultiplyAlpha(pTextMask.get()); | 870 bitmap->MultiplyAlpha(pTextMask.get()); |
| 871 pTextMask.reset(); | 871 pTextMask.reset(); |
| 872 } | 872 } |
| 873 if (Transparency & PDFTRANS_GROUP && group_alpha != 1.0f) { | 873 if (Transparency & PDFTRANS_GROUP && group_alpha != 1.0f) { |
| 874 bitmap->MultiplyAlpha((int32_t)(group_alpha * 255)); | 874 bitmap->MultiplyAlpha((int32_t)(group_alpha * 255)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 889 FX_BOOL bBackAlphaRequired) { | 889 FX_BOOL bBackAlphaRequired) { |
| 890 FX_RECT bbox = rect; | 890 FX_RECT bbox = rect; |
| 891 bbox.Intersect(m_pDevice->GetClipBox()); | 891 bbox.Intersect(m_pDevice->GetClipBox()); |
| 892 left = bbox.left; | 892 left = bbox.left; |
| 893 top = bbox.top; | 893 top = bbox.top; |
| 894 CFX_Matrix deviceCTM = m_pDevice->GetCTM(); | 894 CFX_Matrix deviceCTM = m_pDevice->GetCTM(); |
| 895 FX_FLOAT scaleX = FXSYS_fabs(deviceCTM.a); | 895 FX_FLOAT scaleX = FXSYS_fabs(deviceCTM.a); |
| 896 FX_FLOAT scaleY = FXSYS_fabs(deviceCTM.d); | 896 FX_FLOAT scaleY = FXSYS_fabs(deviceCTM.d); |
| 897 int width = FXSYS_round(bbox.Width() * scaleX); | 897 int width = FXSYS_round(bbox.Width() * scaleX); |
| 898 int height = FXSYS_round(bbox.Height() * scaleY); | 898 int height = FXSYS_round(bbox.Height() * scaleY); |
| 899 nonstd::unique_ptr<CFX_DIBitmap> pBackdrop(new CFX_DIBitmap); | 899 std::unique_ptr<CFX_DIBitmap> pBackdrop(new CFX_DIBitmap); |
| 900 if (bBackAlphaRequired && !m_bDropObjects) | 900 if (bBackAlphaRequired && !m_bDropObjects) |
| 901 pBackdrop->Create(width, height, FXDIB_Argb); | 901 pBackdrop->Create(width, height, FXDIB_Argb); |
| 902 else | 902 else |
| 903 m_pDevice->CreateCompatibleBitmap(pBackdrop.get(), width, height); | 903 m_pDevice->CreateCompatibleBitmap(pBackdrop.get(), width, height); |
| 904 | 904 |
| 905 if (!pBackdrop->GetBuffer()) | 905 if (!pBackdrop->GetBuffer()) |
| 906 return nullptr; | 906 return nullptr; |
| 907 | 907 |
| 908 FX_BOOL bNeedDraw; | 908 FX_BOOL bNeedDraw; |
| 909 if (pBackdrop->HasAlpha()) | 909 if (pBackdrop->HasAlpha()) |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1183 CPDF_TransferFunc* CPDF_DocRenderData::GetTransferFunc(CPDF_Object* pObj) { | 1183 CPDF_TransferFunc* CPDF_DocRenderData::GetTransferFunc(CPDF_Object* pObj) { |
| 1184 if (!pObj) | 1184 if (!pObj) |
| 1185 return nullptr; | 1185 return nullptr; |
| 1186 | 1186 |
| 1187 auto it = m_TransferFuncMap.find(pObj); | 1187 auto it = m_TransferFuncMap.find(pObj); |
| 1188 if (it != m_TransferFuncMap.end()) { | 1188 if (it != m_TransferFuncMap.end()) { |
| 1189 CPDF_CountedObject<CPDF_TransferFunc>* pTransferCounter = it->second; | 1189 CPDF_CountedObject<CPDF_TransferFunc>* pTransferCounter = it->second; |
| 1190 return pTransferCounter->AddRef(); | 1190 return pTransferCounter->AddRef(); |
| 1191 } | 1191 } |
| 1192 | 1192 |
| 1193 nonstd::unique_ptr<CPDF_Function> pFuncs[3]; | 1193 std::unique_ptr<CPDF_Function> pFuncs[3]; |
| 1194 FX_BOOL bUniTransfer = TRUE; | 1194 FX_BOOL bUniTransfer = TRUE; |
| 1195 FX_BOOL bIdentity = TRUE; | 1195 FX_BOOL bIdentity = TRUE; |
| 1196 if (CPDF_Array* pArray = pObj->AsArray()) { | 1196 if (CPDF_Array* pArray = pObj->AsArray()) { |
| 1197 bUniTransfer = FALSE; | 1197 bUniTransfer = FALSE; |
| 1198 if (pArray->GetCount() < 3) | 1198 if (pArray->GetCount() < 3) |
| 1199 return nullptr; | 1199 return nullptr; |
| 1200 | 1200 |
| 1201 for (FX_DWORD i = 0; i < 3; ++i) { | 1201 for (FX_DWORD i = 0; i < 3; ++i) { |
| 1202 pFuncs[2 - i].reset(CPDF_Function::Load(pArray->GetElementValue(i))); | 1202 pFuncs[2 - i].reset(CPDF_Function::Load(pArray->GetElementValue(i))); |
| 1203 if (!pFuncs[2 - i]) | 1203 if (!pFuncs[2 - i]) |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1398 item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict) { | 1398 item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict) { |
| 1399 CPDF_Dictionary* pOCG = | 1399 CPDF_Dictionary* pOCG = |
| 1400 ToDictionary(static_cast<CPDF_Object*>(item.GetParam())); | 1400 ToDictionary(static_cast<CPDF_Object*>(item.GetParam())); |
| 1401 if (!CheckOCGVisible(pOCG)) { | 1401 if (!CheckOCGVisible(pOCG)) { |
| 1402 return FALSE; | 1402 return FALSE; |
| 1403 } | 1403 } |
| 1404 } | 1404 } |
| 1405 } | 1405 } |
| 1406 return TRUE; | 1406 return TRUE; |
| 1407 } | 1407 } |
| OLD | NEW |