Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: core/src/fpdfapi/fpdf_render/fpdf_render.cpp

Issue 1700183002: Remove CFX_PtrList from renderer main loop. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Nits. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fpdfapi/fpdf_page/pageint.h ('k') | core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 m_Transparency = transparency; 237 m_Transparency = transparency;
238 return TRUE; 238 return TRUE;
239 } 239 }
240 void CPDF_RenderStatus::RenderObjectList( 240 void CPDF_RenderStatus::RenderObjectList(
241 const CPDF_PageObjectHolder* pObjectHolder, 241 const CPDF_PageObjectHolder* pObjectHolder,
242 const CFX_Matrix* pObj2Device) { 242 const CFX_Matrix* pObj2Device) {
243 CFX_FloatRect clip_rect = m_pDevice->GetClipBox(); 243 CFX_FloatRect clip_rect = m_pDevice->GetClipBox();
244 CFX_Matrix device2object; 244 CFX_Matrix device2object;
245 device2object.SetReverse(*pObj2Device); 245 device2object.SetReverse(*pObj2Device);
246 device2object.TransformRect(clip_rect); 246 device2object.TransformRect(clip_rect);
247 int index = 0; 247
248 FX_POSITION pos = pObjectHolder->GetPageObjectList()->GetHeadPosition(); 248 for (const auto& pCurObj : *pObjectHolder->GetPageObjectList()) {
249 while (pos) { 249 if (pCurObj.get() == m_pStopObj) {
250 index++;
251 CPDF_PageObject* pCurObj =
252 pObjectHolder->GetPageObjectList()->GetNextObject(pos);
253 if (pCurObj == m_pStopObj) {
254 m_bStopped = TRUE; 250 m_bStopped = TRUE;
255 return; 251 return;
256 } 252 }
257 if (!pCurObj) { 253 if (!pCurObj)
258 continue; 254 continue;
259 } 255
260 if (!pCurObj || pCurObj->m_Left > clip_rect.right || 256 if (pCurObj->m_Left > clip_rect.right ||
261 pCurObj->m_Right < clip_rect.left || 257 pCurObj->m_Right < clip_rect.left ||
262 pCurObj->m_Bottom > clip_rect.top || 258 pCurObj->m_Bottom > clip_rect.top ||
263 pCurObj->m_Top < clip_rect.bottom) { 259 pCurObj->m_Top < clip_rect.bottom) {
264 continue; 260 continue;
265 } 261 }
266 RenderSingleObject(pCurObj, pObj2Device); 262 RenderSingleObject(pCurObj.get(), pObj2Device);
267 if (m_bStopped) { 263 if (m_bStopped)
268 return; 264 return;
269 }
270 } 265 }
271 } 266 }
272 void CPDF_RenderStatus::RenderSingleObject(const CPDF_PageObject* pObj, 267 void CPDF_RenderStatus::RenderSingleObject(const CPDF_PageObject* pObj,
273 const CFX_Matrix* pObj2Device) { 268 const CFX_Matrix* pObj2Device) {
274 CFX_AutoRestorer<int> restorer(&s_CurrentRecursionDepth); 269 CFX_AutoRestorer<int> restorer(&s_CurrentRecursionDepth);
275 if (++s_CurrentRecursionDepth > kRenderMaxRecursionDepth) { 270 if (++s_CurrentRecursionDepth > kRenderMaxRecursionDepth) {
276 return; 271 return;
277 } 272 }
278 m_pCurObj = pObj; 273 m_pCurObj = pObj;
279 if (m_Options.m_pOCContext && pObj->m_ContentMark.NotNull()) { 274 if (m_Options.m_pOCContext && pObj->m_ContentMark.NotNull()) {
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 1025
1031 CPDF_ProgressiveRenderer::CPDF_ProgressiveRenderer( 1026 CPDF_ProgressiveRenderer::CPDF_ProgressiveRenderer(
1032 CPDF_RenderContext* pContext, 1027 CPDF_RenderContext* pContext,
1033 CFX_RenderDevice* pDevice, 1028 CFX_RenderDevice* pDevice,
1034 const CPDF_RenderOptions* pOptions) 1029 const CPDF_RenderOptions* pOptions)
1035 : m_Status(Ready), 1030 : m_Status(Ready),
1036 m_pContext(pContext), 1031 m_pContext(pContext),
1037 m_pDevice(pDevice), 1032 m_pDevice(pDevice),
1038 m_pOptions(pOptions), 1033 m_pOptions(pOptions),
1039 m_LayerIndex(0), 1034 m_LayerIndex(0),
1040 m_pCurrentLayer(nullptr), 1035 m_pCurrentLayer(nullptr) {}
1041 m_LastObjectRendered(nullptr) {}
1042 1036
1043 CPDF_ProgressiveRenderer::~CPDF_ProgressiveRenderer() { 1037 CPDF_ProgressiveRenderer::~CPDF_ProgressiveRenderer() {
1044 if (m_pRenderStatus) 1038 if (m_pRenderStatus)
1045 m_pDevice->RestoreState(); 1039 m_pDevice->RestoreState();
1046 } 1040 }
1047 1041
1048 void CPDF_ProgressiveRenderer::Start(IFX_Pause* pPause) { 1042 void CPDF_ProgressiveRenderer::Start(IFX_Pause* pPause) {
1049 if (!m_pContext || !m_pDevice || m_Status != Ready) { 1043 if (!m_pContext || !m_pDevice || m_Status != Ready) {
1050 m_Status = Failed; 1044 m_Status = Failed;
1051 return; 1045 return;
1052 } 1046 }
1053 m_Status = ToBeContinued; 1047 m_Status = ToBeContinued;
1054 Continue(pPause); 1048 Continue(pPause);
1055 } 1049 }
1056 1050
1057 void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) { 1051 void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) {
1058 while (m_Status == ToBeContinued) { 1052 while (m_Status == ToBeContinued) {
1059 if (!m_pCurrentLayer) { 1053 if (!m_pCurrentLayer) {
1060 if (m_LayerIndex >= m_pContext->CountLayers()) { 1054 if (m_LayerIndex >= m_pContext->CountLayers()) {
1061 m_Status = Done; 1055 m_Status = Done;
1062 return; 1056 return;
1063 } 1057 }
1064 m_pCurrentLayer = m_pContext->GetLayer(m_LayerIndex); 1058 m_pCurrentLayer = m_pContext->GetLayer(m_LayerIndex);
1065 m_LastObjectRendered = nullptr; 1059 m_LastObjectRendered =
1060 m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->end();
1066 m_pRenderStatus.reset(new CPDF_RenderStatus()); 1061 m_pRenderStatus.reset(new CPDF_RenderStatus());
1067 m_pRenderStatus->Initialize( 1062 m_pRenderStatus->Initialize(
1068 m_pContext, m_pDevice, NULL, NULL, NULL, NULL, m_pOptions, 1063 m_pContext, m_pDevice, NULL, NULL, NULL, NULL, m_pOptions,
1069 m_pCurrentLayer->m_pObjectHolder->m_Transparency, FALSE, NULL); 1064 m_pCurrentLayer->m_pObjectHolder->m_Transparency, FALSE, NULL);
1070 m_pDevice->SaveState(); 1065 m_pDevice->SaveState();
1071 m_ClipRect = m_pDevice->GetClipBox(); 1066 m_ClipRect = m_pDevice->GetClipBox();
1072 CFX_Matrix device2object; 1067 CFX_Matrix device2object;
1073 device2object.SetReverse(m_pCurrentLayer->m_Matrix); 1068 device2object.SetReverse(m_pCurrentLayer->m_Matrix);
1074 device2object.TransformRect(m_ClipRect); 1069 device2object.TransformRect(m_ClipRect);
1075 } 1070 }
1076 FX_POSITION pos; 1071 CPDF_PageObjectList::iterator iter;
1077 if (m_LastObjectRendered) { 1072 CPDF_PageObjectList::iterator iterEnd =
1078 pos = m_LastObjectRendered; 1073 m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->end();
1079 m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->GetNextObject(pos); 1074 if (m_LastObjectRendered != iterEnd) {
1075 iter = m_LastObjectRendered;
1076 ++iter;
1080 } else { 1077 } else {
1081 pos = m_pCurrentLayer->m_pObjectHolder->GetPageObjectList() 1078 iter = m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->begin();
1082 ->GetHeadPosition();
1083 } 1079 }
1084 int nObjsToGo = kStepLimit; 1080 int nObjsToGo = kStepLimit;
1085 while (pos) { 1081 while (iter != iterEnd) {
1086 CPDF_PageObject* pCurObj = 1082 CPDF_PageObject* pCurObj = iter->get();
1087 m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->GetObjectAt(
1088 pos);
1089 if (pCurObj && pCurObj->m_Left <= m_ClipRect.right && 1083 if (pCurObj && pCurObj->m_Left <= m_ClipRect.right &&
1090 pCurObj->m_Right >= m_ClipRect.left && 1084 pCurObj->m_Right >= m_ClipRect.left &&
1091 pCurObj->m_Bottom <= m_ClipRect.top && 1085 pCurObj->m_Bottom <= m_ClipRect.top &&
1092 pCurObj->m_Top >= m_ClipRect.bottom) { 1086 pCurObj->m_Top >= m_ClipRect.bottom) {
1093 if (m_pRenderStatus->ContinueSingleObject( 1087 if (m_pRenderStatus->ContinueSingleObject(
1094 pCurObj, &m_pCurrentLayer->m_Matrix, pPause)) { 1088 pCurObj, &m_pCurrentLayer->m_Matrix, pPause)) {
1095 return; 1089 return;
1096 } 1090 }
1097 if (pCurObj->m_Type == CPDF_PageObject::IMAGE && 1091 if (pCurObj->m_Type == CPDF_PageObject::IMAGE &&
1098 m_pRenderStatus->m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { 1092 m_pRenderStatus->m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) {
1099 m_pContext->GetPageCache()->CacheOptimization( 1093 m_pContext->GetPageCache()->CacheOptimization(
1100 m_pRenderStatus->m_Options.m_dwLimitCacheSize); 1094 m_pRenderStatus->m_Options.m_dwLimitCacheSize);
1101 } 1095 }
1102 if (pCurObj->m_Type == CPDF_PageObject::FORM || 1096 if (pCurObj->m_Type == CPDF_PageObject::FORM ||
1103 pCurObj->m_Type == CPDF_PageObject::SHADING) { 1097 pCurObj->m_Type == CPDF_PageObject::SHADING) {
1104 nObjsToGo = 0; 1098 nObjsToGo = 0;
1105 } else { 1099 } else {
1106 --nObjsToGo; 1100 --nObjsToGo;
1107 } 1101 }
1108 } 1102 }
1109 m_LastObjectRendered = pos; 1103 m_LastObjectRendered = iter;
1110 if (nObjsToGo == 0) { 1104 if (nObjsToGo == 0) {
1111 if (pPause && pPause->NeedToPauseNow()) 1105 if (pPause && pPause->NeedToPauseNow())
1112 return; 1106 return;
1113 nObjsToGo = kStepLimit; 1107 nObjsToGo = kStepLimit;
1114 } 1108 }
1115 m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->GetNextObject(pos); 1109 ++iter;
1116 } 1110 }
1117 if (m_pCurrentLayer->m_pObjectHolder->IsParsed()) { 1111 if (m_pCurrentLayer->m_pObjectHolder->IsParsed()) {
1118 m_pRenderStatus.reset(); 1112 m_pRenderStatus.reset();
1119 m_pDevice->RestoreState(); 1113 m_pDevice->RestoreState();
1120 m_pCurrentLayer = nullptr; 1114 m_pCurrentLayer = nullptr;
1121 m_LastObjectRendered = nullptr;
1122 m_LayerIndex++; 1115 m_LayerIndex++;
1123 if (pPause && pPause->NeedToPauseNow()) { 1116 if (pPause && pPause->NeedToPauseNow()) {
1124 return; 1117 return;
1125 } 1118 }
1126 } else { 1119 } else {
1127 m_pCurrentLayer->m_pObjectHolder->ContinueParse(pPause); 1120 m_pCurrentLayer->m_pObjectHolder->ContinueParse(pPause);
1128 if (!m_pCurrentLayer->m_pObjectHolder->IsParsed()) 1121 if (!m_pCurrentLayer->m_pObjectHolder->IsParsed())
1129 return; 1122 return;
1130 } 1123 }
1131 } 1124 }
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 for (int i = 0; i < nItems; i++) { 1334 for (int i = 0; i < nItems; i++) {
1342 CPDF_ContentMarkItem& item = pData->GetItem(i); 1335 CPDF_ContentMarkItem& item = pData->GetItem(i);
1343 if (item.GetName() == "OC" && 1336 if (item.GetName() == "OC" &&
1344 item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict && 1337 item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict &&
1345 !CheckOCGVisible(item.GetParam())) { 1338 !CheckOCGVisible(item.GetParam())) {
1346 return FALSE; 1339 return FALSE;
1347 } 1340 }
1348 } 1341 }
1349 return TRUE; 1342 return TRUE;
1350 } 1343 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_page/pageint.h ('k') | core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698