summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 ||