Chromium Code Reviews| Index: xfa/fde/cfde_path.cpp |
| diff --git a/xfa/fde/cfde_path.cpp b/xfa/fde/cfde_path.cpp |
| index 23aad5054975c7cda62cf11e99c2fc47b735cf3f..f937e1326f6be78b26bbd252a90eae14cd93583b 100644 |
| --- a/xfa/fde/cfde_path.cpp |
| +++ b/xfa/fde/cfde_path.cpp |
| @@ -6,6 +6,7 @@ |
| #include "xfa/fde/cfde_path.h" |
| +#include "third_party/base/stl_util.h" |
| #include "xfa/fde/fde_object.h" |
| bool CFDE_Path::StartFigure() { |
| @@ -106,39 +107,39 @@ void CFDE_Path::ArcTo(bool bStart, |
| CFX_PointF(cx + rx * cos_beta, cy + ry * sin_beta)); |
| } |
| -void CFDE_Path::AddBezier(const CFX_PointsF& points) { |
| - if (points.GetSize() != 4) |
| +void CFDE_Path::AddBezier(const std::vector<CFX_PointF>& points) { |
| + if (points.size() != 4) |
| return; |
| - const CFX_PointF* p = points.GetData(); |
| + const CFX_PointF* p = points.data(); |
|
npm
2017/01/20 19:37:33
Why do we need this variable? points[0] etc could
Tom Sepez
2017/01/20 20:01:15
Prolly because in the old way, this avoided a boun
|
| MoveTo(p[0]); |
| BezierTo(p[1], p[2], p[3]); |
| } |
| -void CFDE_Path::AddBeziers(const CFX_PointsF& points) { |
| - int32_t iCount = points.GetSize(); |
| +void CFDE_Path::AddBeziers(const std::vector<CFX_PointF>& points) { |
| + int32_t iCount = points.size(); |
| if (iCount < 4) |
| return; |
| - const CFX_PointF* p = points.GetData(); |
| + const CFX_PointF* p = points.data(); |
| const CFX_PointF* pEnd = p + iCount; |
| MoveTo(p[0]); |
| for (++p; p <= pEnd - 3; p += 3) |
|
npm
2017/01/20 19:37:33
Kind of similarly here, could be simplified
Tom Sepez
2017/01/20 20:01:15
Left as-is to avoid thinking about the logic.
|
| BezierTo(p[0], p[1], p[2]); |
| } |
| -void CFDE_Path::GetCurveTangents(const CFX_PointsF& points, |
| - CFX_PointsF& tangents, |
| +void CFDE_Path::GetCurveTangents(const std::vector<CFX_PointF>& points, |
| + std::vector<CFX_PointF>& tangents, |
|
npm
2017/01/20 19:37:33
It would be better to have a pointer here
Tom Sepez
2017/01/20 20:01:15
Done.
|
| bool bClosed, |
| FX_FLOAT fTension) const { |
| - int32_t iCount = points.GetSize(); |
| - tangents.SetSize(iCount); |
| + int32_t iCount = pdfium::CollectionSize<int32_t>(points); |
| + tangents.resize(iCount); |
| if (iCount < 3) |
| return; |
| FX_FLOAT fCoefficient = fTension / 3.0f; |
| - const CFX_PointF* pPoints = points.GetData(); |
| - CFX_PointF* pTangents = tangents.GetData(); |
| + const CFX_PointF* pPoints = points.data(); |
| + CFX_PointF* pTangents = tangents.data(); |
| for (int32_t i = 0; i < iCount; ++i) { |
| int32_t r = i + 1; |
| int32_t s = i - 1; |
| @@ -152,17 +153,17 @@ void CFDE_Path::GetCurveTangents(const CFX_PointsF& points, |
| } |
| } |
| -void CFDE_Path::AddCurve(const CFX_PointsF& points, |
| +void CFDE_Path::AddCurve(const std::vector<CFX_PointF>& points, |
| bool bClosed, |
| FX_FLOAT fTension) { |
| - int32_t iLast = points.GetUpperBound(); |
| + int32_t iLast = pdfium::CollectionSize<int32_t>(points) - 1; |
| if (iLast < 1) |
| return; |
| - CFX_PointsF tangents; |
| + std::vector<CFX_PointF> tangents; |
| GetCurveTangents(points, tangents, bClosed, fTension); |
| - const CFX_PointF* pPoints = points.GetData(); |
| - CFX_PointF* pTangents = tangents.GetData(); |
| + const CFX_PointF* pPoints = points.data(); |
| + CFX_PointF* pTangents = tangents.data(); |
| MoveTo(pPoints[0]); |
| for (int32_t i = 0; i < iLast; ++i) { |
| BezierTo(CFX_PointF(pPoints[i].x + pTangents[i].x, |
| @@ -214,13 +215,13 @@ void CFDE_Path::AddPath(const CFDE_Path* pSrc, bool bConnect) { |
| m_Path.Append(&pSrc->m_Path, nullptr); |
| } |
| -void CFDE_Path::AddPolygon(const CFX_PointsF& points) { |
| - int32_t iCount = points.GetSize(); |
| +void CFDE_Path::AddPolygon(const std::vector<CFX_PointF>& points) { |
| + size_t iCount = points.size(); |
| if (iCount < 2) |
| return; |
| AddLines(points); |
| - const CFX_PointF* p = points.GetData(); |
| + const CFX_PointF* p = points.data(); |
| if (FXSYS_fabs(p[0].x - p[iCount - 1].x) < 0.01f || |
| FXSYS_fabs(p[0].y - p[iCount - 1].y) < 0.01f) { |
| LineTo(p[0]); |
| @@ -228,12 +229,12 @@ void CFDE_Path::AddPolygon(const CFX_PointsF& points) { |
| CloseFigure(); |
| } |
| -void CFDE_Path::AddLines(const CFX_PointsF& points) { |
| - int32_t iCount = points.GetSize(); |
| +void CFDE_Path::AddLines(const std::vector<CFX_PointF>& points) { |
| + size_t iCount = points.size(); |
| if (iCount < 2) |
| return; |
| - const CFX_PointF* p = points.GetData(); |
| + const CFX_PointF* p = points.data(); |
| const CFX_PointF* pEnd = p + iCount; |
| MoveTo(p[0]); |
| for (++p; p < pEnd; ++p) |