| 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 "../../../include/fpdfapi/fpdf_module.h" | 7 #include "../../../include/fpdfapi/fpdf_module.h" |
| 8 #include "../../../include/fpdfapi/fpdf_render.h" | 8 #include "../../../include/fpdfapi/fpdf_render.h" |
| 9 #include "../../../include/fxge/fx_ge.h" | 9 #include "../../../include/fxge/fx_ge.h" |
| 10 #include "../fpdf_page/pageint.h" | 10 #include "../fpdf_page/pageint.h" |
| (...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 } | 1006 } |
| 1007 pDevice->RestoreState(); | 1007 pDevice->RestoreState(); |
| 1008 } | 1008 } |
| 1009 } | 1009 } |
| 1010 void CPDF_RenderContext::DrawObjectList(CFX_RenderDevice* pDevice, CPDF_PageObje
cts* pObjs, | 1010 void CPDF_RenderContext::DrawObjectList(CFX_RenderDevice* pDevice, CPDF_PageObje
cts* pObjs, |
| 1011 const CFX_AffineMatrix* pObject2Device,
const CPDF_RenderOptions* pOptions) | 1011 const CFX_AffineMatrix* pObject2Device,
const CPDF_RenderOptions* pOptions) |
| 1012 { | 1012 { |
| 1013 AppendObjectList(pObjs, pObject2Device); | 1013 AppendObjectList(pObjs, pObject2Device); |
| 1014 Render(pDevice, pOptions); | 1014 Render(pDevice, pOptions); |
| 1015 } | 1015 } |
| 1016 CPDF_ProgressiveRenderer::CPDF_ProgressiveRenderer() | 1016 |
| 1017 CPDF_ProgressiveRenderer::CPDF_ProgressiveRenderer( |
| 1018 CPDF_RenderContext* pContext, |
| 1019 CFX_RenderDevice* pDevice, |
| 1020 const CPDF_RenderOptions* pOptions) : |
| 1021 m_Status(Ready), |
| 1022 m_pContext(pContext), |
| 1023 m_pDevice(pDevice), |
| 1024 m_pOptions(pOptions), |
| 1025 m_LayerIndex(0), |
| 1026 m_ObjectIndex(0), |
| 1027 m_ObjectPos(nullptr), |
| 1028 m_PrevLastPos(nullptr) |
| 1017 { | 1029 { |
| 1018 m_pRenderer = NULL; | |
| 1019 m_pContext = NULL; | |
| 1020 m_pDevice = NULL; | |
| 1021 m_Status = Ready; | |
| 1022 } | 1030 } |
| 1031 |
| 1023 CPDF_ProgressiveRenderer::~CPDF_ProgressiveRenderer() | 1032 CPDF_ProgressiveRenderer::~CPDF_ProgressiveRenderer() |
| 1024 { | 1033 { |
| 1025 Clear(); | 1034 if (m_pRenderStatus) |
| 1035 m_pDevice->RestoreState(); |
| 1026 } | 1036 } |
| 1027 void CPDF_ProgressiveRenderer::Clear() | 1037 |
| 1038 void CPDF_ProgressiveRenderer::Start(IFX_Pause* pPause) |
| 1028 { | 1039 { |
| 1029 if (m_pRenderer) { | 1040 if (!m_pContext || !m_pDevice || m_Status != Ready) { |
| 1030 delete m_pRenderer; | |
| 1031 m_pDevice->RestoreState(); | |
| 1032 m_pRenderer = NULL; | |
| 1033 } | |
| 1034 m_Status = Ready; | |
| 1035 } | |
| 1036 void CPDF_ProgressiveRenderer::Start(CPDF_RenderContext* pContext, CFX_RenderDev
ice* pDevice, | |
| 1037 const CPDF_RenderOptions* pOptions, IFX_Pau
se* pPause, FX_BOOL bDropObjects) | |
| 1038 { | |
| 1039 if (m_Status != Ready) { | |
| 1040 m_Status = Failed; | |
| 1041 return; | |
| 1042 } | |
| 1043 m_pContext = pContext; | |
| 1044 m_pDevice = pDevice; | |
| 1045 m_pOptions = pOptions; | |
| 1046 m_bDropObjects = bDropObjects; | |
| 1047 if (pContext == NULL || pDevice == NULL) { | |
| 1048 m_Status = Failed; | 1041 m_Status = Failed; |
| 1049 return; | 1042 return; |
| 1050 } | 1043 } |
| 1051 m_Status = ToBeContinued; | 1044 m_Status = ToBeContinued; |
| 1052 m_ObjectPos = NULL; | |
| 1053 m_LayerIndex = 0; | |
| 1054 m_ObjectIndex = 0; | |
| 1055 m_PrevLastPos = NULL; | |
| 1056 Continue(pPause); | 1045 Continue(pPause); |
| 1057 } | 1046 } |
| 1047 |
| 1058 #define RENDER_STEP_LIMIT 100 | 1048 #define RENDER_STEP_LIMIT 100 |
| 1059 void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) | 1049 void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) |
| 1060 { | 1050 { |
| 1061 if (m_Status != ToBeContinued) { | 1051 if (m_Status != ToBeContinued) { |
| 1062 return; | 1052 return; |
| 1063 } | 1053 } |
| 1064 FX_DWORD nLayers = m_pContext->m_ContentList.GetSize(); | 1054 FX_DWORD nLayers = m_pContext->m_ContentList.GetSize(); |
| 1065 for (; m_LayerIndex < nLayers; m_LayerIndex ++) { | 1055 for (; m_LayerIndex < nLayers; m_LayerIndex ++) { |
| 1066 _PDF_RenderItem* pItem = m_pContext->m_ContentList.GetDataPtr(m_LayerInd
ex); | 1056 _PDF_RenderItem* pItem = m_pContext->m_ContentList.GetDataPtr(m_LayerInd
ex); |
| 1067 FX_POSITION LastPos = pItem->m_pObjectList->GetLastObjectPosition(); | 1057 FX_POSITION LastPos = pItem->m_pObjectList->GetLastObjectPosition(); |
| 1068 if (m_ObjectPos == NULL) { | 1058 if (m_ObjectPos == NULL) { |
| 1069 if (LastPos == m_PrevLastPos) { | 1059 if (LastPos == m_PrevLastPos) { |
| 1070 if (!pItem->m_pObjectList->IsParsed()) { | 1060 if (!pItem->m_pObjectList->IsParsed()) { |
| 1071 pItem->m_pObjectList->ContinueParse(pPause); | 1061 pItem->m_pObjectList->ContinueParse(pPause); |
| 1072 if (!pItem->m_pObjectList->IsParsed()) { | 1062 if (!pItem->m_pObjectList->IsParsed()) { |
| 1073 return; | 1063 return; |
| 1074 } | 1064 } |
| 1075 LastPos = pItem->m_pObjectList->GetLastObjectPosition(); | 1065 LastPos = pItem->m_pObjectList->GetLastObjectPosition(); |
| 1076 } | 1066 } |
| 1077 } | 1067 } |
| 1078 if (LastPos == m_PrevLastPos) { | 1068 if (LastPos == m_PrevLastPos) { |
| 1079 if (m_pRenderer) { | 1069 if (m_pRenderStatus) { |
| 1080 delete m_pRenderer; | 1070 m_pRenderStatus.reset(); |
| 1081 m_pRenderer = NULL; | |
| 1082 m_pDevice->RestoreState(); | 1071 m_pDevice->RestoreState(); |
| 1083 m_ObjectPos = NULL; | 1072 m_ObjectPos = NULL; |
| 1084 m_PrevLastPos = NULL; | 1073 m_PrevLastPos = NULL; |
| 1085 } | 1074 } |
| 1086 continue; | 1075 continue; |
| 1087 } | 1076 } |
| 1088 if (m_PrevLastPos) { | 1077 if (m_PrevLastPos) { |
| 1089 m_ObjectPos = m_PrevLastPos; | 1078 m_ObjectPos = m_PrevLastPos; |
| 1090 pItem->m_pObjectList->GetNextObject(m_ObjectPos); | 1079 pItem->m_pObjectList->GetNextObject(m_ObjectPos); |
| 1091 } else { | 1080 } else { |
| 1092 m_ObjectPos = pItem->m_pObjectList->GetFirstObjectPosition(); | 1081 m_ObjectPos = pItem->m_pObjectList->GetFirstObjectPosition(); |
| 1093 } | 1082 } |
| 1094 m_PrevLastPos = LastPos; | 1083 m_PrevLastPos = LastPos; |
| 1095 } | 1084 } |
| 1096 if (m_pRenderer == NULL) { | 1085 if (!m_pRenderStatus) { |
| 1097 m_ObjectPos = pItem->m_pObjectList->GetFirstObjectPosition(); | 1086 m_ObjectPos = pItem->m_pObjectList->GetFirstObjectPosition(); |
| 1098 m_ObjectIndex = 0; | 1087 m_ObjectIndex = 0; |
| 1099 m_pRenderer = new CPDF_RenderStatus(); | 1088 m_pRenderStatus.reset(new CPDF_RenderStatus()); |
| 1100 m_pRenderer->Initialize(m_pContext, m_pDevice, NULL, NULL, NULL, NUL
L, | 1089 m_pRenderStatus->Initialize( |
| 1101 m_pOptions, pItem->m_pObjectList->m_Transpar
ency, m_bDropObjects, NULL); | 1090 m_pContext, m_pDevice, NULL, NULL, NULL, NULL, m_pOptions, |
| 1091 pItem->m_pObjectList->m_Transparency, FALSE, NULL); |
| 1102 m_pDevice->SaveState(); | 1092 m_pDevice->SaveState(); |
| 1103 m_ClipRect = m_pDevice->GetClipBox(); | 1093 m_ClipRect = m_pDevice->GetClipBox(); |
| 1104 CFX_AffineMatrix device2object; | 1094 CFX_AffineMatrix device2object; |
| 1105 device2object.SetReverse(pItem->m_Matrix); | 1095 device2object.SetReverse(pItem->m_Matrix); |
| 1106 device2object.TransformRect(m_ClipRect); | 1096 device2object.TransformRect(m_ClipRect); |
| 1107 } | 1097 } |
| 1108 int objs_to_go = CPDF_ModuleMgr::Get()->GetRenderModule()->GetConfig()->
m_RenderStepLimit; | 1098 int objs_to_go = CPDF_ModuleMgr::Get()->GetRenderModule()->GetConfig()->
m_RenderStepLimit; |
| 1109 while (m_ObjectPos) { | 1099 while (m_ObjectPos) { |
| 1110 CPDF_PageObject* pCurObj = pItem->m_pObjectList->GetObjectAt(m_Objec
tPos); | 1100 CPDF_PageObject* pCurObj = pItem->m_pObjectList->GetObjectAt(m_Objec
tPos); |
| 1111 if (pCurObj && pCurObj->m_Left <= m_ClipRect.right && pCurObj->m_Rig
ht >= m_ClipRect.left && | 1101 if (pCurObj && pCurObj->m_Left <= m_ClipRect.right && pCurObj->m_Rig
ht >= m_ClipRect.left && |
| 1112 pCurObj->m_Bottom <= m_ClipRect.top && pCurObj->m_Top >= m_C
lipRect.bottom) { | 1102 pCurObj->m_Bottom <= m_ClipRect.top && pCurObj->m_Top >= m_C
lipRect.bottom) { |
| 1113 if (m_pRenderer->ContinueSingleObject(pCurObj, &pItem->m_Matrix,
pPause)) { | 1103 if (m_pRenderStatus->ContinueSingleObject(pCurObj, &pItem->m_Mat
rix, pPause)) { |
| 1114 return; | 1104 return; |
| 1115 } | 1105 } |
| 1116 if (pCurObj->m_Type == PDFPAGE_IMAGE && m_pRenderer->m_Options.m
_Flags & RENDER_LIMITEDIMAGECACHE) { | 1106 if (pCurObj->m_Type == PDFPAGE_IMAGE && m_pRenderStatus->m_Optio
ns.m_Flags & RENDER_LIMITEDIMAGECACHE) { |
| 1117 m_pContext->GetPageCache()->CacheOptimization(m_pRenderer->m
_Options.m_dwLimitCacheSize); | 1107 m_pContext->GetPageCache()->CacheOptimization(m_pRenderStatu
s->m_Options.m_dwLimitCacheSize); |
| 1118 } | 1108 } |
| 1119 if (pCurObj->m_Type == PDFPAGE_FORM || pCurObj->m_Type == PDFPAG
E_SHADING) { | 1109 if (pCurObj->m_Type == PDFPAGE_FORM || pCurObj->m_Type == PDFPAG
E_SHADING) { |
| 1120 objs_to_go = 0; | 1110 objs_to_go = 0; |
| 1121 } else { | 1111 } else { |
| 1122 objs_to_go --; | 1112 objs_to_go --; |
| 1123 } | 1113 } |
| 1124 } | 1114 } |
| 1125 m_ObjectIndex ++; | 1115 m_ObjectIndex ++; |
| 1126 pItem->m_pObjectList->GetNextObject(m_ObjectPos); | 1116 pItem->m_pObjectList->GetNextObject(m_ObjectPos); |
| 1127 if (objs_to_go == 0) { | 1117 if (objs_to_go == 0) { |
| 1128 if (pPause && pPause->NeedToPauseNow()) { | 1118 if (pPause && pPause->NeedToPauseNow()) { |
| 1129 return; | 1119 return; |
| 1130 } | 1120 } |
| 1131 objs_to_go = CPDF_ModuleMgr::Get()->GetRenderModule()->GetConfig
()->m_RenderStepLimit; | 1121 objs_to_go = CPDF_ModuleMgr::Get()->GetRenderModule()->GetConfig
()->m_RenderStepLimit; |
| 1132 } | 1122 } |
| 1133 } | 1123 } |
| 1134 if (!pItem->m_pObjectList->IsParsed()) { | 1124 if (!pItem->m_pObjectList->IsParsed()) { |
| 1135 return; | 1125 return; |
| 1136 } | 1126 } |
| 1137 delete m_pRenderer; | 1127 m_pRenderStatus.reset(); |
| 1138 m_pRenderer = NULL; | |
| 1139 m_pDevice->RestoreState(); | 1128 m_pDevice->RestoreState(); |
| 1140 m_ObjectPos = NULL; | 1129 m_ObjectPos = NULL; |
| 1141 m_PrevLastPos = NULL; | 1130 m_PrevLastPos = NULL; |
| 1142 if (pPause && pPause->NeedToPauseNow()) { | 1131 if (pPause && pPause->NeedToPauseNow()) { |
| 1143 m_LayerIndex++; | 1132 m_LayerIndex++; |
| 1144 return; | 1133 return; |
| 1145 } | 1134 } |
| 1146 } | 1135 } |
| 1147 m_Status = Done; | 1136 m_Status = Done; |
| 1148 } | 1137 } |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1391 CPDF_ContentMarkItem& item = pData->GetItem(i); | 1380 CPDF_ContentMarkItem& item = pData->GetItem(i); |
| 1392 if (item.GetName() == FX_BSTRC("OC") && item.GetParamType() == CPDF_Cont
entMarkItem::PropertiesDict) { | 1381 if (item.GetName() == FX_BSTRC("OC") && item.GetParamType() == CPDF_Cont
entMarkItem::PropertiesDict) { |
| 1393 CPDF_Dictionary* pOCG = (CPDF_Dictionary*)item.GetParam(); | 1382 CPDF_Dictionary* pOCG = (CPDF_Dictionary*)item.GetParam(); |
| 1394 if (!CheckOCGVisible(pOCG)) { | 1383 if (!CheckOCGVisible(pOCG)) { |
| 1395 return FALSE; | 1384 return FALSE; |
| 1396 } | 1385 } |
| 1397 } | 1386 } |
| 1398 } | 1387 } |
| 1399 return TRUE; | 1388 return TRUE; |
| 1400 } | 1389 } |
| OLD | NEW |