summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-12-19 16:35:26 -0800
committerChromium commit bot <commit-bot@chromium.org>2018-01-08 23:17:06 +0000
commit88469f5fa0fe43b74063ffaec97617ef0abbb8ca (patch)
tree6f38498021fe68baccd427dc99620a326a074f60
parent1f2211e9c3d0c2c3a448280b58c85d021cb3ee4b (diff)
downloadpdfium-88469f5fa0fe43b74063ffaec97617ef0abbb8ca.tar.xz
Encapsulate CPDF_ShadingObject members.
Change-Id: I9b878c8df4a6208fb1908bad09eb1c699970163f Reviewed-on: https://pdfium-review.googlesource.com/21690 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
-rw-r--r--core/fpdfapi/page/cpdf_shadingobject.cpp4
-rw-r--r--core/fpdfapi/page/cpdf_shadingobject.h8
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp9
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp6
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.h2
5 files changed, 17 insertions, 12 deletions
diff --git a/core/fpdfapi/page/cpdf_shadingobject.cpp b/core/fpdfapi/page/cpdf_shadingobject.cpp
index df3fbd17cd..1b16ac4862 100644
--- a/core/fpdfapi/page/cpdf_shadingobject.cpp
+++ b/core/fpdfapi/page/cpdf_shadingobject.cpp
@@ -9,7 +9,9 @@
#include "core/fpdfapi/page/cpdf_shadingpattern.h"
#include "core/fpdfapi/parser/cpdf_document.h"
-CPDF_ShadingObject::CPDF_ShadingObject() : m_pShading(nullptr) {}
+CPDF_ShadingObject::CPDF_ShadingObject(CPDF_ShadingPattern* pattern,
+ const CFX_Matrix& matrix)
+ : m_pShading(pattern), m_Matrix(matrix) {}
CPDF_ShadingObject::~CPDF_ShadingObject() {}
diff --git a/core/fpdfapi/page/cpdf_shadingobject.h b/core/fpdfapi/page/cpdf_shadingobject.h
index a5405cb090..80e062c729 100644
--- a/core/fpdfapi/page/cpdf_shadingobject.h
+++ b/core/fpdfapi/page/cpdf_shadingobject.h
@@ -15,10 +15,10 @@ class CPDF_ShadingPattern;
class CPDF_ShadingObject : public CPDF_PageObject {
public:
- CPDF_ShadingObject();
+ CPDF_ShadingObject(CPDF_ShadingPattern* pattern, const CFX_Matrix& matrix);
~CPDF_ShadingObject() override;
- // CPDF_PageObject
+ // CPDF_PageObject:
Type GetType() const override;
void Transform(const CFX_Matrix& matrix) override;
bool IsShading() const override;
@@ -27,6 +27,10 @@ class CPDF_ShadingObject : public CPDF_PageObject {
void CalcBoundingBox();
+ const CPDF_ShadingPattern* pattern() const { return m_pShading.Get(); }
+ const CFX_Matrix& matrix() const { return m_Matrix; }
+
+ private:
UnownedPtr<CPDF_ShadingPattern> m_pShading;
CFX_Matrix m_Matrix;
};
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 3bd40d5b7c..4e3857bf85 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -1113,15 +1113,14 @@ void CPDF_StreamContentParser::Handle_ShadeFill() {
if (!pShading->IsShadingObject() || !pShading->Load())
return;
- auto pObj = pdfium::MakeUnique<CPDF_ShadingObject>();
- pObj->m_pShading = pShading;
+ CFX_Matrix matrix = m_pCurStates->m_CTM;
+ matrix.Concat(m_mtContentToUser);
+ auto pObj = pdfium::MakeUnique<CPDF_ShadingObject>(pShading, matrix);
SetGraphicStates(pObj.get(), false, false, false);
- pObj->m_Matrix = m_pCurStates->m_CTM;
- pObj->m_Matrix.Concat(m_mtContentToUser);
CFX_FloatRect bbox =
pObj->m_ClipPath.HasRef() ? pObj->m_ClipPath.GetClipBox() : m_BBox;
if (pShading->IsMeshShading())
- bbox.Intersect(GetShadingBBox(pShading, pObj->m_Matrix));
+ bbox.Intersect(GetShadingBBox(pShading, pObj->matrix()));
pObj->m_Left = bbox.left;
pObj->m_Right = bbox.right;
pObj->m_Top = bbox.top;
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 3f61358d7f..8899867354 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -2065,7 +2065,7 @@ void CPDF_RenderStatus::DrawTextPathWithPattern(const CPDF_TextObject* textobj,
}
}
-void CPDF_RenderStatus::DrawShading(CPDF_ShadingPattern* pPattern,
+void CPDF_RenderStatus::DrawShading(const CPDF_ShadingPattern* pPattern,
CFX_Matrix* pMatrix,
FX_RECT& clip_rect,
int alpha,
@@ -2197,9 +2197,9 @@ void CPDF_RenderStatus::ProcessShading(const CPDF_ShadingObject* pShadingObj,
if (rect.IsEmpty())
return;
- CFX_Matrix matrix = pShadingObj->m_Matrix;
+ CFX_Matrix matrix = pShadingObj->matrix();
matrix.Concat(*pObj2Device);
- DrawShading(pShadingObj->m_pShading.Get(), &matrix, rect,
+ DrawShading(pShadingObj->pattern(), &matrix, rect,
FXSYS_round(255 * pShadingObj->m_GeneralState.GetFillAlpha()),
m_Options.ColorModeIs(CPDF_RenderOptions::kAlpha));
}
diff --git a/core/fpdfapi/render/cpdf_renderstatus.h b/core/fpdfapi/render/cpdf_renderstatus.h
index 1dbdf5bbd3..c8b7b09017 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.h
+++ b/core/fpdfapi/render/cpdf_renderstatus.h
@@ -121,7 +121,7 @@ class CPDF_RenderStatus {
bool ProcessImage(CPDF_ImageObject* pImageObj, const CFX_Matrix* pObj2Device);
void ProcessShading(const CPDF_ShadingObject* pShadingObj,
const CFX_Matrix* pObj2Device);
- void DrawShading(CPDF_ShadingPattern* pPattern,
+ void DrawShading(const CPDF_ShadingPattern* pPattern,
CFX_Matrix* pMatrix,
FX_RECT& clip_rect,
int alpha,