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 "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" |
11 #include "core/include/fxge/fx_ge.h" | 11 #include "core/include/fxge/fx_ge.h" |
12 #include "core/src/fpdfapi/fpdf_page/pageint.h" | 12 #include "core/src/fpdfapi/fpdf_page/pageint.h" |
13 | 13 |
14 CPDF_DocRenderData::CPDF_DocRenderData(CPDF_Document* pPDFDoc) | 14 CPDF_DocRenderData::CPDF_DocRenderData(CPDF_Document* pPDFDoc) |
15 : m_pPDFDoc(pPDFDoc), m_pFontCache(new CFX_FontCache) {} | 15 : m_pPDFDoc(pPDFDoc), m_pFontCache(new CFX_FontCache) {} |
16 | 16 |
17 CPDF_DocRenderData::~CPDF_DocRenderData() { | 17 CPDF_DocRenderData::~CPDF_DocRenderData() { |
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1032 CPDF_ProgressiveRenderer::CPDF_ProgressiveRenderer( | 1032 CPDF_ProgressiveRenderer::CPDF_ProgressiveRenderer( |
1033 CPDF_RenderContext* pContext, | 1033 CPDF_RenderContext* pContext, |
1034 CFX_RenderDevice* pDevice, | 1034 CFX_RenderDevice* pDevice, |
1035 const CPDF_RenderOptions* pOptions) | 1035 const CPDF_RenderOptions* pOptions) |
1036 : m_Status(Ready), | 1036 : m_Status(Ready), |
1037 m_pContext(pContext), | 1037 m_pContext(pContext), |
1038 m_pDevice(pDevice), | 1038 m_pDevice(pDevice), |
1039 m_pOptions(pOptions), | 1039 m_pOptions(pOptions), |
1040 m_LayerIndex(0), | 1040 m_LayerIndex(0), |
1041 m_ObjectIndex(0), | 1041 m_ObjectIndex(0), |
1042 m_ObjectPos(nullptr), | 1042 m_pCurrentLayer(nullptr), |
1043 m_PrevLastPos(nullptr) { | 1043 m_ObjectPos(nullptr) {} |
1044 } | |
1045 | 1044 |
1046 CPDF_ProgressiveRenderer::~CPDF_ProgressiveRenderer() { | 1045 CPDF_ProgressiveRenderer::~CPDF_ProgressiveRenderer() { |
1047 if (m_pRenderStatus) | 1046 if (m_pRenderStatus) |
1048 m_pDevice->RestoreState(); | 1047 m_pDevice->RestoreState(); |
1049 } | 1048 } |
1050 | 1049 |
1051 void CPDF_ProgressiveRenderer::Start(IFX_Pause* pPause) { | 1050 void CPDF_ProgressiveRenderer::Start(IFX_Pause* pPause) { |
1052 if (!m_pContext || !m_pDevice || m_Status != Ready) { | 1051 if (!m_pContext || !m_pDevice || m_Status != Ready) { |
1053 m_Status = Failed; | 1052 m_Status = Failed; |
1054 return; | 1053 return; |
1055 } | 1054 } |
1056 m_Status = ToBeContinued; | 1055 m_Status = ToBeContinued; |
1057 Continue(pPause); | 1056 Continue(pPause); |
1058 } | 1057 } |
1059 | 1058 |
1060 void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) { | 1059 void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) { |
1061 if (m_Status != ToBeContinued) { | 1060 int step_limit = |
1062 return; | 1061 CPDF_ModuleMgr::Get()->GetRenderModule()->GetConfig()->m_RenderStepLimit; |
1063 } | 1062 int objs_to_go = step_limit; |
Tom Sepez
2016/02/12 20:19:20
Change in behaviour here, we check for limit every
| |
1064 FX_DWORD nLayers = m_pContext->CountLayers(); | 1063 while (m_Status == ToBeContinued) { |
1065 for (; m_LayerIndex < nLayers; m_LayerIndex++) { | 1064 if (!m_pCurrentLayer) { |
1066 CPDF_RenderContext::Layer* pLayer = m_pContext->GetLayer(m_LayerIndex); | 1065 if (m_LayerIndex >= m_pContext->CountLayers()) { |
1067 FX_POSITION LastPos = pLayer->m_pObjectList->GetLastObjectPosition(); | 1066 m_Status = Done; |
1068 if (!m_ObjectPos) { | 1067 return; |
1069 if (LastPos == m_PrevLastPos) { | |
Tom Sepez
2016/02/12 20:19:20
We now use the notion of a "current layer" rather
| |
1070 if (!pLayer->m_pObjectList->IsParsed()) { | |
1071 pLayer->m_pObjectList->ContinueParse(pPause); | |
1072 if (!pLayer->m_pObjectList->IsParsed()) { | |
1073 return; | |
1074 } | |
1075 LastPos = pLayer->m_pObjectList->GetLastObjectPosition(); | |
1076 } | |
1077 } | 1068 } |
1078 if (LastPos == m_PrevLastPos) { | 1069 CPDF_RenderContext::Layer* pLayer = m_pContext->GetLayer(m_LayerIndex); |
Tom Sepez
2016/02/12 20:19:20
This cleanup falls down to below and merges with b
| |
1079 if (m_pRenderStatus) { | 1070 if (!pLayer->m_pObjectList->IsParsed()) { |
1080 m_pRenderStatus.reset(); | 1071 pLayer->m_pObjectList->ContinueParse(pPause); |
1081 m_pDevice->RestoreState(); | 1072 if (!pLayer->m_pObjectList->IsParsed()) |
1082 m_ObjectPos = NULL; | 1073 return; |
1083 m_PrevLastPos = NULL; | |
1084 } | |
1085 continue; | |
1086 } | 1074 } |
1087 if (m_PrevLastPos) { | 1075 m_pCurrentLayer = pLayer; |
1088 m_ObjectPos = m_PrevLastPos; | |
1089 pLayer->m_pObjectList->GetNextObject(m_ObjectPos); | |
1090 } else { | |
1091 m_ObjectPos = pLayer->m_pObjectList->GetFirstObjectPosition(); | |
1092 } | |
1093 m_PrevLastPos = LastPos; | |
1094 } | |
1095 if (!m_pRenderStatus) { | |
1096 m_ObjectPos = pLayer->m_pObjectList->GetFirstObjectPosition(); | 1076 m_ObjectPos = pLayer->m_pObjectList->GetFirstObjectPosition(); |
1097 m_ObjectIndex = 0; | 1077 m_ObjectIndex = 0; |
1098 m_pRenderStatus.reset(new CPDF_RenderStatus()); | 1078 m_pRenderStatus.reset(new CPDF_RenderStatus()); |
1099 m_pRenderStatus->Initialize( | 1079 m_pRenderStatus->Initialize( |
1100 m_pContext, m_pDevice, NULL, NULL, NULL, NULL, m_pOptions, | 1080 m_pContext, m_pDevice, NULL, NULL, NULL, NULL, m_pOptions, |
1101 pLayer->m_pObjectList->m_Transparency, FALSE, NULL); | 1081 pLayer->m_pObjectList->m_Transparency, FALSE, NULL); |
1102 m_pDevice->SaveState(); | 1082 m_pDevice->SaveState(); |
1103 m_ClipRect = m_pDevice->GetClipBox(); | 1083 m_ClipRect = m_pDevice->GetClipBox(); |
1104 CFX_Matrix device2object; | 1084 CFX_Matrix device2object; |
1105 device2object.SetReverse(pLayer->m_Matrix); | 1085 device2object.SetReverse(pLayer->m_Matrix); |
1106 device2object.TransformRect(m_ClipRect); | 1086 device2object.TransformRect(m_ClipRect); |
1107 } | 1087 } |
1108 int objs_to_go = CPDF_ModuleMgr::Get() | |
1109 ->GetRenderModule() | |
1110 ->GetConfig() | |
1111 ->m_RenderStepLimit; | |
1112 while (m_ObjectPos) { | 1088 while (m_ObjectPos) { |
1113 CPDF_PageObject* pCurObj = | 1089 CPDF_PageObject* pCurObj = |
1114 pLayer->m_pObjectList->GetObjectAt(m_ObjectPos); | 1090 m_pCurrentLayer->m_pObjectList->GetObjectAt(m_ObjectPos); |
1115 if (pCurObj && pCurObj->m_Left <= m_ClipRect.right && | 1091 if (pCurObj && pCurObj->m_Left <= m_ClipRect.right && |
1116 pCurObj->m_Right >= m_ClipRect.left && | 1092 pCurObj->m_Right >= m_ClipRect.left && |
1117 pCurObj->m_Bottom <= m_ClipRect.top && | 1093 pCurObj->m_Bottom <= m_ClipRect.top && |
1118 pCurObj->m_Top >= m_ClipRect.bottom) { | 1094 pCurObj->m_Top >= m_ClipRect.bottom) { |
1119 if (m_pRenderStatus->ContinueSingleObject(pCurObj, &pLayer->m_Matrix, | 1095 if (m_pRenderStatus->ContinueSingleObject( |
1120 pPause)) { | 1096 pCurObj, &m_pCurrentLayer->m_Matrix, pPause)) { |
1121 return; | 1097 return; |
1122 } | 1098 } |
1123 if (pCurObj->m_Type == CPDF_PageObject::IMAGE && | 1099 if (pCurObj->m_Type == CPDF_PageObject::IMAGE && |
1124 m_pRenderStatus->m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { | 1100 m_pRenderStatus->m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { |
1125 m_pContext->GetPageCache()->CacheOptimization( | 1101 m_pContext->GetPageCache()->CacheOptimization( |
1126 m_pRenderStatus->m_Options.m_dwLimitCacheSize); | 1102 m_pRenderStatus->m_Options.m_dwLimitCacheSize); |
1127 } | 1103 } |
1104 m_ObjectIndex++; | |
1105 m_pCurrentLayer->m_pObjectList->GetNextObject(m_ObjectPos); | |
1128 if (pCurObj->m_Type == CPDF_PageObject::FORM || | 1106 if (pCurObj->m_Type == CPDF_PageObject::FORM || |
1129 pCurObj->m_Type == CPDF_PageObject::SHADING) { | 1107 pCurObj->m_Type == CPDF_PageObject::SHADING || --objs_to_go == 0) { |
1130 objs_to_go = 0; | 1108 if (pPause && pPause->NeedToPauseNow()) { |
1131 } else { | 1109 return; |
1132 objs_to_go--; | 1110 } |
1111 objs_to_go = step_limit; | |
1133 } | 1112 } |
1134 } | 1113 } |
1135 m_ObjectIndex++; | |
1136 pLayer->m_pObjectList->GetNextObject(m_ObjectPos); | |
1137 if (objs_to_go == 0) { | |
1138 if (pPause && pPause->NeedToPauseNow()) { | |
1139 return; | |
1140 } | |
1141 objs_to_go = CPDF_ModuleMgr::Get() | |
1142 ->GetRenderModule() | |
1143 ->GetConfig() | |
1144 ->m_RenderStepLimit; | |
1145 } | |
1146 } | |
1147 if (!pLayer->m_pObjectList->IsParsed()) { | |
1148 return; | |
1149 } | 1114 } |
1150 m_pRenderStatus.reset(); | 1115 m_pRenderStatus.reset(); |
1151 m_pDevice->RestoreState(); | 1116 m_pDevice->RestoreState(); |
1152 m_ObjectPos = NULL; | 1117 m_ObjectPos = NULL; |
1153 m_PrevLastPos = NULL; | 1118 m_pCurrentLayer = nullptr; |
1154 if (pPause && pPause->NeedToPauseNow()) { | 1119 m_LayerIndex++; |
1155 m_LayerIndex++; | |
1156 return; | |
1157 } | |
1158 } | 1120 } |
1159 m_Status = Done; | |
1160 } | 1121 } |
1122 | |
1161 int CPDF_ProgressiveRenderer::EstimateProgress() { | 1123 int CPDF_ProgressiveRenderer::EstimateProgress() { |
1162 if (!m_pContext) { | 1124 if (!m_pContext) { |
1163 return 0; | 1125 return 0; |
1164 } | 1126 } |
1165 FX_DWORD nLayers = m_pContext->CountLayers(); | 1127 FX_DWORD nLayers = m_pContext->CountLayers(); |
1166 int nTotal = 0; | 1128 int nTotal = 0; |
1167 int nRendered = 0; | 1129 int nRendered = 0; |
1168 for (FX_DWORD layer = 0; layer < nLayers; layer++) { | 1130 for (FX_DWORD layer = 0; layer < nLayers; layer++) { |
1169 CPDF_RenderContext::Layer* pLayer = m_pContext->GetLayer(layer); | 1131 CPDF_RenderContext::Layer* pLayer = m_pContext->GetLayer(layer); |
1170 int nObjs = pLayer->m_pObjectList->CountObjects(); | 1132 int nObjs = pLayer->m_pObjectList->CountObjects(); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1398 item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict) { | 1360 item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict) { |
1399 CPDF_Dictionary* pOCG = | 1361 CPDF_Dictionary* pOCG = |
1400 ToDictionary(static_cast<CPDF_Object*>(item.GetParam())); | 1362 ToDictionary(static_cast<CPDF_Object*>(item.GetParam())); |
1401 if (!CheckOCGVisible(pOCG)) { | 1363 if (!CheckOCGVisible(pOCG)) { |
1402 return FALSE; | 1364 return FALSE; |
1403 } | 1365 } |
1404 } | 1366 } |
1405 } | 1367 } |
1406 return TRUE; | 1368 return TRUE; |
1407 } | 1369 } |
OLD | NEW |