From e858aa4b70db7408bda1aed71827d9eee1dd98c5 Mon Sep 17 00:00:00 2001 From: wileyrya Date: Wed, 31 May 2017 14:49:05 -0500 Subject: Fix content generation to only generate dirty page objects. BUG=pdfium:717 R=dsinclair@chromium.org,thestig@chromium.org Change-Id: I7e0e6fd301d40f9b5341d40cf11167b7748af243 Reviewed-on: https://pdfium-review.googlesource.com/6071 Reviewed-by: dsinclair Reviewed-by: Lei Zhang Commit-Queue: dsinclair --- core/fpdfapi/page/cpdf_imageobject.cpp | 1 + core/fpdfapi/page/cpdf_pageobject.cpp | 5 ++++- core/fpdfapi/page/cpdf_pageobject.h | 4 ++++ core/fpdfapi/page/cpdf_pathobject.cpp | 1 + core/fpdfapi/page/cpdf_textobject.cpp | 2 ++ 5 files changed, 12 insertions(+), 1 deletion(-) (limited to 'core/fpdfapi/page') diff --git a/core/fpdfapi/page/cpdf_imageobject.cpp b/core/fpdfapi/page/cpdf_imageobject.cpp index 8732c00954..a74ac4802c 100644 --- a/core/fpdfapi/page/cpdf_imageobject.cpp +++ b/core/fpdfapi/page/cpdf_imageobject.cpp @@ -25,6 +25,7 @@ CPDF_PageObject::Type CPDF_ImageObject::GetType() const { void CPDF_ImageObject::Transform(const CFX_Matrix& matrix) { m_Matrix.Concat(matrix); CalcBoundingBox(); + SetDirty(true); } bool CPDF_ImageObject::IsImage() const { diff --git a/core/fpdfapi/page/cpdf_pageobject.cpp b/core/fpdfapi/page/cpdf_pageobject.cpp index 09a98eee7d..79d9bbc540 100644 --- a/core/fpdfapi/page/cpdf_pageobject.cpp +++ b/core/fpdfapi/page/cpdf_pageobject.cpp @@ -6,7 +6,7 @@ #include "core/fpdfapi/page/cpdf_pageobject.h" -CPDF_PageObject::CPDF_PageObject() {} +CPDF_PageObject::CPDF_PageObject() : m_bDirty(false) {} CPDF_PageObject::~CPDF_PageObject() {} @@ -76,18 +76,21 @@ void CPDF_PageObject::CopyData(const CPDF_PageObject* pSrc) { m_Right = pSrc->m_Right; m_Top = pSrc->m_Top; m_Bottom = pSrc->m_Bottom; + m_bDirty = true; } void CPDF_PageObject::TransformClipPath(CFX_Matrix& matrix) { if (!m_ClipPath.HasRef()) return; m_ClipPath.Transform(matrix); + SetDirty(true); } void CPDF_PageObject::TransformGeneralState(CFX_Matrix& matrix) { if (!m_GeneralState.HasRef()) return; m_GeneralState.GetMutableMatrix()->Concat(matrix); + SetDirty(true); } FX_RECT CPDF_PageObject::GetBBox(const CFX_Matrix* pMatrix) const { diff --git a/core/fpdfapi/page/cpdf_pageobject.h b/core/fpdfapi/page/cpdf_pageobject.h index 668621ff51..d23cd971f8 100644 --- a/core/fpdfapi/page/cpdf_pageobject.h +++ b/core/fpdfapi/page/cpdf_pageobject.h @@ -49,6 +49,8 @@ class CPDF_PageObject : public CPDF_GraphicStates { virtual CPDF_FormObject* AsForm(); virtual const CPDF_FormObject* AsForm() const; + void SetDirty(bool value) { m_bDirty = value; } + bool IsDirty() const { return m_bDirty; } void TransformClipPath(CFX_Matrix& matrix); void TransformGeneralState(CFX_Matrix& matrix); @@ -69,6 +71,8 @@ class CPDF_PageObject : public CPDF_GraphicStates { private: CPDF_PageObject(const CPDF_PageObject& src) = delete; void operator=(const CPDF_PageObject& src) = delete; + + bool m_bDirty; }; #endif // CORE_FPDFAPI_PAGE_CPDF_PAGEOBJECT_H_ diff --git a/core/fpdfapi/page/cpdf_pathobject.cpp b/core/fpdfapi/page/cpdf_pathobject.cpp index c4d55bc20f..b54ad6e151 100644 --- a/core/fpdfapi/page/cpdf_pathobject.cpp +++ b/core/fpdfapi/page/cpdf_pathobject.cpp @@ -17,6 +17,7 @@ CPDF_PageObject::Type CPDF_PathObject::GetType() const { void CPDF_PathObject::Transform(const CFX_Matrix& matrix) { m_Matrix.Concat(matrix); CalcBoundingBox(); + SetDirty(true); } bool CPDF_PathObject::IsPath() const { diff --git a/core/fpdfapi/page/cpdf_textobject.cpp b/core/fpdfapi/page/cpdf_textobject.cpp index b8f3f61073..7a70101789 100644 --- a/core/fpdfapi/page/cpdf_textobject.cpp +++ b/core/fpdfapi/page/cpdf_textobject.cpp @@ -115,6 +115,7 @@ void CPDF_TextObject::Transform(const CFX_Matrix& matrix) { pTextMatrix[3] = text_matrix.d; m_Pos = CFX_PointF(text_matrix.e, text_matrix.f); CalcPositionData(0); + SetDirty(true); } bool CPDF_TextObject::IsText() const { @@ -164,6 +165,7 @@ void CPDF_TextObject::SetSegments(const CFX_ByteString* pStrs, void CPDF_TextObject::SetText(const CFX_ByteString& str) { SetSegments(&str, nullptr, 1); RecalcPositionData(); + SetDirty(true); } float CPDF_TextObject::GetCharWidth(uint32_t charcode) const { -- cgit v1.2.3