summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJane Liu <janeliulwq@google.com>2017-08-18 14:42:58 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-08-21 15:05:56 +0000
commit69ad278881f83a1f8cf45d5a42a88752c0871c7e (patch)
tree0118fe1b71175b3c5b2da9c49b33ef9a349f8444
parent8c6dc95678810e3a054744a6a229606ac0d75134 (diff)
downloadpdfium-69ad278881f83a1f8cf45d5a42a88752c0871c7e.tar.xz
Converted CFX_FloatRect::{Init|Update}Rect() to take point objects
Converted CFX_FloatRect::Init() and CFX_FloatRect::UpdateRect() to take in a CFX_PointF object instead of two coordinates. Bug=pdfium:770 Change-Id: Ibcb620f192d6c086158c39f23c411777286005d0 Reviewed-on: https://pdfium-review.googlesource.com/11450 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp4
-rw-r--r--core/fxcrt/fx_coordinates.cpp10
-rw-r--r--core/fxcrt/fx_coordinates.h12
-rw-r--r--core/fxge/cfx_pathdata.cpp35
4 files changed, 30 insertions, 31 deletions
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 1e6bf6c3c8..ca92b9efdf 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -114,9 +114,9 @@ CFX_FloatRect GetShadingBBox(CPDF_ShadingPattern* pShading,
break;
CFX_PointF origin = stream.ReadCoords();
if (bStarted) {
- rect.UpdateRect(origin.x, origin.y);
+ rect.UpdateRect(origin);
} else {
- rect.InitRect(origin.x, origin.y);
+ rect.InitRect(origin);
bStarted = true;
}
}
diff --git a/core/fxcrt/fx_coordinates.cpp b/core/fxcrt/fx_coordinates.cpp
index 752591d3ed..26c9169fd9 100644
--- a/core/fxcrt/fx_coordinates.cpp
+++ b/core/fxcrt/fx_coordinates.cpp
@@ -184,11 +184,11 @@ bool CFX_FloatRect::Contains(const CFX_FloatRect& other_rect) const {
n2.top <= n1.top;
}
-void CFX_FloatRect::UpdateRect(float x, float y) {
- left = std::min(left, x);
- bottom = std::min(bottom, y);
- right = std::max(right, x);
- top = std::max(top, y);
+void CFX_FloatRect::UpdateRect(const CFX_PointF& point) {
+ left = std::min(left, point.x);
+ bottom = std::min(bottom, point.y);
+ right = std::max(right, point.x);
+ top = std::max(top, point.y);
}
CFX_FloatRect CFX_FloatRect::GetBBox(const CFX_PointF* pPoints, int nPoints) {
diff --git a/core/fxcrt/fx_coordinates.h b/core/fxcrt/fx_coordinates.h
index 86b921d85c..cc14508d70 100644
--- a/core/fxcrt/fx_coordinates.h
+++ b/core/fxcrt/fx_coordinates.h
@@ -274,13 +274,13 @@ class CFX_FloatRect {
int Substract4(CFX_FloatRect& substract_rect, CFX_FloatRect* pRects);
- void InitRect(float x, float y) {
- left = x;
- right = x;
- bottom = y;
- top = y;
+ void InitRect(const CFX_PointF& point) {
+ left = point.x;
+ right = point.x;
+ bottom = point.y;
+ top = point.y;
}
- void UpdateRect(float x, float y);
+ void UpdateRect(const CFX_PointF& point);
float Width() const { return right - left; }
float Height() const { return top - bottom; }
diff --git a/core/fxge/cfx_pathdata.cpp b/core/fxge/cfx_pathdata.cpp
index 1dbb44638c..4ac5cf6a7a 100644
--- a/core/fxge/cfx_pathdata.cpp
+++ b/core/fxge/cfx_pathdata.cpp
@@ -17,8 +17,8 @@ void UpdateLineEndPoints(CFX_FloatRect* rect,
float hw) {
if (start_pos.x == end_pos.x) {
if (start_pos.y == end_pos.y) {
- rect->UpdateRect(end_pos.x + hw, end_pos.y + hw);
- rect->UpdateRect(end_pos.x - hw, end_pos.y - hw);
+ rect->UpdateRect(end_pos + CFX_PointF(hw, hw));
+ rect->UpdateRect(end_pos - CFX_PointF(hw, hw));
return;
}
@@ -28,8 +28,8 @@ void UpdateLineEndPoints(CFX_FloatRect* rect,
else
point_y = end_pos.y + hw;
- rect->UpdateRect(end_pos.x + hw, point_y);
- rect->UpdateRect(end_pos.x - hw, point_y);
+ rect->UpdateRect(CFX_PointF(end_pos.x + hw, point_y));
+ rect->UpdateRect(CFX_PointF(end_pos.x - hw, point_y));
return;
}
@@ -40,8 +40,8 @@ void UpdateLineEndPoints(CFX_FloatRect* rect,
else
point_x = end_pos.x + hw;
- rect->UpdateRect(point_x, end_pos.y + hw);
- rect->UpdateRect(point_x, end_pos.y - hw);
+ rect->UpdateRect(CFX_PointF(point_x, end_pos.y + hw));
+ rect->UpdateRect(CFX_PointF(point_x, end_pos.y - hw));
return;
}
@@ -51,8 +51,8 @@ void UpdateLineEndPoints(CFX_FloatRect* rect,
float my = end_pos.y + hw * diff.y / ll;
float dx1 = hw * diff.y / ll;
float dy1 = hw * diff.x / ll;
- rect->UpdateRect(mx - dx1, my + dy1);
- rect->UpdateRect(mx + dx1, my - dy1);
+ rect->UpdateRect(CFX_PointF(mx - dx1, my + dy1));
+ rect->UpdateRect(CFX_PointF(mx + dx1, my - dy1));
}
void UpdateLineJoinPoints(CFX_FloatRect* rect,
@@ -76,8 +76,8 @@ void UpdateLineJoinPoints(CFX_FloatRect* rect,
if (bStartVert && bEndVert) {
int start_dir = mid_pos.y > start_pos.y ? 1 : -1;
float point_y = mid_pos.y + half_width * start_dir;
- rect->UpdateRect(mid_pos.x + half_width, point_y);
- rect->UpdateRect(mid_pos.x - half_width, point_y);
+ rect->UpdateRect(CFX_PointF(mid_pos.x + half_width, point_y));
+ rect->UpdateRect(CFX_PointF(mid_pos.x - half_width, point_y));
return;
}
@@ -108,7 +108,7 @@ void UpdateLineJoinPoints(CFX_FloatRect* rect,
else
outside.y = (end_k * outside.x) + end_c - end_dc;
- rect->UpdateRect(outside.x, outside.y);
+ rect->UpdateRect(outside);
return;
}
@@ -124,7 +124,7 @@ void UpdateLineJoinPoints(CFX_FloatRect* rect,
else
outside.y = (start_k * outside.x) + start_c - start_dc;
- rect->UpdateRect(outside.x, outside.y);
+ rect->UpdateRect(outside);
return;
}
@@ -152,7 +152,7 @@ void UpdateLineJoinPoints(CFX_FloatRect* rect,
float join_x = (end_outside_c - start_outside_c) / (start_k - end_k);
float join_y = start_k * join_x + start_outside_c;
- rect->UpdateRect(join_x, join_y);
+ rect->UpdateRect(CFX_PointF(join_x, join_y));
}
} // namespace
@@ -231,9 +231,9 @@ CFX_FloatRect CFX_PathData::GetBoundingBox() const {
return CFX_FloatRect();
CFX_FloatRect rect;
- rect.InitRect(m_Points[0].m_Point.x, m_Points[0].m_Point.y);
+ rect.InitRect(m_Points[0].m_Point);
for (size_t i = 1; i < m_Points.size(); i++)
- rect.UpdateRect(m_Points[i].m_Point.x, m_Points[i].m_Point.y);
+ rect.UpdateRect(m_Points[i].m_Point);
return rect;
}
@@ -256,9 +256,8 @@ CFX_FloatRect CFX_PathData::GetBoundingBox(float line_width,
bJoin = false;
} else {
if (m_Points[iPoint].IsTypeAndOpen(FXPT_TYPE::BezierTo)) {
- rect.UpdateRect(m_Points[iPoint].m_Point.x, m_Points[iPoint].m_Point.y);
- rect.UpdateRect(m_Points[iPoint + 1].m_Point.x,
- m_Points[iPoint + 1].m_Point.y);
+ rect.UpdateRect(m_Points[iPoint].m_Point);
+ rect.UpdateRect(m_Points[iPoint + 1].m_Point);
iPoint += 2;
}
if (iPoint == m_Points.size() - 1 ||