summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'core/src')
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render.cpp34
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp4
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp6
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp3
-rw-r--r--core/src/fpdfdoc/doc_annot.cpp13
-rw-r--r--core/src/fpdfdoc/doc_formcontrol.cpp16
6 files changed, 30 insertions, 46 deletions
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
index bee188e049..1c46583e59 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
@@ -956,30 +956,18 @@ CPDF_GraphicStates* CPDF_RenderStatus::CloneObjStates(
}
return pStates;
}
-CPDF_RenderContext::CPDF_RenderContext() {}
-void CPDF_RenderContext::Create(CPDF_Document* pDoc,
- CPDF_PageRenderCache* pPageCache,
- CPDF_Dictionary* pPageResources,
- FX_BOOL bFirstLayer) {
- m_pDocument = pDoc;
- m_pPageResources = pPageResources;
- m_pPageCache = pPageCache;
- m_bFirstLayer = bFirstLayer;
-}
-void CPDF_RenderContext::Create(CPDF_Page* pPage, FX_BOOL bFirstLayer) {
- m_pDocument = pPage->m_pDocument;
- m_pPageResources = pPage->m_pPageResources;
- m_pPageCache = pPage->GetRenderCache();
- m_bFirstLayer = bFirstLayer;
-}
+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::Clear() {
- m_pDocument = NULL;
- m_pPageResources = NULL;
- m_pPageCache = NULL;
- m_bFirstLayer = TRUE;
- m_ContentList.RemoveAll();
-}
void CPDF_RenderContext::AppendObjectList(CPDF_PageObjects* pObjs,
const CFX_Matrix* pObject2Device) {
_PDF_RenderItem* pItem = m_ContentList.AddSpace();
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp
index babf70396b..8d0568e719 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp
@@ -250,7 +250,7 @@ FX_BOOL CPDF_ImageCache::GetCachedBitmap(CFX_DIBSource*& pBitmap,
return FALSE;
}
CPDF_RenderContext* pContext = pRenderStatus->GetContext();
- CPDF_PageRenderCache* pPageRenderCache = pContext->m_pPageCache;
+ CPDF_PageRenderCache* pPageRenderCache = pContext->GetPageCache();
m_dwTimeCount = pPageRenderCache->GetTimeCount();
CPDF_DIBSource* pSrc = new CPDF_DIBSource;
CPDF_DIBSource* pMaskSrc = NULL;
@@ -325,7 +325,7 @@ int CPDF_ImageCache::ContinueGetCachedBitmap() {
m_MatteColor = ((CPDF_DIBSource*)m_pCurBitmap)->m_MatteColor;
m_pCurMask = ((CPDF_DIBSource*)m_pCurBitmap)->DetachMask();
CPDF_RenderContext* pContext = m_pRenderStatus->GetContext();
- CPDF_PageRenderCache* pPageRenderCache = pContext->m_pPageCache;
+ CPDF_PageRenderCache* pPageRenderCache = pContext->GetPageCache();
m_dwTimeCount = pPageRenderCache->GetTimeCount();
if (m_pCurBitmap->GetPitch() * m_pCurBitmap->GetHeight() <
FPDF_HUGE_IMAGE_SIZE) {
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp
index d3390517e9..9c7b0018fa 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp
@@ -340,7 +340,7 @@ FX_BOOL CPDF_ImageRenderer::StartLoadDIBSource() {
dest_height = -dest_height;
}
if (m_Loader.StartLoadImage(
- m_pImageObject, m_pRenderStatus->m_pContext->m_pPageCache,
+ m_pImageObject, m_pRenderStatus->m_pContext->GetPageCache(),
m_LoadHandle, m_bStdCS, m_pRenderStatus->m_GroupFamily,
m_pRenderStatus->m_bLoadMask, m_pRenderStatus, dest_width,
dest_height)) {
@@ -444,8 +444,8 @@ FX_BOOL CPDF_ImageRenderer::StartRenderDIBSource() {
pGeneralState->m_StrokeAlpha == 1 && pGeneralState->m_FillAlpha == 1) {
CPDF_Document* pDocument = NULL;
CPDF_Page* pPage = NULL;
- if (m_pRenderStatus->m_pContext->m_pPageCache) {
- pPage = m_pRenderStatus->m_pContext->m_pPageCache->GetPage();
+ if (m_pRenderStatus->m_pContext->GetPageCache()) {
+ pPage = m_pRenderStatus->m_pContext->GetPageCache()->GetPage();
pDocument = pPage->m_pDocument;
} else {
pDocument = m_pImageObject->m_pImage->GetDocument();
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
index 9076b7ba20..718fa73009 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
@@ -988,8 +988,7 @@ static CFX_DIBitmap* DrawPatternBitmap(CPDF_Document* pDoc,
}
flags |= RENDER_FORCE_HALFTONE;
options.m_Flags = flags;
- CPDF_RenderContext context;
- context.Create(pDoc, pCache, NULL);
+ CPDF_RenderContext context(pDoc, pCache);
context.DrawObjectList(&bitmap_device, pPattern->m_pForm, &mtPattern2Bitmap,
&options);
return pBitmap;
diff --git a/core/src/fpdfdoc/doc_annot.cpp b/core/src/fpdfdoc/doc_annot.cpp
index 8f3d7f99eb..f4a75e6afc 100644
--- a/core/src/fpdfdoc/doc_annot.cpp
+++ b/core/src/fpdfdoc/doc_annot.cpp
@@ -46,7 +46,7 @@ CPDF_AnnotList::~CPDF_AnnotList() {
delete annot;
}
-void CPDF_AnnotList::DisplayPass(const CPDF_Page* pPage,
+void CPDF_AnnotList::DisplayPass(CPDF_Page* pPage,
CFX_RenderDevice* pDevice,
CPDF_RenderContext* pContext,
FX_BOOL bPrinting,
@@ -97,7 +97,7 @@ void CPDF_AnnotList::DisplayPass(const CPDF_Page* pPage,
}
}
-void CPDF_AnnotList::DisplayAnnots(const CPDF_Page* pPage,
+void CPDF_AnnotList::DisplayAnnots(CPDF_Page* pPage,
CFX_RenderDevice* pDevice,
CPDF_RenderContext* pContext,
FX_BOOL bPrinting,
@@ -216,7 +216,7 @@ static CPDF_Form* FPDFDOC_Annot_GetMatrix(const CPDF_Page* pPage,
matrix.Concat(*pUser2Device);
return pForm;
}
-FX_BOOL CPDF_Annot::DrawAppearance(const CPDF_Page* pPage,
+FX_BOOL CPDF_Annot::DrawAppearance(CPDF_Page* pPage,
CFX_RenderDevice* pDevice,
const CFX_Matrix* pUser2Device,
AppearanceMode mode,
@@ -227,13 +227,12 @@ FX_BOOL CPDF_Annot::DrawAppearance(const CPDF_Page* pPage,
if (!pForm) {
return FALSE;
}
- CPDF_RenderContext context;
- context.Create((CPDF_Page*)pPage);
+ CPDF_RenderContext context(pPage);
context.DrawObjectList(pDevice, pForm, &matrix, pOptions);
return TRUE;
}
FX_BOOL CPDF_Annot::DrawInContext(const CPDF_Page* pPage,
- const CPDF_RenderContext* pContext,
+ CPDF_RenderContext* pContext,
const CFX_Matrix* pUser2Device,
AppearanceMode mode) {
CFX_Matrix matrix;
@@ -242,7 +241,7 @@ FX_BOOL CPDF_Annot::DrawInContext(const CPDF_Page* pPage,
if (!pForm) {
return FALSE;
}
- ((CPDF_RenderContext*)pContext)->AppendObjectList(pForm, &matrix);
+ pContext->AppendObjectList(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 fa0441cf79..93e837feaf 100644
--- a/core/src/fpdfdoc/doc_formcontrol.cpp
+++ b/core/src/fpdfdoc/doc_formcontrol.cpp
@@ -170,22 +170,20 @@ void CPDF_FormControl::DrawControl(CFX_RenderDevice* pDevice,
CPDF_Form form(m_pField->m_pForm->m_pDocument,
m_pField->m_pForm->m_pFormDict->GetDict("DR"), pStream);
form.ParseContent(NULL, NULL, NULL, NULL);
- CPDF_RenderContext context;
- context.Create(pPage);
+ CPDF_RenderContext context(pPage);
context.DrawObjectList(pDevice, &form, &matrix, pOptions);
}
-const FX_CHAR* g_sHighlightingMode[] = {"N", "I", "O", "P", "T", ""};
+static const FX_CHAR* const g_sHighlightingMode[] = {
+ // Must match order of HiglightingMode enum.
+ "N", "I", "O", "P", "T", nullptr};
CPDF_FormControl::HighlightingMode CPDF_FormControl::GetHighlightingMode() {
if (!m_pWidgetDict) {
return Invert;
}
CFX_ByteString csH = m_pWidgetDict->GetString("H", "I");
- int i = 0;
- while (g_sHighlightingMode[i][0] != '\0') {
- if (csH.Equal(g_sHighlightingMode[i])) {
- return (HighlightingMode)i;
- }
- i++;
+ for (int i = 0; g_sHighlightingMode[i]; ++i) {
+ if (csH.Equal(g_sHighlightingMode[i]))
+ return static_cast<HighlightingMode>(i);
}
return Invert;
}