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/src/fpdfapi/fpdf_render/render_int.h" | 7 #include "core/src/fpdfapi/fpdf_render/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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 pData->m_StrokeColor.Copy(&pParentData->m_StrokeColor); | 230 pData->m_StrokeColor.Copy(&pParentData->m_StrokeColor); |
231 } | 231 } |
232 } | 232 } |
233 } else { | 233 } else { |
234 m_InitialStates.DefaultStates(); | 234 m_InitialStates.DefaultStates(); |
235 } | 235 } |
236 m_pObjectRenderer.reset(); | 236 m_pObjectRenderer.reset(); |
237 m_Transparency = transparency; | 237 m_Transparency = transparency; |
238 return TRUE; | 238 return TRUE; |
239 } | 239 } |
240 void CPDF_RenderStatus::RenderObjectList(const CPDF_PageObjectList* pObjs, | 240 void CPDF_RenderStatus::RenderObjectList( |
241 const CFX_Matrix* pObj2Device) { | 241 const CPDF_PageObjectHolder* pObjectHolder, |
| 242 const CFX_Matrix* pObj2Device) { |
242 CFX_FloatRect clip_rect = m_pDevice->GetClipBox(); | 243 CFX_FloatRect clip_rect = m_pDevice->GetClipBox(); |
243 CFX_Matrix device2object; | 244 CFX_Matrix device2object; |
244 device2object.SetReverse(*pObj2Device); | 245 device2object.SetReverse(*pObj2Device); |
245 device2object.TransformRect(clip_rect); | 246 device2object.TransformRect(clip_rect); |
246 int index = 0; | 247 int index = 0; |
247 FX_POSITION pos = pObjs->GetFirstObjectPosition(); | 248 FX_POSITION pos = pObjectHolder->GetPageObjectList()->GetHeadPosition(); |
248 while (pos) { | 249 while (pos) { |
249 index++; | 250 index++; |
250 CPDF_PageObject* pCurObj = pObjs->GetNextObject(pos); | 251 CPDF_PageObject* pCurObj = |
| 252 pObjectHolder->GetPageObjectList()->GetNextObject(pos); |
251 if (pCurObj == m_pStopObj) { | 253 if (pCurObj == m_pStopObj) { |
252 m_bStopped = TRUE; | 254 m_bStopped = TRUE; |
253 return; | 255 return; |
254 } | 256 } |
255 if (!pCurObj) { | 257 if (!pCurObj) { |
256 continue; | 258 continue; |
257 } | 259 } |
258 if (!pCurObj || pCurObj->m_Left > clip_rect.right || | 260 if (!pCurObj || pCurObj->m_Left > clip_rect.right || |
259 pCurObj->m_Right < clip_rect.left || | 261 pCurObj->m_Right < clip_rect.left || |
260 pCurObj->m_Bottom > clip_rect.top || | 262 pCurObj->m_Bottom > clip_rect.top || |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 | 966 |
965 CPDF_RenderContext::CPDF_RenderContext(CPDF_Document* pDoc, | 967 CPDF_RenderContext::CPDF_RenderContext(CPDF_Document* pDoc, |
966 CPDF_PageRenderCache* pPageCache) | 968 CPDF_PageRenderCache* pPageCache) |
967 : m_pDocument(pDoc), | 969 : m_pDocument(pDoc), |
968 m_pPageResources(nullptr), | 970 m_pPageResources(nullptr), |
969 m_pPageCache(pPageCache), | 971 m_pPageCache(pPageCache), |
970 m_bFirstLayer(TRUE) {} | 972 m_bFirstLayer(TRUE) {} |
971 | 973 |
972 CPDF_RenderContext::~CPDF_RenderContext() {} | 974 CPDF_RenderContext::~CPDF_RenderContext() {} |
973 | 975 |
974 void CPDF_RenderContext::AppendLayer(CPDF_PageObjectList* pObjs, | 976 void CPDF_RenderContext::AppendLayer(CPDF_PageObjectHolder* pObjectHolder, |
975 const CFX_Matrix* pObject2Device) { | 977 const CFX_Matrix* pObject2Device) { |
976 Layer* pLayer = m_Layers.AddSpace(); | 978 Layer* pLayer = m_Layers.AddSpace(); |
977 pLayer->m_pObjectList = pObjs; | 979 pLayer->m_pObjectHolder = pObjectHolder; |
978 if (pObject2Device) { | 980 if (pObject2Device) { |
979 pLayer->m_Matrix = *pObject2Device; | 981 pLayer->m_Matrix = *pObject2Device; |
980 } else { | 982 } else { |
981 pLayer->m_Matrix.SetIdentity(); | 983 pLayer->m_Matrix.SetIdentity(); |
982 } | 984 } |
983 } | 985 } |
984 void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, | 986 void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, |
985 const CPDF_RenderOptions* pOptions, | 987 const CPDF_RenderOptions* pOptions, |
986 const CFX_Matrix* pLastMatrix) { | 988 const CFX_Matrix* pLastMatrix) { |
987 Render(pDevice, NULL, pOptions, pLastMatrix); | 989 Render(pDevice, NULL, pOptions, pLastMatrix); |
988 } | 990 } |
989 void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, | 991 void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, |
990 const CPDF_PageObject* pStopObj, | 992 const CPDF_PageObject* pStopObj, |
991 const CPDF_RenderOptions* pOptions, | 993 const CPDF_RenderOptions* pOptions, |
992 const CFX_Matrix* pLastMatrix) { | 994 const CFX_Matrix* pLastMatrix) { |
993 int count = m_Layers.GetSize(); | 995 int count = m_Layers.GetSize(); |
994 for (int j = 0; j < count; j++) { | 996 for (int j = 0; j < count; j++) { |
995 pDevice->SaveState(); | 997 pDevice->SaveState(); |
996 Layer* pLayer = m_Layers.GetDataPtr(j); | 998 Layer* pLayer = m_Layers.GetDataPtr(j); |
997 if (pLastMatrix) { | 999 if (pLastMatrix) { |
998 CFX_Matrix FinalMatrix = pLayer->m_Matrix; | 1000 CFX_Matrix FinalMatrix = pLayer->m_Matrix; |
999 FinalMatrix.Concat(*pLastMatrix); | 1001 FinalMatrix.Concat(*pLastMatrix); |
1000 CPDF_RenderStatus status; | 1002 CPDF_RenderStatus status; |
1001 status.Initialize(this, pDevice, pLastMatrix, pStopObj, NULL, NULL, | 1003 status.Initialize(this, pDevice, pLastMatrix, pStopObj, NULL, NULL, |
1002 pOptions, pLayer->m_pObjectList->m_Transparency, FALSE, | 1004 pOptions, pLayer->m_pObjectHolder->m_Transparency, |
1003 NULL); | 1005 FALSE, NULL); |
1004 status.RenderObjectList(pLayer->m_pObjectList, &FinalMatrix); | 1006 status.RenderObjectList(pLayer->m_pObjectHolder, &FinalMatrix); |
1005 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { | 1007 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { |
1006 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); | 1008 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); |
1007 } | 1009 } |
1008 if (status.m_bStopped) { | 1010 if (status.m_bStopped) { |
1009 pDevice->RestoreState(); | 1011 pDevice->RestoreState(); |
1010 break; | 1012 break; |
1011 } | 1013 } |
1012 } else { | 1014 } else { |
1013 CPDF_RenderStatus status; | 1015 CPDF_RenderStatus status; |
1014 status.Initialize(this, pDevice, NULL, pStopObj, NULL, NULL, pOptions, | 1016 status.Initialize(this, pDevice, NULL, pStopObj, NULL, NULL, pOptions, |
1015 pLayer->m_pObjectList->m_Transparency, FALSE, NULL); | 1017 pLayer->m_pObjectHolder->m_Transparency, FALSE, NULL); |
1016 status.RenderObjectList(pLayer->m_pObjectList, &pLayer->m_Matrix); | 1018 status.RenderObjectList(pLayer->m_pObjectHolder, &pLayer->m_Matrix); |
1017 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { | 1019 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { |
1018 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); | 1020 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); |
1019 } | 1021 } |
1020 if (status.m_bStopped) { | 1022 if (status.m_bStopped) { |
1021 pDevice->RestoreState(); | 1023 pDevice->RestoreState(); |
1022 break; | 1024 break; |
1023 } | 1025 } |
1024 } | 1026 } |
1025 pDevice->RestoreState(); | 1027 pDevice->RestoreState(); |
1026 } | 1028 } |
(...skipping 30 matching lines...) Expand all Loading... |
1057 if (!m_pCurrentLayer) { | 1059 if (!m_pCurrentLayer) { |
1058 if (m_LayerIndex >= m_pContext->CountLayers()) { | 1060 if (m_LayerIndex >= m_pContext->CountLayers()) { |
1059 m_Status = Done; | 1061 m_Status = Done; |
1060 return; | 1062 return; |
1061 } | 1063 } |
1062 m_pCurrentLayer = m_pContext->GetLayer(m_LayerIndex); | 1064 m_pCurrentLayer = m_pContext->GetLayer(m_LayerIndex); |
1063 m_LastObjectRendered = nullptr; | 1065 m_LastObjectRendered = nullptr; |
1064 m_pRenderStatus.reset(new CPDF_RenderStatus()); | 1066 m_pRenderStatus.reset(new CPDF_RenderStatus()); |
1065 m_pRenderStatus->Initialize( | 1067 m_pRenderStatus->Initialize( |
1066 m_pContext, m_pDevice, NULL, NULL, NULL, NULL, m_pOptions, | 1068 m_pContext, m_pDevice, NULL, NULL, NULL, NULL, m_pOptions, |
1067 m_pCurrentLayer->m_pObjectList->m_Transparency, FALSE, NULL); | 1069 m_pCurrentLayer->m_pObjectHolder->m_Transparency, FALSE, NULL); |
1068 m_pDevice->SaveState(); | 1070 m_pDevice->SaveState(); |
1069 m_ClipRect = m_pDevice->GetClipBox(); | 1071 m_ClipRect = m_pDevice->GetClipBox(); |
1070 CFX_Matrix device2object; | 1072 CFX_Matrix device2object; |
1071 device2object.SetReverse(m_pCurrentLayer->m_Matrix); | 1073 device2object.SetReverse(m_pCurrentLayer->m_Matrix); |
1072 device2object.TransformRect(m_ClipRect); | 1074 device2object.TransformRect(m_ClipRect); |
1073 } | 1075 } |
1074 FX_POSITION pos; | 1076 FX_POSITION pos; |
1075 if (m_LastObjectRendered) { | 1077 if (m_LastObjectRendered) { |
1076 pos = m_LastObjectRendered; | 1078 pos = m_LastObjectRendered; |
1077 m_pCurrentLayer->m_pObjectList->GetNextObject(pos); | 1079 m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->GetNextObject(pos); |
1078 } else { | 1080 } else { |
1079 pos = m_pCurrentLayer->m_pObjectList->GetFirstObjectPosition(); | 1081 pos = m_pCurrentLayer->m_pObjectHolder->GetPageObjectList() |
| 1082 ->GetHeadPosition(); |
1080 } | 1083 } |
1081 int nObjsToGo = kStepLimit; | 1084 int nObjsToGo = kStepLimit; |
1082 while (pos) { | 1085 while (pos) { |
1083 CPDF_PageObject* pCurObj = | 1086 CPDF_PageObject* pCurObj = |
1084 m_pCurrentLayer->m_pObjectList->GetObjectAt(pos); | 1087 m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->GetObjectAt( |
| 1088 pos); |
1085 if (pCurObj && pCurObj->m_Left <= m_ClipRect.right && | 1089 if (pCurObj && pCurObj->m_Left <= m_ClipRect.right && |
1086 pCurObj->m_Right >= m_ClipRect.left && | 1090 pCurObj->m_Right >= m_ClipRect.left && |
1087 pCurObj->m_Bottom <= m_ClipRect.top && | 1091 pCurObj->m_Bottom <= m_ClipRect.top && |
1088 pCurObj->m_Top >= m_ClipRect.bottom) { | 1092 pCurObj->m_Top >= m_ClipRect.bottom) { |
1089 if (m_pRenderStatus->ContinueSingleObject( | 1093 if (m_pRenderStatus->ContinueSingleObject( |
1090 pCurObj, &m_pCurrentLayer->m_Matrix, pPause)) { | 1094 pCurObj, &m_pCurrentLayer->m_Matrix, pPause)) { |
1091 return; | 1095 return; |
1092 } | 1096 } |
1093 if (pCurObj->m_Type == CPDF_PageObject::IMAGE && | 1097 if (pCurObj->m_Type == CPDF_PageObject::IMAGE && |
1094 m_pRenderStatus->m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { | 1098 m_pRenderStatus->m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { |
1095 m_pContext->GetPageCache()->CacheOptimization( | 1099 m_pContext->GetPageCache()->CacheOptimization( |
1096 m_pRenderStatus->m_Options.m_dwLimitCacheSize); | 1100 m_pRenderStatus->m_Options.m_dwLimitCacheSize); |
1097 } | 1101 } |
1098 if (pCurObj->m_Type == CPDF_PageObject::FORM || | 1102 if (pCurObj->m_Type == CPDF_PageObject::FORM || |
1099 pCurObj->m_Type == CPDF_PageObject::SHADING) { | 1103 pCurObj->m_Type == CPDF_PageObject::SHADING) { |
1100 nObjsToGo = 0; | 1104 nObjsToGo = 0; |
1101 } else { | 1105 } else { |
1102 --nObjsToGo; | 1106 --nObjsToGo; |
1103 } | 1107 } |
1104 } | 1108 } |
1105 m_LastObjectRendered = pos; | 1109 m_LastObjectRendered = pos; |
1106 if (nObjsToGo == 0) { | 1110 if (nObjsToGo == 0) { |
1107 if (pPause && pPause->NeedToPauseNow()) | 1111 if (pPause && pPause->NeedToPauseNow()) |
1108 return; | 1112 return; |
1109 nObjsToGo = kStepLimit; | 1113 nObjsToGo = kStepLimit; |
1110 } | 1114 } |
1111 m_pCurrentLayer->m_pObjectList->GetNextObject(pos); | 1115 m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->GetNextObject(pos); |
1112 } | 1116 } |
1113 if (m_pCurrentLayer->m_pObjectList->IsParsed()) { | 1117 if (m_pCurrentLayer->m_pObjectHolder->IsParsed()) { |
1114 m_pRenderStatus.reset(); | 1118 m_pRenderStatus.reset(); |
1115 m_pDevice->RestoreState(); | 1119 m_pDevice->RestoreState(); |
1116 m_pCurrentLayer = nullptr; | 1120 m_pCurrentLayer = nullptr; |
1117 m_LastObjectRendered = nullptr; | 1121 m_LastObjectRendered = nullptr; |
1118 m_LayerIndex++; | 1122 m_LayerIndex++; |
1119 if (pPause && pPause->NeedToPauseNow()) { | 1123 if (pPause && pPause->NeedToPauseNow()) { |
1120 return; | 1124 return; |
1121 } | 1125 } |
1122 } else { | 1126 } else { |
1123 m_pCurrentLayer->m_pObjectList->ContinueParse(pPause); | 1127 m_pCurrentLayer->m_pObjectHolder->ContinueParse(pPause); |
1124 if (!m_pCurrentLayer->m_pObjectList->IsParsed()) | 1128 if (!m_pCurrentLayer->m_pObjectHolder->IsParsed()) |
1125 return; | 1129 return; |
1126 } | 1130 } |
1127 } | 1131 } |
1128 } | 1132 } |
1129 | 1133 |
1130 CPDF_TransferFunc* CPDF_DocRenderData::GetTransferFunc(CPDF_Object* pObj) { | 1134 CPDF_TransferFunc* CPDF_DocRenderData::GetTransferFunc(CPDF_Object* pObj) { |
1131 if (!pObj) | 1135 if (!pObj) |
1132 return nullptr; | 1136 return nullptr; |
1133 | 1137 |
1134 auto it = m_TransferFuncMap.find(pObj); | 1138 auto it = m_TransferFuncMap.find(pObj); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1337 for (int i = 0; i < nItems; i++) { | 1341 for (int i = 0; i < nItems; i++) { |
1338 CPDF_ContentMarkItem& item = pData->GetItem(i); | 1342 CPDF_ContentMarkItem& item = pData->GetItem(i); |
1339 if (item.GetName() == "OC" && | 1343 if (item.GetName() == "OC" && |
1340 item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict && | 1344 item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict && |
1341 !CheckOCGVisible(item.GetParam())) { | 1345 !CheckOCGVisible(item.GetParam())) { |
1342 return FALSE; | 1346 return FALSE; |
1343 } | 1347 } |
1344 } | 1348 } |
1345 return TRUE; | 1349 return TRUE; |
1346 } | 1350 } |
OLD | NEW |