summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page
diff options
context:
space:
mode:
authorJane Liu <janeliulwq@google.com>2017-08-22 10:50:06 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-08-22 16:42:55 +0000
commit878b27de2fa8e5bdc3b910c98846f4b43185d4aa (patch)
treef21a9528354ebf533a637f5ea0e8edaa44be7427 /core/fpdfapi/page
parentaac59a0e59052366e260396165a759b5b0e80188 (diff)
downloadpdfium-878b27de2fa8e5bdc3b910c98846f4b43185d4aa.tar.xz
Converted CFX_Matrix::TransformRect() to take in consts
Currently, all three of CFX_Matrix::TransformRect() take in rect values and modify them in place. This CL converts them to take in constant values and return the transformed values instead, and fixes all the call sites. Bug=pdfium:874 Change-Id: I9c274df3b14e9d88c100ba0530068e06e8fec32b Reviewed-on: https://pdfium-review.googlesource.com/11550 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Jane Liu <janeliulwq@google.com>
Diffstat (limited to 'core/fpdfapi/page')
-rw-r--r--core/fpdfapi/page/cpdf_contentparser.cpp4
-rw-r--r--core/fpdfapi/page/cpdf_formobject.cpp4
-rw-r--r--core/fpdfapi/page/cpdf_imageobject.cpp7
-rw-r--r--core/fpdfapi/page/cpdf_pageobject.cpp6
-rw-r--r--core/fpdfapi/page/cpdf_pathobject.cpp2
-rw-r--r--core/fpdfapi/page/cpdf_shadingobject.cpp3
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp3
-rw-r--r--core/fpdfapi/page/cpdf_textobject.cpp8
8 files changed, 15 insertions, 22 deletions
diff --git a/core/fpdfapi/page/cpdf_contentparser.cpp b/core/fpdfapi/page/cpdf_contentparser.cpp
index 4f4036f078..36dea17572 100644
--- a/core/fpdfapi/page/cpdf_contentparser.cpp
+++ b/core/fpdfapi/page/cpdf_contentparser.cpp
@@ -91,9 +91,9 @@ void CPDF_ContentParser::Start(CPDF_Form* pForm,
if (pParentMatrix)
ClipPath.Transform(pParentMatrix);
- form_matrix.TransformRect(form_bbox);
+ form_bbox = form_matrix.TransformRect(form_bbox);
if (pParentMatrix)
- pParentMatrix->TransformRect(form_bbox);
+ form_bbox = pParentMatrix->TransformRect(form_bbox);
}
CPDF_Dictionary* pResources = pForm->m_pFormDict->GetDictFor("Resources");
diff --git a/core/fpdfapi/page/cpdf_formobject.cpp b/core/fpdfapi/page/cpdf_formobject.cpp
index 5642a5dd01..c0cdd3e950 100644
--- a/core/fpdfapi/page/cpdf_formobject.cpp
+++ b/core/fpdfapi/page/cpdf_formobject.cpp
@@ -34,8 +34,8 @@ CPDF_PageObject::Type CPDF_FormObject::GetType() const {
}
void CPDF_FormObject::CalcBoundingBox() {
- CFX_FloatRect form_rect = m_pForm->CalcBoundingBox();
- m_FormMatrix.TransformRect(form_rect);
+ CFX_FloatRect form_rect =
+ m_FormMatrix.TransformRect(m_pForm->CalcBoundingBox());
m_Left = form_rect.left;
m_Bottom = form_rect.bottom;
m_Right = form_rect.right;
diff --git a/core/fpdfapi/page/cpdf_imageobject.cpp b/core/fpdfapi/page/cpdf_imageobject.cpp
index a74ac4802c..dd07385db4 100644
--- a/core/fpdfapi/page/cpdf_imageobject.cpp
+++ b/core/fpdfapi/page/cpdf_imageobject.cpp
@@ -41,11 +41,8 @@ const CPDF_ImageObject* CPDF_ImageObject::AsImage() const {
}
void CPDF_ImageObject::CalcBoundingBox() {
- m_Left = 0;
- m_Bottom = 0;
- m_Right = 1.0f;
- m_Top = 1.0f;
- m_Matrix.TransformRect(m_Left, m_Right, m_Top, m_Bottom);
+ std::tie(m_Left, m_Right, m_Top, m_Bottom) =
+ m_Matrix.TransformRect(0.f, 1.f, 1.f, 0.f);
}
void CPDF_ImageObject::SetImage(const CFX_RetainPtr<CPDF_Image>& pImage) {
diff --git a/core/fpdfapi/page/cpdf_pageobject.cpp b/core/fpdfapi/page/cpdf_pageobject.cpp
index 79d9bbc540..8bb5bf5978 100644
--- a/core/fpdfapi/page/cpdf_pageobject.cpp
+++ b/core/fpdfapi/page/cpdf_pageobject.cpp
@@ -95,8 +95,8 @@ void CPDF_PageObject::TransformGeneralState(CFX_Matrix& matrix) {
FX_RECT CPDF_PageObject::GetBBox(const CFX_Matrix* pMatrix) const {
CFX_FloatRect rect(m_Left, m_Bottom, m_Right, m_Top);
- if (pMatrix) {
- pMatrix->TransformRect(rect);
- }
+ if (pMatrix)
+ rect = pMatrix->TransformRect(rect);
+
return rect.GetOuterRect();
}
diff --git a/core/fpdfapi/page/cpdf_pathobject.cpp b/core/fpdfapi/page/cpdf_pathobject.cpp
index 7dd91598c6..d8c2cb8741 100644
--- a/core/fpdfapi/page/cpdf_pathobject.cpp
+++ b/core/fpdfapi/page/cpdf_pathobject.cpp
@@ -42,7 +42,7 @@ void CPDF_PathObject::CalcBoundingBox() {
} else {
rect = m_Path.GetBoundingBox();
}
- m_Matrix.TransformRect(rect);
+ rect = m_Matrix.TransformRect(rect);
if (width == 0 && m_bStroke) {
rect.left += -0.5f;
diff --git a/core/fpdfapi/page/cpdf_shadingobject.cpp b/core/fpdfapi/page/cpdf_shadingobject.cpp
index 8a61161f17..df3fbd17cd 100644
--- a/core/fpdfapi/page/cpdf_shadingobject.cpp
+++ b/core/fpdfapi/page/cpdf_shadingobject.cpp
@@ -25,7 +25,8 @@ void CPDF_ShadingObject::Transform(const CFX_Matrix& matrix) {
if (m_ClipPath.HasRef()) {
CalcBoundingBox();
} else {
- matrix.TransformRect(m_Left, m_Right, m_Top, m_Bottom);
+ std::tie(m_Left, m_Right, m_Top, m_Bottom) =
+ matrix.TransformRect(m_Left, m_Right, m_Top, m_Bottom);
}
}
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index ca92b9efdf..1d5ddaeed2 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -130,8 +130,7 @@ CFX_FloatRect GetShadingBBox(CPDF_ShadingPattern* pShading,
if (bGouraud)
stream.BitStream()->ByteAlign();
}
- matrix.TransformRect(rect);
- return rect;
+ return matrix.TransformRect(rect);
}
struct AbbrPair {
diff --git a/core/fpdfapi/page/cpdf_textobject.cpp b/core/fpdfapi/page/cpdf_textobject.cpp
index 7a70101789..a4d714ff72 100644
--- a/core/fpdfapi/page/cpdf_textobject.cpp
+++ b/core/fpdfapi/page/cpdf_textobject.cpp
@@ -261,12 +261,8 @@ CFX_PointF CPDF_TextObject::CalcPositionData(float horz_scale) {
min_y = min_y * fontsize / 1000;
max_y = max_y * fontsize / 1000;
}
-
- m_Left = min_x;
- m_Right = max_x;
- m_Bottom = min_y;
- m_Top = max_y;
- GetTextMatrix().TransformRect(m_Left, m_Right, m_Top, m_Bottom);
+ std::tie(m_Left, m_Right, m_Top, m_Bottom) =
+ GetTextMatrix().TransformRect(min_x, max_x, max_y, min_y);
if (!TextRenderingModeIsStrokeMode(m_TextState.GetTextMode()))
return ret;