summaryrefslogtreecommitdiff
path: root/xfa/fde/cfde_path.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-02-15 11:07:32 -0500
committerChromium commit bot <commit-bot@chromium.org>2017-02-15 17:47:57 +0000
commite4602321f3175fa5addb6761d0e94f5c2fc93d0c (patch)
tree6671774659645fad6d9ce55a5910b4665a25094f /xfa/fde/cfde_path.cpp
parenteb55885e9a9eec670ed98cbd12dc96d63e6a6623 (diff)
downloadpdfium-e4602321f3175fa5addb6761d0e94f5c2fc93d0c.tar.xz
Cleanup CFX_PathData.
This CL replaces the array of path points with a vector. Cleaning up the usage as required. Change-Id: Ifa386a2c847005fef68af748ebe99c4e08961238 Reviewed-on: https://pdfium-review.googlesource.com/2710 Reviewed-by: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fde/cfde_path.cpp')
-rw-r--r--xfa/fde/cfde_path.cpp68
1 files changed, 13 insertions, 55 deletions
diff --git a/xfa/fde/cfde_path.cpp b/xfa/fde/cfde_path.cpp
index 825de40bfe..0418513972 100644
--- a/xfa/fde/cfde_path.cpp
+++ b/xfa/fde/cfde_path.cpp
@@ -9,70 +9,29 @@
#include "third_party/base/stl_util.h"
#include "xfa/fde/fde_object.h"
-bool CFDE_Path::StartFigure() {
- return CloseFigure();
-}
-
-bool CFDE_Path::CloseFigure() {
- FX_PATHPOINT* pPoint = GetLastPoint();
- if (pPoint)
- pPoint->m_CloseFigure = true;
- return true;
-}
-
-FX_PATHPOINT* CFDE_Path::GetLastPoint() const {
- int32_t iPoints = m_Path.GetPointCount();
- if (iPoints == 0)
- return nullptr;
- return m_Path.GetPoints() + iPoints - 1;
+void CFDE_Path::CloseFigure() {
+ m_Path.ClosePath();
}
bool CFDE_Path::FigureClosed() const {
- FX_PATHPOINT* pPoint = GetLastPoint();
- return pPoint ? pPoint->m_CloseFigure : true;
-}
-
-FX_PATHPOINT* CFDE_Path::AddPoints(int32_t iCount) {
- if (iCount < 1)
- return nullptr;
-
- int32_t iPoints = m_Path.GetPointCount();
- m_Path.AddPointCount(iCount);
- return m_Path.GetPoints() + iPoints;
+ const std::vector<FX_PATHPOINT>& points = m_Path.GetPoints();
+ return points.empty() ? true : points.back().m_CloseFigure;
}
void CFDE_Path::MoveTo(FX_FLOAT fx, FX_FLOAT fy) {
- FX_PATHPOINT* pPoint = AddPoints(1);
- pPoint->m_PointX = fx;
- pPoint->m_PointY = fy;
- pPoint->m_Type = FXPT_TYPE::MoveTo;
- pPoint->m_CloseFigure = false;
+ m_Path.AppendPoint(fx, fy, FXPT_TYPE::MoveTo, false);
}
void CFDE_Path::LineTo(FX_FLOAT fx, FX_FLOAT fy) {
- FX_PATHPOINT* pPoint = AddPoints(1);
- pPoint->m_PointX = fx;
- pPoint->m_PointY = fy;
- pPoint->m_Type = FXPT_TYPE::LineTo;
- pPoint->m_CloseFigure = false;
+ m_Path.AppendPoint(fx, fy, FXPT_TYPE::LineTo, false);
}
void CFDE_Path::BezierTo(const CFX_PointF& p1,
const CFX_PointF& p2,
const CFX_PointF& p3) {
- FX_PATHPOINT* p = AddPoints(3);
- p[0].m_PointX = p1.x;
- p[0].m_PointY = p1.y;
- p[0].m_Type = FXPT_TYPE::BezierTo;
- p[0].m_CloseFigure = false;
- p[1].m_PointX = p2.x;
- p[1].m_PointY = p2.y;
- p[1].m_Type = FXPT_TYPE::BezierTo;
- p[1].m_CloseFigure = false;
- p[2].m_PointX = p3.x;
- p[2].m_PointY = p3.y;
- p[2].m_Type = FXPT_TYPE::BezierTo;
- p[2].m_CloseFigure = false;
+ m_Path.AppendPoint(p1.x, p1.y, FXPT_TYPE::BezierTo, false);
+ m_Path.AppendPoint(p2.x, p2.y, FXPT_TYPE::BezierTo, false);
+ m_Path.AppendPoint(p3.x, p3.y, FXPT_TYPE::BezierTo, false);
}
void CFDE_Path::ArcTo(bool bStart,
@@ -195,9 +154,9 @@ void CFDE_Path::AddEllipse(const CFX_RectF& rect) {
}
void CFDE_Path::AddLine(const CFX_PointF& pt1, const CFX_PointF& pt2) {
- FX_PATHPOINT* pLast = GetLastPoint();
- if (!pLast || FXSYS_fabs(pLast->m_PointX - pt1.x) > 0.001 ||
- FXSYS_fabs(pLast->m_PointY - pt1.y) > 0.001) {
+ std::vector<FX_PATHPOINT>& points = m_Path.GetPoints();
+ if (points.empty() || FXSYS_fabs(points.back().m_PointX - pt1.x) > 0.001 ||
+ FXSYS_fabs(points.back().m_PointY - pt1.y) > 0.001) {
MoveTo(pt1);
}
LineTo(pt2);
@@ -207,8 +166,7 @@ void CFDE_Path::AddPath(const CFDE_Path* pSrc, bool bConnect) {
if (!pSrc)
return;
- int32_t iCount = pSrc->m_Path.GetPointCount();
- if (iCount < 1)
+ if (pSrc->m_Path.GetPoints().empty())
return;
if (bConnect)
LineTo(pSrc->m_Path.GetPointX(0), pSrc->m_Path.GetPointY(0));