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/fxge/win32/cfx_psrenderer.cpp | 23 ++++++++++++----------- core/fxge/win32/fx_win32_device.cpp | 10 +++++----- core/fxge/win32/fx_win32_gdipext.cpp | 15 ++++++++------- 3 files changed, 25 insertions(+), 23 deletions(-) (limited to 'core/fxge/win32') diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp index b62d0cb8f5..c01c4c0060 100644 --- a/core/fxge/win32/cfx_psrenderer.cpp +++ b/core/fxge/win32/cfx_psrenderer.cpp @@ -113,23 +113,24 @@ void CFX_PSRenderer::OutputPath(const CFX_PathData* pPathData, CFX_ByteTextBuf buf; buf.EstimateSize(nPoints * 10); for (int i = 0; i < nPoints; i++) { - uint8_t flag = pPathData->GetFlag(i); + FXPT_TYPE type = pPathData->GetType(i); + bool closing = pPathData->IsClosingFigure(i); FX_FLOAT x = pPathData->GetPointX(i); FX_FLOAT y = pPathData->GetPointY(i); if (pObject2Device) { pObject2Device->Transform(x, y); } buf << x << " " << y; - switch (flag & FXPT_TYPE) { - case FXPT_MOVETO: + switch (type) { + case FXPT_TYPE::MoveTo: buf << " m "; break; - case FXPT_LINETO: + case FXPT_TYPE::LineTo: buf << " l "; - if (flag & FXPT_CLOSEFIGURE) + if (closing) buf << "h "; break; - case FXPT_BEZIERTO: { + case FXPT_TYPE::BezierTo: { FX_FLOAT x1 = pPathData->GetPointX(i + 1); FX_FLOAT x2 = pPathData->GetPointX(i + 2); FX_FLOAT y1 = pPathData->GetPointY(i + 1); @@ -139,7 +140,7 @@ void CFX_PSRenderer::OutputPath(const CFX_PathData* pPathData, pObject2Device->Transform(x2, y2); } buf << " " << x1 << " " << y1 << " " << x2 << " " << y2 << " c"; - if (flag & FXPT_CLOSEFIGURE) + if (closing) buf << " h"; buf << "\n"; i += 2; @@ -599,16 +600,16 @@ void CFX_PSRenderer::FindPSFontGlyph(CFX_FaceCache* pFaceCache, << "{n "; for (int p = 0; p < TransformedPath.GetPointCount(); p++) { FX_FLOAT x = TransformedPath.GetPointX(p), y = TransformedPath.GetPointY(p); - switch (TransformedPath.GetFlag(p) & FXPT_TYPE) { - case FXPT_MOVETO: { + switch (TransformedPath.GetType(p)) { + case FXPT_TYPE::MoveTo: { buf << x << " " << y << " m\n"; break; } - case FXPT_LINETO: { + case FXPT_TYPE::LineTo: { buf << x << " " << y << " l\n"; break; } - case FXPT_BEZIERTO: { + case FXPT_TYPE::BezierTo: { buf << x << " " << y << " " << TransformedPath.GetPointX(p + 1) << " " << TransformedPath.GetPointY(p + 1) << " " << TransformedPath.GetPointX(p + 2) << " " diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index c673a18d2d..223f64d041 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -174,16 +174,16 @@ void SetPathToDC(HDC hDC, pMatrix->Transform(posx, posy); } int screen_x = FXSYS_round(posx), screen_y = FXSYS_round(posy); - int point_type = pPoints[i].m_Flag & FXPT_TYPE; - if (point_type == PT_MOVETO) { + FXPT_TYPE point_type = pPoints[i].m_Type; + if (point_type == FXPT_TYPE::MoveTo) { MoveToEx(hDC, screen_x, screen_y, nullptr); - } else if (point_type == PT_LINETO) { + } else if (point_type == FXPT_TYPE::LineTo) { if (pPoints[i].m_PointY == pPoints[i - 1].m_PointY && pPoints[i].m_PointX == pPoints[i - 1].m_PointX) { screen_x++; } LineTo(hDC, screen_x, screen_y); - } else if (point_type == PT_BEZIERTO) { + } else if (point_type == FXPT_TYPE::BezierTo) { POINT lppt[3]; lppt[0].x = screen_x; lppt[0].y = screen_y; @@ -204,7 +204,7 @@ void SetPathToDC(HDC hDC, PolyBezierTo(hDC, lppt, 3); i += 2; } - if (pPoints[i].m_Flag & PT_CLOSEFIGURE) { + if (pPoints[i].m_CloseFigure) { CloseFigure(hDC); } } diff --git a/core/fxge/win32/fx_win32_gdipext.cpp b/core/fxge/win32/fx_win32_gdipext.cpp index cd18525b00..65f7b3e732 100644 --- a/core/fxge/win32/fx_win32_gdipext.cpp +++ b/core/fxge/win32/fx_win32_gdipext.cpp @@ -1151,16 +1151,17 @@ bool CGdiplusExt::DrawPath(HDC hDC, if (y < -50000 * 1.0f) { points[i].Y = -50000 * 1.0f; } - int point_type = pPoints[i].m_Flag & FXPT_TYPE; - if (point_type == FXPT_MOVETO) { + FXPT_TYPE point_type = pPoints[i].m_Type; + if (point_type == FXPT_TYPE::MoveTo) { types[i] = PathPointTypeStart; nSubPathes++; bSubClose = false; startpoint = i; - } else if (point_type == FXPT_LINETO) { + } else if (point_type == FXPT_TYPE::LineTo) { types[i] = PathPointTypeLine; - if (pPoints[i - 1].m_Flag == FXPT_MOVETO && - (i == nPoints - 1 || pPoints[i + 1].m_Flag == FXPT_MOVETO) && + if (pPoints[i - 1].IsTypeAndOpen(FXPT_TYPE::MoveTo) && + (i == nPoints - 1 || + pPoints[i + 1].IsTypeAndOpen(FXPT_TYPE::MoveTo)) && points[i].Y == points[i - 1].Y && points[i].X == points[i - 1].X) { points[i].X += 0.01f; continue; @@ -1169,11 +1170,11 @@ bool CGdiplusExt::DrawPath(HDC hDC, points[i].Y != points[i - 1].Y) { bSmooth = true; } - } else if (point_type == FXPT_BEZIERTO) { + } else if (point_type == FXPT_TYPE::BezierTo) { types[i] = PathPointTypeBezier; bSmooth = true; } - if (pPoints[i].m_Flag & FXPT_CLOSEFIGURE) { + if (pPoints[i].m_CloseFigure) { if (bSubClose) { types[pos_subclose] &= ~PathPointTypeCloseSubpath; } else { -- cgit v1.2.3