summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-01-22 12:06:32 -0800
committerTom Sepez <tsepez@chromium.org>2016-01-22 12:06:32 -0800
commit71fdc34b71760735aa0c14c820a1a10eb1e5829a (patch)
tree03424565134e2dd7adb29a23a15324600b764b57 /core/src
parent8139bc147f6936d490d2e47632213ec13251e925 (diff)
downloadpdfium-71fdc34b71760735aa0c14c820a1a10eb1e5829a.tar.xz
Merge to XFA: Change _PDF_RenderItem to CPDF_RenderContext::Layer.
Original Review URL: https://codereview.chromium.org/1620523002 . (cherry picked from commit d5712ac571f3487fe3f74617fdab007a11a09052) TBR=ochang@chromium.org Review URL: https://codereview.chromium.org/1624553004 .
Diffstat (limited to 'core/src')
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render.cpp88
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp7
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp8
-rw-r--r--core/src/fpdfapi/fpdf_render/render_int.h7
-rw-r--r--core/src/fpdfdoc/doc_annot.cpp5
-rw-r--r--core/src/fpdfdoc/doc_formcontrol.cpp3
6 files changed, 56 insertions, 62 deletions
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
index 5222d69fde..583b19f7ab 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
@@ -212,7 +212,7 @@ FX_BOOL CPDF_RenderStatus::Initialize(CPDF_RenderContext* pContext,
m_GroupFamily = GroupFamily;
m_bLoadMask = bLoadMask;
m_pFormResource = pFormResource;
- m_pPageResource = m_pContext->m_pPageResources;
+ m_pPageResource = m_pContext->GetPageResources();
if (pInitialStates && !m_pType3Char) {
m_InitialStates.CopyStates(*pInitialStates);
if (pParentState) {
@@ -538,7 +538,7 @@ FX_BOOL CPDF_RenderStatus::ProcessPath(CPDF_PathObject* pPathObj,
}
CPDF_TransferFunc* CPDF_RenderStatus::GetTransferFunc(CPDF_Object* pObj) const {
ASSERT(pObj);
- CPDF_DocRenderData* pDocCache = m_pContext->m_pDocument->GetRenderData();
+ CPDF_DocRenderData* pDocCache = m_pContext->GetDocument()->GetRenderData();
return pDocCache ? pDocCache->GetTransferFunc(pObj) : nullptr;
}
FX_ARGB CPDF_RenderStatus::GetFillArgb(const CPDF_PageObject* pObj,
@@ -758,8 +758,8 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj,
pGeneralState->m_FillOP && pGeneralState->m_StrokeOP) {
CPDF_Document* pDocument = NULL;
CPDF_Page* pPage = NULL;
- if (m_pContext->m_pPageCache) {
- pPage = m_pContext->m_pPageCache->GetPage();
+ if (m_pContext->GetPageCache()) {
+ pPage = m_pContext->GetPageCache()->GetPage();
pDocument = pPage->m_pDocument;
} else {
pDocument = ((CPDF_ImageObject*)pPageObj)->m_pImage->GetDocument();
@@ -956,26 +956,30 @@ CPDF_GraphicStates* CPDF_RenderStatus::CloneObjStates(
}
return pStates;
}
+
CPDF_RenderContext::CPDF_RenderContext(CPDF_Page* pPage)
: m_pDocument(pPage->m_pDocument),
m_pPageResources(pPage->m_pPageResources),
m_pPageCache(pPage->GetRenderCache()),
m_bFirstLayer(TRUE) {}
+
CPDF_RenderContext::CPDF_RenderContext(CPDF_Document* pDoc,
CPDF_PageRenderCache* pPageCache)
: m_pDocument(pDoc),
m_pPageResources(nullptr),
m_pPageCache(pPageCache),
m_bFirstLayer(TRUE) {}
+
CPDF_RenderContext::~CPDF_RenderContext() {}
-void CPDF_RenderContext::AppendObjectList(CPDF_PageObjectList* pObjs,
- const CFX_Matrix* pObject2Device) {
- _PDF_RenderItem* pItem = m_ContentList.AddSpace();
- pItem->m_pObjectList = pObjs;
+
+void CPDF_RenderContext::AppendLayer(CPDF_PageObjectList* pObjs,
+ const CFX_Matrix* pObject2Device) {
+ Layer* pLayer = m_Layers.AddSpace();
+ pLayer->m_pObjectList = pObjs;
if (pObject2Device) {
- pItem->m_Matrix = *pObject2Device;
+ pLayer->m_Matrix = *pObject2Device;
} else {
- pItem->m_Matrix.SetIdentity();
+ pLayer->m_Matrix.SetIdentity();
}
}
void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice,
@@ -987,18 +991,18 @@ void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice,
const CPDF_PageObject* pStopObj,
const CPDF_RenderOptions* pOptions,
const CFX_Matrix* pLastMatrix) {
- int count = m_ContentList.GetSize();
+ int count = m_Layers.GetSize();
for (int j = 0; j < count; j++) {
pDevice->SaveState();
- _PDF_RenderItem* pItem = m_ContentList.GetDataPtr(j);
+ Layer* pLayer = m_Layers.GetDataPtr(j);
if (pLastMatrix) {
- CFX_Matrix FinalMatrix = pItem->m_Matrix;
+ CFX_Matrix FinalMatrix = pLayer->m_Matrix;
FinalMatrix.Concat(*pLastMatrix);
CPDF_RenderStatus status;
status.Initialize(this, pDevice, pLastMatrix, pStopObj, NULL, NULL,
- pOptions, pItem->m_pObjectList->m_Transparency, FALSE,
+ pOptions, pLayer->m_pObjectList->m_Transparency, FALSE,
NULL);
- status.RenderObjectList(pItem->m_pObjectList, &FinalMatrix);
+ status.RenderObjectList(pLayer->m_pObjectList, &FinalMatrix);
if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) {
m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize);
}
@@ -1009,8 +1013,8 @@ void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice,
} else {
CPDF_RenderStatus status;
status.Initialize(this, pDevice, NULL, pStopObj, NULL, NULL, pOptions,
- pItem->m_pObjectList->m_Transparency, FALSE, NULL);
- status.RenderObjectList(pItem->m_pObjectList, &pItem->m_Matrix);
+ pLayer->m_pObjectList->m_Transparency, FALSE, NULL);
+ status.RenderObjectList(pLayer->m_pObjectList, &pLayer->m_Matrix);
if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) {
m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize);
}
@@ -1022,13 +1026,6 @@ void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice,
pDevice->RestoreState();
}
}
-void CPDF_RenderContext::DrawObjectList(CFX_RenderDevice* pDevice,
- CPDF_PageObjectList* pObjs,
- const CFX_Matrix* pObject2Device,
- const CPDF_RenderOptions* pOptions) {
- AppendObjectList(pObjs, pObject2Device);
- Render(pDevice, pOptions);
-}
CPDF_ProgressiveRenderer::CPDF_ProgressiveRenderer(
CPDF_RenderContext* pContext,
@@ -1058,23 +1055,22 @@ void CPDF_ProgressiveRenderer::Start(IFX_Pause* pPause) {
Continue(pPause);
}
-#define RENDER_STEP_LIMIT 100
void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) {
if (m_Status != ToBeContinued) {
return;
}
- FX_DWORD nLayers = m_pContext->m_ContentList.GetSize();
+ FX_DWORD nLayers = m_pContext->CountLayers();
for (; m_LayerIndex < nLayers; m_LayerIndex++) {
- _PDF_RenderItem* pItem = m_pContext->m_ContentList.GetDataPtr(m_LayerIndex);
- FX_POSITION LastPos = pItem->m_pObjectList->GetLastObjectPosition();
+ CPDF_RenderContext::Layer* pLayer = m_pContext->GetLayer(m_LayerIndex);
+ FX_POSITION LastPos = pLayer->m_pObjectList->GetLastObjectPosition();
if (!m_ObjectPos) {
if (LastPos == m_PrevLastPos) {
- if (!pItem->m_pObjectList->IsParsed()) {
- pItem->m_pObjectList->ContinueParse(pPause);
- if (!pItem->m_pObjectList->IsParsed()) {
+ if (!pLayer->m_pObjectList->IsParsed()) {
+ pLayer->m_pObjectList->ContinueParse(pPause);
+ if (!pLayer->m_pObjectList->IsParsed()) {
return;
}
- LastPos = pItem->m_pObjectList->GetLastObjectPosition();
+ LastPos = pLayer->m_pObjectList->GetLastObjectPosition();
}
}
if (LastPos == m_PrevLastPos) {
@@ -1088,23 +1084,23 @@ void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) {
}
if (m_PrevLastPos) {
m_ObjectPos = m_PrevLastPos;
- pItem->m_pObjectList->GetNextObject(m_ObjectPos);
+ pLayer->m_pObjectList->GetNextObject(m_ObjectPos);
} else {
- m_ObjectPos = pItem->m_pObjectList->GetFirstObjectPosition();
+ m_ObjectPos = pLayer->m_pObjectList->GetFirstObjectPosition();
}
m_PrevLastPos = LastPos;
}
if (!m_pRenderStatus) {
- m_ObjectPos = pItem->m_pObjectList->GetFirstObjectPosition();
+ m_ObjectPos = pLayer->m_pObjectList->GetFirstObjectPosition();
m_ObjectIndex = 0;
m_pRenderStatus.reset(new CPDF_RenderStatus());
m_pRenderStatus->Initialize(
m_pContext, m_pDevice, NULL, NULL, NULL, NULL, m_pOptions,
- pItem->m_pObjectList->m_Transparency, FALSE, NULL);
+ pLayer->m_pObjectList->m_Transparency, FALSE, NULL);
m_pDevice->SaveState();
m_ClipRect = m_pDevice->GetClipBox();
CFX_Matrix device2object;
- device2object.SetReverse(pItem->m_Matrix);
+ device2object.SetReverse(pLayer->m_Matrix);
device2object.TransformRect(m_ClipRect);
}
int objs_to_go = CPDF_ModuleMgr::Get()
@@ -1112,12 +1108,13 @@ void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) {
->GetConfig()
->m_RenderStepLimit;
while (m_ObjectPos) {
- CPDF_PageObject* pCurObj = pItem->m_pObjectList->GetObjectAt(m_ObjectPos);
+ CPDF_PageObject* pCurObj =
+ pLayer->m_pObjectList->GetObjectAt(m_ObjectPos);
if (pCurObj && pCurObj->m_Left <= m_ClipRect.right &&
pCurObj->m_Right >= m_ClipRect.left &&
pCurObj->m_Bottom <= m_ClipRect.top &&
pCurObj->m_Top >= m_ClipRect.bottom) {
- if (m_pRenderStatus->ContinueSingleObject(pCurObj, &pItem->m_Matrix,
+ if (m_pRenderStatus->ContinueSingleObject(pCurObj, &pLayer->m_Matrix,
pPause)) {
return;
}
@@ -1134,7 +1131,7 @@ void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) {
}
}
m_ObjectIndex++;
- pItem->m_pObjectList->GetNextObject(m_ObjectPos);
+ pLayer->m_pObjectList->GetNextObject(m_ObjectPos);
if (objs_to_go == 0) {
if (pPause && pPause->NeedToPauseNow()) {
return;
@@ -1145,7 +1142,7 @@ void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) {
->m_RenderStepLimit;
}
}
- if (!pItem->m_pObjectList->IsParsed()) {
+ if (!pLayer->m_pObjectList->IsParsed()) {
return;
}
m_pRenderStatus.reset();
@@ -1163,11 +1160,12 @@ int CPDF_ProgressiveRenderer::EstimateProgress() {
if (!m_pContext) {
return 0;
}
- FX_DWORD nLayers = m_pContext->m_ContentList.GetSize();
- int nTotal = 0, nRendered = 0;
+ FX_DWORD nLayers = m_pContext->CountLayers();
+ int nTotal = 0;
+ int nRendered = 0;
for (FX_DWORD layer = 0; layer < nLayers; layer++) {
- _PDF_RenderItem* pItem = m_pContext->m_ContentList.GetDataPtr(layer);
- int nObjs = pItem->m_pObjectList->CountObjects();
+ CPDF_RenderContext::Layer* pLayer = m_pContext->GetLayer(layer);
+ int nObjs = pLayer->m_pObjectList->CountObjects();
if (layer == m_LayerIndex) {
nRendered += m_ObjectIndex;
} else if (layer < m_LayerIndex) {
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp
index 3f7347b8f1..a0b3059e5b 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp
@@ -883,7 +883,8 @@ CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict,
CFX_Matrix matrix = *pMatrix;
matrix.TranslateI(-pClipRect->left, -pClipRect->top);
- CPDF_Form form(m_pContext->m_pDocument, m_pContext->m_pPageResources, pGroup);
+ CPDF_Form form(m_pContext->GetDocument(), m_pContext->GetPageResources(),
+ pGroup);
form.ParseContent(NULL, NULL, NULL, NULL);
CFX_FxgeDevice bitmap_device;
#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
@@ -909,7 +910,7 @@ CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict,
pCSObj = pDict->GetDict("Group")->GetElementValue("CS");
else
pCSObj = NULL;
- pCS = m_pContext->m_pDocument->LoadColorSpace(pCSObj);
+ pCS = m_pContext->GetDocument()->LoadColorSpace(pCSObj);
if (pCS) {
FX_FLOAT R, G, B;
FX_DWORD comps = 8;
@@ -931,7 +932,7 @@ CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict,
pCS->GetRGB(pFloats, R, G, B);
back_color = 0xff000000 | ((int32_t)(R * 255) << 16) |
((int32_t)(G * 255) << 8) | (int32_t)(B * 255);
- m_pContext->m_pDocument->GetPageData()->ReleaseColorSpace(pCSObj);
+ m_pContext->GetDocument()->GetPageData()->ReleaseColorSpace(pCSObj);
}
}
bitmap.Clear(back_color);
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
index 8cee178369..c1bb6f6813 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
@@ -989,8 +989,8 @@ static CFX_DIBitmap* DrawPatternBitmap(CPDF_Document* pDoc,
flags |= RENDER_FORCE_HALFTONE;
options.m_Flags = flags;
CPDF_RenderContext context(pDoc, pCache);
- context.DrawObjectList(&bitmap_device, pPattern->m_pForm, &mtPattern2Bitmap,
- &options);
+ context.AppendLayer(pPattern->m_pForm, &mtPattern2Bitmap);
+ context.Render(&bitmap_device, &options, nullptr);
return pBitmap;
}
void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
@@ -1111,13 +1111,13 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
CFX_DIBitmap* pPatternBitmap = NULL;
if (width * height < 16) {
CFX_DIBitmap* pEnlargedBitmap =
- DrawPatternBitmap(m_pContext->m_pDocument, m_pContext->m_pPageCache,
+ DrawPatternBitmap(m_pContext->GetDocument(), m_pContext->GetPageCache(),
pPattern, pObj2Device, 8, 8, m_Options.m_Flags);
pPatternBitmap = pEnlargedBitmap->StretchTo(width, height);
delete pEnlargedBitmap;
} else {
pPatternBitmap = DrawPatternBitmap(
- m_pContext->m_pDocument, m_pContext->m_pPageCache, pPattern,
+ m_pContext->GetDocument(), m_pContext->GetPageCache(), pPattern,
pObj2Device, width, height, m_Options.m_Flags);
}
if (!pPatternBitmap) {
diff --git a/core/src/fpdfapi/fpdf_render/render_int.h b/core/src/fpdfapi/fpdf_render/render_int.h
index 3a81ba5587..d5018adfa7 100644
--- a/core/src/fpdfapi/fpdf_render/render_int.h
+++ b/core/src/fpdfapi/fpdf_render/render_int.h
@@ -91,13 +91,6 @@ class CPDF_DocRenderData {
CPDF_Type3CacheMap m_Type3FaceMap;
CPDF_TransferFuncMap m_TransferFuncMap;
};
-struct _PDF_RenderItem {
- public:
- CPDF_PageObjectList* m_pObjectList;
- CFX_Matrix m_Matrix;
-};
-
-typedef CFX_ArrayTemplate<_PDF_RenderItem> CPDF_RenderLayer;
class IPDF_ObjectRenderer {
public:
diff --git a/core/src/fpdfdoc/doc_annot.cpp b/core/src/fpdfdoc/doc_annot.cpp
index 814496ff7f..5786349490 100644
--- a/core/src/fpdfdoc/doc_annot.cpp
+++ b/core/src/fpdfdoc/doc_annot.cpp
@@ -227,7 +227,8 @@ FX_BOOL CPDF_Annot::DrawAppearance(CPDF_Page* pPage,
return FALSE;
}
CPDF_RenderContext context(pPage);
- context.DrawObjectList(pDevice, pForm, &matrix, pOptions);
+ context.AppendLayer(pForm, &matrix);
+ context.Render(pDevice, pOptions, nullptr);
return TRUE;
}
FX_BOOL CPDF_Annot::DrawInContext(const CPDF_Page* pPage,
@@ -240,7 +241,7 @@ FX_BOOL CPDF_Annot::DrawInContext(const CPDF_Page* pPage,
if (!pForm) {
return FALSE;
}
- pContext->AppendObjectList(pForm, &matrix);
+ pContext->AppendLayer(pForm, &matrix);
return TRUE;
}
void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice,
diff --git a/core/src/fpdfdoc/doc_formcontrol.cpp b/core/src/fpdfdoc/doc_formcontrol.cpp
index bf37d85195..1ec98bb986 100644
--- a/core/src/fpdfdoc/doc_formcontrol.cpp
+++ b/core/src/fpdfdoc/doc_formcontrol.cpp
@@ -170,7 +170,8 @@ void CPDF_FormControl::DrawControl(CFX_RenderDevice* pDevice,
m_pField->m_pForm->m_pFormDict->GetDict("DR"), pStream);
form.ParseContent(NULL, NULL, NULL, NULL);
CPDF_RenderContext context(pPage);
- context.DrawObjectList(pDevice, &form, &matrix, pOptions);
+ context.AppendLayer(&form, &matrix);
+ context.Render(pDevice, pOptions, nullptr);
}
static const FX_CHAR* const g_sHighlightingMode[] = {
// Must match order of HiglightingMode enum.