From 79365f7e3d2d62138e79e4403d4959318776c139 Mon Sep 17 00:00:00 2001 From: Nicolas Pena Date: Tue, 7 Feb 2017 14:21:36 -0500 Subject: Use enum class for PathPoint types. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This hopefully makes it less confusing what the description of a point is. Currently we have defines for the types, which is confusing because a point can only be one of the three. And it is mixed up with whether the point is closing a figure or not. Change-Id: Icd71355d69c77b3d52ca78e03bc379081ff87753 Reviewed-on: https://pdfium-review.googlesource.com/2552 Commit-Queue: Nicolás Peña Reviewed-by: Tom Sepez --- core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp') diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp index 9dba6e0ceb..a5bd741cc0 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp @@ -155,15 +155,16 @@ void CPDF_PageContentGenerator::ProcessPath(CFX_ByteTextBuf* buf, if (i > 0) *buf << " "; *buf << pPoints[i].m_PointX << " " << pPoints[i].m_PointY; - int pointFlag = pPoints[i].m_Flag; - if (pointFlag == FXPT_MOVETO) { + FXPT_TYPE pointType = pPoints[i].m_Type; + if (pointType == FXPT_TYPE::MoveTo) { *buf << " m"; - } else if (pointFlag & FXPT_LINETO) { + } else if (pointType == FXPT_TYPE::LineTo) { *buf << " l"; - } else if (pointFlag & FXPT_BEZIERTO) { - if (i + 2 >= numPoints || pPoints[i].m_Flag != FXPT_BEZIERTO || - pPoints[i + 1].m_Flag != FXPT_BEZIERTO || - (pPoints[i + 2].m_Flag & FXPT_BEZIERTO) == 0) { + } else if (pointType == FXPT_TYPE::BezierTo) { + if (i + 2 >= numPoints || + !pPoints[i].IsTypeAndOpen(FXPT_TYPE::BezierTo) || + !pPoints[i + 1].IsTypeAndOpen(FXPT_TYPE::BezierTo) || + pPoints[i + 2].m_Type != FXPT_TYPE::BezierTo) { // If format is not supported, close the path and paint *buf << " h"; break; @@ -171,11 +172,9 @@ void CPDF_PageContentGenerator::ProcessPath(CFX_ByteTextBuf* buf, *buf << " " << pPoints[i + 1].m_PointX << " " << pPoints[i + 1].m_PointY << " " << pPoints[i + 2].m_PointX << " " << pPoints[i + 2].m_PointY << " c"; - if (pPoints[i + 2].m_Flag & FXPT_CLOSEFIGURE) - *buf << " h"; i += 2; } - if (pointFlag & FXPT_CLOSEFIGURE) + if (pPoints[i].m_CloseFigure) *buf << " h"; } } -- cgit v1.2.3