summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-12-17 13:35:22 -0800
committerTom Sepez <tsepez@chromium.org>2015-12-17 13:35:22 -0800
commit761660c4074269ac806d06c9bef70e4e9fb0eb29 (patch)
tree6ba6709f676261367161ab717f2dfe44eac89103 /core/src/fpdfapi
parent0a9158b99a2002fb82301ebec20dbc23b3fc084c (diff)
downloadpdfium-761660c4074269ac806d06c9bef70e4e9fb0eb29.tar.xz
Tidy CPDF_RenderContext
- Remove unused Clear() method. - Replace Create() with actual ctors. - Avoid const casts. - Protect members. - Add missing const in adjacent code. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1536623004 .
Diffstat (limited to 'core/src/fpdfapi')
-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
4 files changed, 17 insertions, 30 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;