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_LastObjectRendered(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 IPDF_RenderModule* pModule = CPDF_ModuleMgr::Get()->GetRenderModule(); |
1062 return; | 1061 int nStepLimit = pModule->GetConfig()->m_RenderStepLimit; |
1063 } | 1062 while (m_Status == ToBeContinued) { |
1064 FX_DWORD nLayers = m_pContext->CountLayers(); | 1063 if (!m_pCurrentLayer) { |
1065 for (; m_LayerIndex < nLayers; m_LayerIndex++) { | 1064 if (m_LayerIndex >= m_pContext->CountLayers()) { |
1066 CPDF_RenderContext::Layer* pLayer = m_pContext->GetLayer(m_LayerIndex); | 1065 m_Status = Done; |
1067 FX_POSITION LastPos = pLayer->m_pObjectList->GetLastObjectPosition(); | 1066 return; |
1068 if (!m_ObjectPos) { | |
1069 if (LastPos == m_PrevLastPos) { | |
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 } | 1067 } |
1078 if (LastPos == m_PrevLastPos) { | 1068 m_pCurrentLayer = m_pContext->GetLayer(m_LayerIndex); |
1079 if (m_pRenderStatus) { | 1069 m_LastObjectRendered = nullptr; |
1080 m_pRenderStatus.reset(); | |
1081 m_pDevice->RestoreState(); | |
1082 m_ObjectPos = NULL; | |
1083 m_PrevLastPos = NULL; | |
1084 } | |
1085 continue; | |
1086 } | |
1087 if (m_PrevLastPos) { | |
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(); | |
1097 m_ObjectIndex = 0; | 1070 m_ObjectIndex = 0; |
1098 m_pRenderStatus.reset(new CPDF_RenderStatus()); | 1071 m_pRenderStatus.reset(new CPDF_RenderStatus()); |
1099 m_pRenderStatus->Initialize( | 1072 m_pRenderStatus->Initialize( |
1100 m_pContext, m_pDevice, NULL, NULL, NULL, NULL, m_pOptions, | 1073 m_pContext, m_pDevice, NULL, NULL, NULL, NULL, m_pOptions, |
1101 pLayer->m_pObjectList->m_Transparency, FALSE, NULL); | 1074 m_pCurrentLayer->m_pObjectList->m_Transparency, FALSE, NULL); |
1102 m_pDevice->SaveState(); | 1075 m_pDevice->SaveState(); |
1103 m_ClipRect = m_pDevice->GetClipBox(); | 1076 m_ClipRect = m_pDevice->GetClipBox(); |
1104 CFX_Matrix device2object; | 1077 CFX_Matrix device2object; |
1105 device2object.SetReverse(pLayer->m_Matrix); | 1078 device2object.SetReverse(m_pCurrentLayer->m_Matrix); |
1106 device2object.TransformRect(m_ClipRect); | 1079 device2object.TransformRect(m_ClipRect); |
1107 } | 1080 } |
1108 int objs_to_go = CPDF_ModuleMgr::Get() | 1081 FX_POSITION pos; |
1109 ->GetRenderModule() | 1082 if (m_LastObjectRendered) { |
1110 ->GetConfig() | 1083 pos = m_LastObjectRendered; |
1111 ->m_RenderStepLimit; | 1084 m_pCurrentLayer->m_pObjectList->GetNextObject(pos); |
1112 while (m_ObjectPos) { | 1085 } else { |
1086 pos = m_pCurrentLayer->m_pObjectList->GetFirstObjectPosition(); | |
1087 } | |
1088 int nObjsToGo = nStepLimit; | |
1089 while (pos) { | |
1113 CPDF_PageObject* pCurObj = | 1090 CPDF_PageObject* pCurObj = |
1114 pLayer->m_pObjectList->GetObjectAt(m_ObjectPos); | 1091 m_pCurrentLayer->m_pObjectList->GetObjectAt(pos); |
1115 if (pCurObj && pCurObj->m_Left <= m_ClipRect.right && | 1092 if (pCurObj && pCurObj->m_Left <= m_ClipRect.right && |
1116 pCurObj->m_Right >= m_ClipRect.left && | 1093 pCurObj->m_Right >= m_ClipRect.left && |
1117 pCurObj->m_Bottom <= m_ClipRect.top && | 1094 pCurObj->m_Bottom <= m_ClipRect.top && |
1118 pCurObj->m_Top >= m_ClipRect.bottom) { | 1095 pCurObj->m_Top >= m_ClipRect.bottom) { |
1119 if (m_pRenderStatus->ContinueSingleObject(pCurObj, &pLayer->m_Matrix, | 1096 if (m_pRenderStatus->ContinueSingleObject( |
1120 pPause)) { | 1097 pCurObj, &m_pCurrentLayer->m_Matrix, pPause)) { |
1121 return; | 1098 return; |
1122 } | 1099 } |
1123 if (pCurObj->m_Type == CPDF_PageObject::IMAGE && | 1100 if (pCurObj->m_Type == CPDF_PageObject::IMAGE && |
1124 m_pRenderStatus->m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { | 1101 m_pRenderStatus->m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { |
1125 m_pContext->GetPageCache()->CacheOptimization( | 1102 m_pContext->GetPageCache()->CacheOptimization( |
1126 m_pRenderStatus->m_Options.m_dwLimitCacheSize); | 1103 m_pRenderStatus->m_Options.m_dwLimitCacheSize); |
1127 } | 1104 } |
1128 if (pCurObj->m_Type == CPDF_PageObject::FORM || | 1105 if (pCurObj->m_Type == CPDF_PageObject::FORM || |
1129 pCurObj->m_Type == CPDF_PageObject::SHADING) { | 1106 pCurObj->m_Type == CPDF_PageObject::SHADING) { |
1130 objs_to_go = 0; | 1107 nObjsToGo = 0; |
1131 } else { | 1108 } else { |
1132 objs_to_go--; | 1109 --nObjsToGo; |
1133 } | 1110 } |
1134 } | 1111 } |
1135 m_ObjectIndex++; | 1112 m_ObjectIndex++; |
1136 pLayer->m_pObjectList->GetNextObject(m_ObjectPos); | 1113 m_LastObjectRendered = pos; |
1137 if (objs_to_go == 0) { | 1114 if (nObjsToGo == 0) { |
1138 if (pPause && pPause->NeedToPauseNow()) { | 1115 if (pPause && pPause->NeedToPauseNow()) |
1139 return; | 1116 return; |
1140 } | 1117 nObjsToGo = nStepLimit; |
1141 objs_to_go = CPDF_ModuleMgr::Get() | |
1142 ->GetRenderModule() | |
1143 ->GetConfig() | |
1144 ->m_RenderStepLimit; | |
1145 } | 1118 } |
1119 m_pCurrentLayer->m_pObjectList->GetNextObject(pos); | |
1146 } | 1120 } |
1147 if (!pLayer->m_pObjectList->IsParsed()) { | 1121 if (m_pCurrentLayer->m_pObjectList->IsParsed()) { |
1148 return; | 1122 m_pRenderStatus.reset(); |
1149 } | 1123 m_pDevice->RestoreState(); |
1150 m_pRenderStatus.reset(); | 1124 m_pCurrentLayer = nullptr; |
1151 m_pDevice->RestoreState(); | 1125 m_LastObjectRendered = nullptr; |
1152 m_ObjectPos = NULL; | |
1153 m_PrevLastPos = NULL; | |
1154 if (pPause && pPause->NeedToPauseNow()) { | |
1155 m_LayerIndex++; | 1126 m_LayerIndex++; |
1156 return; | 1127 if (pPause && pPause->NeedToPauseNow()) { |
1128 return; | |
1129 } | |
1130 } else { | |
1131 m_pCurrentLayer->m_pObjectList->ContinueParse(pPause); | |
1132 if (!m_pCurrentLayer->m_pObjectList->IsParsed()) | |
1133 return; | |
1157 } | 1134 } |
1158 } | 1135 } |
1159 m_Status = Done; | |
1160 } | 1136 } |
1137 | |
1161 int CPDF_ProgressiveRenderer::EstimateProgress() { | 1138 int CPDF_ProgressiveRenderer::EstimateProgress() { |
1162 if (!m_pContext) { | 1139 if (!m_pContext) { |
1163 return 0; | 1140 return 0; |
1164 } | 1141 } |
1165 FX_DWORD nLayers = m_pContext->CountLayers(); | 1142 FX_DWORD nLayers = m_pContext->CountLayers(); |
1166 int nTotal = 0; | 1143 int nTotal = 0; |
1167 int nRendered = 0; | 1144 int nRendered = 0; |
1168 for (FX_DWORD layer = 0; layer < nLayers; layer++) { | 1145 for (FX_DWORD layer = 0; layer < nLayers; layer++) { |
1169 CPDF_RenderContext::Layer* pLayer = m_pContext->GetLayer(layer); | 1146 CPDF_RenderContext::Layer* pLayer = m_pContext->GetLayer(layer); |
1170 int nObjs = pLayer->m_pObjectList->CountObjects(); | 1147 int nObjs = pLayer->m_pObjectList->CountObjects(); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1245 | 1222 |
1246 pTransfer->m_bIdentity = bIdentity; | 1223 pTransfer->m_bIdentity = bIdentity; |
1247 return pTransferCounter->AddRef(); | 1224 return pTransferCounter->AddRef(); |
1248 } | 1225 } |
1249 | 1226 |
1250 void CPDF_DocRenderData::ReleaseTransferFunc(CPDF_Object* pObj) { | 1227 void CPDF_DocRenderData::ReleaseTransferFunc(CPDF_Object* pObj) { |
1251 auto it = m_TransferFuncMap.find(pObj); | 1228 auto it = m_TransferFuncMap.find(pObj); |
1252 if (it != m_TransferFuncMap.end()) | 1229 if (it != m_TransferFuncMap.end()) |
1253 it->second->RemoveRef(); | 1230 it->second->RemoveRef(); |
1254 } | 1231 } |
1255 CPDF_RenderConfig::CPDF_RenderConfig() { | 1232 CPDF_RenderConfig::CPDF_RenderConfig() { |
Lei Zhang
2016/02/13 01:08:12
Can we kill this class and make the two limits con
| |
1256 m_HalftoneLimit = 0; | 1233 m_HalftoneLimit = 0; |
1257 m_RenderStepLimit = 100; | 1234 m_RenderStepLimit = 100; |
1258 } | 1235 } |
1259 CPDF_RenderConfig::~CPDF_RenderConfig() {} | 1236 CPDF_RenderConfig::~CPDF_RenderConfig() {} |
1260 | 1237 |
1261 CPDF_DeviceBuffer::CPDF_DeviceBuffer() | 1238 CPDF_DeviceBuffer::CPDF_DeviceBuffer() |
1262 : m_pDevice(nullptr), m_pContext(nullptr), m_pObject(nullptr) {} | 1239 : m_pDevice(nullptr), m_pContext(nullptr), m_pObject(nullptr) {} |
1263 | 1240 |
1264 CPDF_DeviceBuffer::~CPDF_DeviceBuffer() { | 1241 CPDF_DeviceBuffer::~CPDF_DeviceBuffer() { |
1265 } | 1242 } |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1398 item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict) { | 1375 item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict) { |
1399 CPDF_Dictionary* pOCG = | 1376 CPDF_Dictionary* pOCG = |
1400 ToDictionary(static_cast<CPDF_Object*>(item.GetParam())); | 1377 ToDictionary(static_cast<CPDF_Object*>(item.GetParam())); |
1401 if (!CheckOCGVisible(pOCG)) { | 1378 if (!CheckOCGVisible(pOCG)) { |
1402 return FALSE; | 1379 return FALSE; |
1403 } | 1380 } |
1404 } | 1381 } |
1405 } | 1382 } |
1406 return TRUE; | 1383 return TRUE; |
1407 } | 1384 } |
OLD | NEW |