From a0032a2a2c53794bbf0ccb412a5c70ce66f052fb Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 5 Oct 2018 22:18:32 +0000 Subject: Remove optional matrix parameter from CPDF_PageObject::GetBBox(). Instead, add GetTransformedBBox() with a required matrix parameter and use that when the there is a matrix. Change-Id: I594f3eb6bc7e1bc3eb6aa9f66556ebb1dfdbebe1 Reviewed-on: https://pdfium-review.googlesource.com/c/43553 Commit-Queue: Lei Zhang Reviewed-by: Tom Sepez --- core/fpdfapi/page/cpdf_clippath.cpp | 20 ++++++++++---------- core/fpdfapi/page/cpdf_pageobject.cpp | 10 +++++----- core/fpdfapi/page/cpdf_pageobject.h | 3 ++- 3 files changed, 17 insertions(+), 16 deletions(-) (limited to 'core/fpdfapi/page') diff --git a/core/fpdfapi/page/cpdf_clippath.cpp b/core/fpdfapi/page/cpdf_clippath.cpp index 465a2d3549..9782469786 100644 --- a/core/fpdfapi/page/cpdf_clippath.cpp +++ b/core/fpdfapi/page/cpdf_clippath.cpp @@ -55,21 +55,21 @@ CFX_FloatRect CPDF_ClipPath::GetClipBox() const { bool bLayerStarted = false; for (size_t i = 0; i < GetTextCount(); ++i) { CPDF_TextObject* pTextObj = GetText(i); - if (!pTextObj) { - if (!bStarted) { - rect = layer_rect; - bStarted = true; + if (pTextObj) { + if (bLayerStarted) { + layer_rect.Union(CFX_FloatRect(pTextObj->GetBBox())); } else { - rect.Intersect(layer_rect); + layer_rect = CFX_FloatRect(pTextObj->GetBBox()); + bLayerStarted = true; } - bLayerStarted = false; } else { - if (!bLayerStarted) { - layer_rect = CFX_FloatRect(pTextObj->GetBBox(nullptr)); - bLayerStarted = true; + if (bStarted) { + rect.Intersect(layer_rect); } else { - layer_rect.Union(CFX_FloatRect(pTextObj->GetBBox(nullptr))); + rect = layer_rect; + bStarted = true; } + bLayerStarted = false; } } return rect; diff --git a/core/fpdfapi/page/cpdf_pageobject.cpp b/core/fpdfapi/page/cpdf_pageobject.cpp index 604309f6e6..0c3a850936 100644 --- a/core/fpdfapi/page/cpdf_pageobject.cpp +++ b/core/fpdfapi/page/cpdf_pageobject.cpp @@ -98,10 +98,10 @@ void CPDF_PageObject::TransformGeneralState(CFX_Matrix& matrix) { SetDirty(true); } -FX_RECT CPDF_PageObject::GetBBox(const CFX_Matrix* pMatrix) const { - CFX_FloatRect rect(m_Left, m_Bottom, m_Right, m_Top); - if (pMatrix) - rect = pMatrix->TransformRect(rect); +FX_RECT CPDF_PageObject::GetBBox() const { + return GetRect().GetOuterRect(); +} - return rect.GetOuterRect(); +FX_RECT CPDF_PageObject::GetTransformedBBox(const CFX_Matrix& matrix) const { + return matrix.TransformRect(GetRect()).GetOuterRect(); } diff --git a/core/fpdfapi/page/cpdf_pageobject.h b/core/fpdfapi/page/cpdf_pageobject.h index 3fc35aa063..1dfe20b6f9 100644 --- a/core/fpdfapi/page/cpdf_pageobject.h +++ b/core/fpdfapi/page/cpdf_pageobject.h @@ -60,7 +60,8 @@ class CPDF_PageObject : public CPDF_GraphicStates { CFX_FloatRect GetRect() const { return CFX_FloatRect(m_Left, m_Bottom, m_Right, m_Top); } - FX_RECT GetBBox(const CFX_Matrix* pMatrix) const; + FX_RECT GetBBox() const; + FX_RECT GetTransformedBBox(const CFX_Matrix& matrix) const; // Get what content stream the object was parsed from in its page. This number // is the index of the content stream in the "Contents" array, or 0 if there -- cgit v1.2.3