summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/page/cpdf_clippath.cpp20
-rw-r--r--core/fpdfapi/page/cpdf_pageobject.cpp10
-rw-r--r--core/fpdfapi/page/cpdf_pageobject.h3
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp8
4 files changed, 21 insertions, 20 deletions
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
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 7d78253ea6..19fea76d70 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -1121,7 +1121,7 @@ bool CPDF_RenderStatus::ContinueSingleObject(CPDF_PageObject* pObj,
FX_RECT CPDF_RenderStatus::GetObjectClippedRect(
const CPDF_PageObject* pObj,
const CFX_Matrix& mtObj2Device) const {
- FX_RECT rect = pObj->GetBBox(&mtObj2Device);
+ FX_RECT rect = pObj->GetTransformedBBox(mtObj2Device);
rect.Intersect(m_pDevice->GetClipBox());
return rect;
}
@@ -1405,7 +1405,7 @@ bool CPDF_RenderStatus::ClipPattern(const CPDF_PageObject* pPageObj,
if (pPageObj->IsPath())
return SelectClipPath(pPageObj->AsPath(), mtObj2Device, bStroke);
if (pPageObj->IsImage()) {
- m_pDevice->SetClip_Rect(pPageObj->GetBBox(&mtObj2Device));
+ m_pDevice->SetClip_Rect(pPageObj->GetTransformedBBox(mtObj2Device));
return true;
}
return false;
@@ -1514,7 +1514,7 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj,
}
return true;
}
- FX_RECT rect = pPageObj->GetBBox(&mtObj2Device);
+ FX_RECT rect = pPageObj->GetTransformedBBox(mtObj2Device);
rect.Intersect(m_pDevice->GetClipBox());
if (rect.IsEmpty())
return true;
@@ -2138,7 +2138,7 @@ void CPDF_RenderStatus::DrawShadingPattern(CPDF_ShadingPattern* pattern,
void CPDF_RenderStatus::ProcessShading(const CPDF_ShadingObject* pShadingObj,
const CFX_Matrix& mtObj2Device) {
- FX_RECT rect = pShadingObj->GetBBox(&mtObj2Device);
+ FX_RECT rect = pShadingObj->GetTransformedBBox(mtObj2Device);
FX_RECT clip_box = m_pDevice->GetClipBox();
rect.Intersect(clip_box);
if (rect.IsEmpty())