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