summaryrefslogtreecommitdiff
path: root/core/fpdfapi/fpdf_render
diff options
context:
space:
mode:
authorthestig <thestig@chromium.org>2016-04-26 11:46:02 -0700
committerCommit bot <commit-bot@chromium.org>2016-04-26 11:46:02 -0700
commit5cc24654fb345189140acb4711ff981e1c720951 (patch)
tree1e9e11a9136363e2b330ffbbce6fdf9e3827b5b1 /core/fpdfapi/fpdf_render
parent76c53794b6202ec37f6dcace5f2ae86870e953b6 (diff)
downloadpdfium-5cc24654fb345189140acb4711ff981e1c720951.tar.xz
Clean up CPDF_Page.
- Merge CPDF_Page::Load() into ctor. - Remove always nullptr param for CPDF_Page::ParseContent(). - Remove unneeded indirection in IPDF_RenderModule. - Delete CPDF_ParseOptions. - Fix up CPDF_Pattern. Review URL: https://codereview.chromium.org/1918113002
Diffstat (limited to 'core/fpdfapi/fpdf_render')
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render.cpp10
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render_cache.cpp1
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render_image.cpp18
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp1
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp91
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render_text.cpp1
6 files changed, 52 insertions, 70 deletions
diff --git a/core/fpdfapi/fpdf_render/fpdf_render.cpp b/core/fpdfapi/fpdf_render/fpdf_render.cpp
index 066d4eb2a4..c8fa406a08 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render.cpp
@@ -101,12 +101,6 @@ class CPDF_RenderModule : public IPDF_RenderModule {
CPDF_DocRenderData* GetRenderData() override { return &m_RenderData; }
- CPDF_PageRenderCache* CreatePageCache(CPDF_Page* pPage) override {
- return new CPDF_PageRenderCache(pPage);
- }
-
- void DestroyPageCache(CPDF_PageRenderCache* pCache) override;
-
CPDF_DocRenderData m_RenderData;
};
@@ -121,10 +115,6 @@ void CPDF_RenderModule::ClearDocData(CPDF_DocRenderData* p) {
p->Clear(FALSE);
}
}
-void CPDF_RenderModule::DestroyPageCache(CPDF_PageRenderCache* pCache) {
- delete pCache;
-}
-
void CPDF_ModuleMgr::InitRenderModule() {
m_pRenderModule.reset(new CPDF_RenderModule);
}
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_cache.cpp b/core/fpdfapi/fpdf_render/fpdf_render_cache.cpp
index d95edd7bb7..b0539a2014 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_cache.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_cache.cpp
@@ -6,7 +6,6 @@
#include "core/fpdfapi/fpdf_render/cpdf_pagerendercache.h"
-#include "core/fpdfapi/fpdf_page/cpdf_parseoptions.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
#include "core/fpdfapi/fpdf_page/pageint.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
index ec8a784623..aedf8036cb 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
@@ -9,7 +9,6 @@
#include <utility>
#include <vector>
-#include "core/fpdfapi/fpdf_page/cpdf_parseoptions.h"
#include "core/fpdfapi/fpdf_page/cpdf_shadingpattern.h"
#include "core/fpdfapi/fpdf_page/cpdf_tilingpattern.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_form.h"
@@ -534,14 +533,13 @@ FX_BOOL CPDF_ImageRenderer::DrawPatternImage(const CFX_Matrix* pObj2Device) {
m_pRenderStatus->m_bDropObjects, NULL, TRUE);
CFX_Matrix patternDevice = *pObj2Device;
patternDevice.Translate((FX_FLOAT)-rect.left, (FX_FLOAT)-rect.top);
- if (m_pPattern->m_PatternType == CPDF_Pattern::TILING) {
- bitmap_render.DrawTilingPattern(
- static_cast<CPDF_TilingPattern*>(m_pPattern), m_pImageObject,
- &patternDevice, FALSE);
- } else {
- bitmap_render.DrawShadingPattern(
- static_cast<CPDF_ShadingPattern*>(m_pPattern), m_pImageObject,
- &patternDevice, FALSE);
+ if (CPDF_TilingPattern* pTilingPattern = m_pPattern->AsTilingPattern()) {
+ bitmap_render.DrawTilingPattern(pTilingPattern, m_pImageObject,
+ &patternDevice, FALSE);
+ } else if (CPDF_ShadingPattern* pShadingPattern =
+ m_pPattern->AsShadingPattern()) {
+ bitmap_render.DrawShadingPattern(pShadingPattern, m_pImageObject,
+ &patternDevice, FALSE);
}
}
{
@@ -894,7 +892,7 @@ CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict,
CPDF_Form form(m_pContext->GetDocument(), m_pContext->GetPageResources(),
pGroup);
- form.ParseContent(NULL, NULL, NULL, NULL);
+ form.ParseContent(nullptr, nullptr, nullptr);
CFX_FxgeDevice bitmap_device;
FX_BOOL bLuminosity = pSMaskDict->GetStringBy("S") != "Alpha";
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
index 44ac29f9e1..19aeb71e9a 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
@@ -10,7 +10,6 @@
#include <memory>
#include <vector>
-#include "core/fpdfapi/fpdf_page/cpdf_parseoptions.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_image.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_imageobject.h"
#include "core/fpdfapi/fpdf_page/pageint.h"
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp b/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
index c235fd98cb..0af1175c8e 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
@@ -8,7 +8,6 @@
#include "core/fpdfapi/fpdf_page/cpdf_graphicstates.h"
#include "core/fpdfapi/fpdf_page/cpdf_meshstream.h"
-#include "core/fpdfapi/fpdf_page/cpdf_parseoptions.h"
#include "core/fpdfapi/fpdf_page/cpdf_shadingpattern.h"
#include "core/fpdfapi/fpdf_page/cpdf_tilingpattern.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_form.h"
@@ -947,7 +946,7 @@ void CPDF_RenderStatus::DrawShadingPattern(CPDF_ShadingPattern* pattern,
m_pDevice->RestoreState();
return;
}
- CFX_Matrix matrix = pattern->m_Pattern2Form;
+ CFX_Matrix matrix = *pattern->pattern_to_form();
matrix.Concat(*pObj2Device);
GetScaledMatrix(matrix);
int alpha = pPageObj->m_GeneralState.GetAlpha(bStroke);
@@ -979,15 +978,15 @@ static CFX_DIBitmap* DrawPatternBitmap(CPDF_Document* pDoc,
int flags) {
CFX_DIBitmap* pBitmap = new CFX_DIBitmap;
if (!pBitmap->Create(width, height,
- pPattern->m_bColored ? FXDIB_Argb : FXDIB_8bppMask)) {
+ pPattern->colored() ? FXDIB_Argb : FXDIB_8bppMask)) {
delete pBitmap;
return NULL;
}
CFX_FxgeDevice bitmap_device;
bitmap_device.Attach(pBitmap);
pBitmap->Clear(0);
- CFX_FloatRect cell_bbox = pPattern->m_BBox;
- pPattern->m_Pattern2Form.TransformRect(cell_bbox);
+ CFX_FloatRect cell_bbox = pPattern->bbox();
+ pPattern->pattern_to_form()->TransformRect(cell_bbox);
pObject2Device->TransformRect(cell_bbox);
CFX_FloatRect bitmap_rect(0.0f, 0.0f, (FX_FLOAT)width, (FX_FLOAT)height);
CFX_Matrix mtAdjust;
@@ -995,13 +994,13 @@ static CFX_DIBitmap* DrawPatternBitmap(CPDF_Document* pDoc,
CFX_Matrix mtPattern2Bitmap = *pObject2Device;
mtPattern2Bitmap.Concat(mtAdjust);
CPDF_RenderOptions options;
- if (!pPattern->m_bColored) {
+ if (!pPattern->colored())
options.m_ColorMode = RENDER_COLOR_ALPHA;
- }
+
flags |= RENDER_FORCE_HALFTONE;
options.m_Flags = flags;
CPDF_RenderContext context(pDoc, pCache);
- context.AppendLayer(pPattern->m_pForm, &mtPattern2Bitmap);
+ context.AppendLayer(pPattern->form(), &mtPattern2Bitmap);
context.Render(&bitmap_device, &options, nullptr);
return pBitmap;
}
@@ -1033,17 +1032,17 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
FX_FLOAT sd = FXSYS_fabs(dCTM.d);
clip_box.right = clip_box.left + (int32_t)FXSYS_ceil(clip_box.Width() * sa);
clip_box.bottom = clip_box.top + (int32_t)FXSYS_ceil(clip_box.Height() * sd);
- CFX_Matrix mtPattern2Device = pPattern->m_Pattern2Form;
+ CFX_Matrix mtPattern2Device = *pPattern->pattern_to_form();
mtPattern2Device.Concat(*pObj2Device);
GetScaledMatrix(mtPattern2Device);
FX_BOOL bAligned = FALSE;
- if (pPattern->m_BBox.left == 0 && pPattern->m_BBox.bottom == 0 &&
- pPattern->m_BBox.right == pPattern->m_XStep &&
- pPattern->m_BBox.top == pPattern->m_YStep &&
+ if (pPattern->bbox().left == 0 && pPattern->bbox().bottom == 0 &&
+ pPattern->bbox().right == pPattern->x_step() &&
+ pPattern->bbox().top == pPattern->y_step() &&
(mtPattern2Device.IsScaled() || mtPattern2Device.Is90Rotated())) {
bAligned = TRUE;
}
- CFX_FloatRect cell_bbox = pPattern->m_BBox;
+ CFX_FloatRect cell_bbox = pPattern->bbox();
mtPattern2Device.TransformRect(cell_bbox);
int width = (int)FXSYS_ceil(cell_bbox.Width());
int height = (int)FXSYS_ceil(cell_bbox.Height());
@@ -1059,40 +1058,40 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
CFX_FloatRect clip_box_p(clip_box);
clip_box_p.Transform(&mtDevice2Pattern);
- min_col = (int)FXSYS_ceil((clip_box_p.left - pPattern->m_BBox.right) /
- pPattern->m_XStep);
- max_col = (int)FXSYS_floor((clip_box_p.right - pPattern->m_BBox.left) /
- pPattern->m_XStep);
- min_row = (int)FXSYS_ceil((clip_box_p.bottom - pPattern->m_BBox.top) /
- pPattern->m_YStep);
- max_row = (int)FXSYS_floor((clip_box_p.top - pPattern->m_BBox.bottom) /
- pPattern->m_YStep);
+ min_col = (int)FXSYS_ceil((clip_box_p.left - pPattern->bbox().right) /
+ pPattern->x_step());
+ max_col = (int)FXSYS_floor((clip_box_p.right - pPattern->bbox().left) /
+ pPattern->x_step());
+ min_row = (int)FXSYS_ceil((clip_box_p.bottom - pPattern->bbox().top) /
+ pPattern->y_step());
+ max_row = (int)FXSYS_floor((clip_box_p.top - pPattern->bbox().bottom) /
+ pPattern->y_step());
if (width > clip_box.Width() || height > clip_box.Height() ||
width * height > clip_box.Width() * clip_box.Height()) {
CPDF_GraphicStates* pStates = NULL;
- if (!pPattern->m_bColored) {
+ if (!pPattern->colored())
pStates = CloneObjStates(pPageObj, bStroke);
- }
- CPDF_Dictionary* pFormResource = NULL;
- if (pPattern->m_pForm->m_pFormDict) {
- pFormResource = pPattern->m_pForm->m_pFormDict->GetDictBy("Resources");
- }
+
+ CPDF_Dictionary* pFormResource = nullptr;
+ if (pPattern->form()->m_pFormDict)
+ pFormResource = pPattern->form()->m_pFormDict->GetDictBy("Resources");
+
for (int col = min_col; col <= max_col; col++)
for (int row = min_row; row <= max_row; row++) {
FX_FLOAT orig_x, orig_y;
- orig_x = col * pPattern->m_XStep;
- orig_y = row * pPattern->m_YStep;
+ orig_x = col * pPattern->x_step();
+ orig_y = row * pPattern->y_step();
mtPattern2Device.Transform(orig_x, orig_y);
CFX_Matrix matrix = *pObj2Device;
matrix.Translate(orig_x - mtPattern2Device.e,
orig_y - mtPattern2Device.f);
m_pDevice->SaveState();
CPDF_RenderStatus status;
- status.Initialize(m_pContext, m_pDevice, NULL, NULL, this, pStates,
- &m_Options, pPattern->m_pForm->m_Transparency,
+ status.Initialize(m_pContext, m_pDevice, nullptr, nullptr, this,
+ pStates, &m_Options, pPattern->form()->m_Transparency,
m_bDropObjects, pFormResource);
- status.RenderObjectList(pPattern->m_pForm, &matrix);
+ status.RenderObjectList(pPattern->form(), &matrix);
m_pDevice->RestoreState();
}
m_pDevice->RestoreState();
@@ -1157,8 +1156,8 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
start_x = FXSYS_round(mtPattern2Device.e) + col * width - clip_box.left;
start_y = FXSYS_round(mtPattern2Device.f) + row * height - clip_box.top;
} else {
- FX_FLOAT orig_x = col * pPattern->m_XStep;
- FX_FLOAT orig_y = row * pPattern->m_YStep;
+ FX_FLOAT orig_x = col * pPattern->x_step();
+ FX_FLOAT orig_y = row * pPattern->y_step();
mtPattern2Device.Transform(orig_x, orig_y);
start_x = FXSYS_round(orig_x + left_offset) - clip_box.left;
start_y = FXSYS_round(orig_y + top_offset) - clip_box.top;
@@ -1171,13 +1170,12 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
uint32_t* dest_buf =
(uint32_t*)(screen.GetBuffer() + screen.GetPitch() * start_y +
start_x * 4);
- if (pPattern->m_bColored) {
+ if (pPattern->colored())
*dest_buf = *src_buf;
- } else {
+ else
*dest_buf = (*(uint8_t*)src_buf << 24) | (fill_argb & 0xffffff);
- }
} else {
- if (pPattern->m_bColored) {
+ if (pPattern->colored()) {
screen.CompositeBitmap(start_x, start_y, width, height,
pPatternBitmap, 0, 0);
} else {
@@ -1192,22 +1190,21 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
m_pDevice->RestoreState();
delete pPatternBitmap;
}
+
void CPDF_RenderStatus::DrawPathWithPattern(const CPDF_PathObject* pPathObj,
const CFX_Matrix* pObj2Device,
CPDF_Color* pColor,
FX_BOOL bStroke) {
CPDF_Pattern* pattern = pColor->GetPattern();
- if (!pattern) {
+ if (!pattern)
return;
- }
- if (pattern->m_PatternType == CPDF_Pattern::TILING) {
- DrawTilingPattern(static_cast<CPDF_TilingPattern*>(pattern), pPathObj,
- pObj2Device, bStroke);
- } else {
- DrawShadingPattern(static_cast<CPDF_ShadingPattern*>(pattern), pPathObj,
- pObj2Device, bStroke);
- }
+
+ if (CPDF_TilingPattern* pTilingPattern = pattern->AsTilingPattern())
+ DrawTilingPattern(pTilingPattern, pPathObj, pObj2Device, bStroke);
+ else if (CPDF_ShadingPattern* pShadingPattern = pattern->AsShadingPattern())
+ DrawShadingPattern(pShadingPattern, pPathObj, pObj2Device, bStroke);
}
+
void CPDF_RenderStatus::ProcessPathPattern(const CPDF_PathObject* pPathObj,
const CFX_Matrix* pObj2Device,
int& filltype,
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
index ff8df7685d..acc70c001e 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
@@ -10,7 +10,6 @@
#include "core/fpdfapi/fpdf_font/cpdf_type3char.h"
#include "core/fpdfapi/fpdf_font/cpdf_type3font.h"
#include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
-#include "core/fpdfapi/fpdf_page/cpdf_parseoptions.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_form.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_imageobject.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h"