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 ++-- .../edit/cpdf_pagecontentgenerator_unittest.cpp | 51 ++++++---- core/fpdfapi/page/cpdf_path.cpp | 4 - core/fpdfapi/page/cpdf_path.h | 1 - core/fpdfapi/page/cpdf_streamcontentparser.cpp | 77 ++++++++------- core/fpdfapi/page/cpdf_streamcontentparser.h | 2 +- core/fpdfapi/render/cpdf_renderstatus.cpp | 9 +- core/fxge/agg/fx_agg_driver.cpp | 15 +-- core/fxge/cfx_pathdata.h | 18 +++- core/fxge/cfx_renderdevice.h | 8 +- core/fxge/ge/cfx_font.cpp | 37 +++++--- core/fxge/ge/cfx_pathdata.cpp | 105 ++++++++++++--------- core/fxge/ge/cfx_renderdevice.cpp | 4 +- core/fxge/skia/fx_skia_device.cpp | 10 +- core/fxge/win32/cfx_psrenderer.cpp | 23 ++--- core/fxge/win32/fx_win32_device.cpp | 10 +- core/fxge/win32/fx_win32_gdipext.cpp | 15 +-- fpdfsdk/formfiller/cffl_interactiveformfiller.cpp | 13 ++- fpdfsdk/fpdf_transformpage.cpp | 12 +-- fpdfsdk/pdfwindow/PWL_Caret.cpp | 8 +- fpdfsdk/pdfwindow/PWL_ComboBox.cpp | 8 +- fpdfsdk/pdfwindow/PWL_Edit.cpp | 8 +- fpdfsdk/pdfwindow/PWL_ScrollBar.cpp | 16 ++-- fpdfsdk/pdfwindow/PWL_Utils.cpp | 61 ++++++------ xfa/fde/cfde_path.cpp | 19 ++-- xfa/fxgraphics/cfx_path_generator.cpp | 53 ++++++----- 26 files changed, 345 insertions(+), 261 deletions(-) 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"; } } diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp index 41e61b3bab..3267f5218c 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp @@ -47,16 +47,20 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessRect) { FX_PATHPOINT* pPoints = pPathObj->m_Path.GetMutablePoints(); pPoints[0].m_PointX = 0; pPoints[0].m_PointY = 0; - pPoints[0].m_Flag = FXPT_MOVETO; + pPoints[0].m_Type = FXPT_TYPE::MoveTo; + pPoints[0].m_CloseFigure = false; pPoints[1].m_PointX = 5.2f; pPoints[1].m_PointY = 0; - pPoints[1].m_Flag = FXPT_LINETO; + pPoints[1].m_Type = FXPT_TYPE::LineTo; + pPoints[1].m_CloseFigure = false; pPoints[2].m_PointX = 5.2f; pPoints[2].m_PointY = 3.78f; - pPoints[2].m_Flag = FXPT_LINETO; + pPoints[2].m_Type = FXPT_TYPE::LineTo; + pPoints[2].m_CloseFigure = false; pPoints[3].m_PointX = 0; pPoints[3].m_PointY = 3.78f; - pPoints[3].m_Flag = FXPT_LINETO | FXPT_CLOSEFIGURE; + pPoints[3].m_Type = FXPT_TYPE::LineTo; + pPoints[3].m_CloseFigure = true; pPathObj->m_FillType = 0; pPathObj->m_bStroke = false; buf.Clear(); @@ -70,34 +74,44 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessPath) { FX_PATHPOINT* pPoints = pPathObj->m_Path.GetMutablePoints(); pPoints[0].m_PointX = 3.102f; pPoints[0].m_PointY = 4.67f; - pPoints[0].m_Flag = FXPT_MOVETO; + pPoints[0].m_Type = FXPT_TYPE::MoveTo; + pPoints[0].m_CloseFigure = false; pPoints[1].m_PointX = 5.45f; pPoints[1].m_PointY = 0.29f; - pPoints[1].m_Flag = FXPT_LINETO; + pPoints[1].m_Type = FXPT_TYPE::LineTo; + pPoints[1].m_CloseFigure = false; pPoints[2].m_PointX = 4.24f; pPoints[2].m_PointY = 3.15f; - pPoints[2].m_Flag = FXPT_BEZIERTO; + pPoints[2].m_Type = FXPT_TYPE::BezierTo; + pPoints[2].m_CloseFigure = false; pPoints[3].m_PointX = 4.65f; pPoints[3].m_PointY = 2.98f; - pPoints[3].m_Flag = FXPT_BEZIERTO; + pPoints[3].m_Type = FXPT_TYPE::BezierTo; + pPoints[3].m_CloseFigure = false; pPoints[4].m_PointX = 3.456f; pPoints[4].m_PointY = 0.24f; - pPoints[4].m_Flag = FXPT_BEZIERTO; + pPoints[4].m_Type = FXPT_TYPE::BezierTo; + pPoints[4].m_CloseFigure = false; pPoints[5].m_PointX = 10.6f; pPoints[5].m_PointY = 11.15f; - pPoints[5].m_Flag = FXPT_LINETO; + pPoints[5].m_Type = FXPT_TYPE::LineTo; + pPoints[5].m_CloseFigure = false; pPoints[6].m_PointX = 11; pPoints[6].m_PointY = 12.5f; - pPoints[6].m_Flag = FXPT_LINETO; + pPoints[6].m_Type = FXPT_TYPE::LineTo; + pPoints[6].m_CloseFigure = false; pPoints[7].m_PointX = 11.46f; pPoints[7].m_PointY = 12.67f; - pPoints[7].m_Flag = FXPT_BEZIERTO; + pPoints[7].m_Type = FXPT_TYPE::BezierTo; + pPoints[7].m_CloseFigure = false; pPoints[8].m_PointX = 11.84f; pPoints[8].m_PointY = 12.96f; - pPoints[8].m_Flag = FXPT_BEZIERTO; + pPoints[8].m_Type = FXPT_TYPE::BezierTo; + pPoints[8].m_CloseFigure = false; pPoints[9].m_PointX = 12; pPoints[9].m_PointY = 13.64f; - pPoints[9].m_Flag = FXPT_BEZIERTO | FXPT_CLOSEFIGURE; + pPoints[9].m_Type = FXPT_TYPE::BezierTo; + pPoints[9].m_CloseFigure = true; pPathObj->m_FillType = FXFILL_WINDING; pPathObj->m_bStroke = false; auto pTestPage = pdfium::MakeUnique(nullptr, nullptr, false); @@ -116,13 +130,16 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessGraphics) { FX_PATHPOINT* pPoints = pPathObj->m_Path.GetMutablePoints(); pPoints[0].m_PointX = 1; pPoints[0].m_PointY = 2; - pPoints[0].m_Flag = FXPT_MOVETO; + pPoints[0].m_Type = FXPT_TYPE::MoveTo; + pPoints[0].m_CloseFigure = false; pPoints[1].m_PointX = 3; pPoints[1].m_PointY = 4; - pPoints[1].m_Flag = FXPT_LINETO; + pPoints[1].m_Type = FXPT_TYPE::LineTo; + pPoints[1].m_CloseFigure = false; pPoints[2].m_PointX = 5; pPoints[2].m_PointY = 6; - pPoints[2].m_Flag = FXPT_LINETO | FXPT_CLOSEFIGURE; + pPoints[2].m_Type = FXPT_TYPE::LineTo; + pPoints[2].m_CloseFigure = true; pPathObj->m_FillType = FXFILL_WINDING; pPathObj->m_bStroke = true; FX_FLOAT rgb[3] = {0.5f, 0.7f, 0.35f}; diff --git a/core/fpdfapi/page/cpdf_path.cpp b/core/fpdfapi/page/cpdf_path.cpp index 2bfda75f56..8151ae46d7 100644 --- a/core/fpdfapi/page/cpdf_path.cpp +++ b/core/fpdfapi/page/cpdf_path.cpp @@ -28,10 +28,6 @@ FX_PATHPOINT* CPDF_Path::GetMutablePoints() { return m_Ref.GetPrivateCopy()->GetPoints(); } -int CPDF_Path::GetFlag(int index) const { - return m_Ref.GetObject()->GetFlag(index); -} - FX_FLOAT CPDF_Path::GetPointX(int index) const { return m_Ref.GetObject()->GetPointX(index); } diff --git a/core/fpdfapi/page/cpdf_path.h b/core/fpdfapi/page/cpdf_path.h index 407905e429..252be2673c 100644 --- a/core/fpdfapi/page/cpdf_path.h +++ b/core/fpdfapi/page/cpdf_path.h @@ -27,7 +27,6 @@ class CPDF_Path { const FX_PATHPOINT* GetPoints() const; FX_PATHPOINT* GetMutablePoints(); - int GetFlag(int index) const; FX_FLOAT GetPointX(int index) const; FX_FLOAT GetPointY(int index) const; CFX_FloatRect GetBoundingBox() const; diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp index 0e78612bc9..3dec01a52e 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp @@ -586,7 +586,7 @@ void CPDF_StreamContentParser::Handle_FillStrokePath() { } void CPDF_StreamContentParser::Handle_CloseEOFillStrokePath() { - AddPathPoint(m_PathStartX, m_PathStartY, FXPT_LINETO | FXPT_CLOSEFIGURE); + AddPathPoint(m_PathStartX, m_PathStartY, FXPT_TYPE::LineTo, true); AddPathObject(FXFILL_ALTERNATE, true); } @@ -682,9 +682,9 @@ void CPDF_StreamContentParser::Handle_BeginText() { } void CPDF_StreamContentParser::Handle_CurveTo_123() { - AddPathPoint(GetNumber(5), GetNumber(4), FXPT_BEZIERTO); - AddPathPoint(GetNumber(3), GetNumber(2), FXPT_BEZIERTO); - AddPathPoint(GetNumber(1), GetNumber(0), FXPT_BEZIERTO); + AddPathPoint(GetNumber(5), GetNumber(4), FXPT_TYPE::BezierTo, false); + AddPathPoint(GetNumber(3), GetNumber(2), FXPT_TYPE::BezierTo, false); + AddPathPoint(GetNumber(1), GetNumber(0), FXPT_TYPE::BezierTo, false); } void CPDF_StreamContentParser::Handle_ConcatMatrix() { @@ -887,9 +887,9 @@ void CPDF_StreamContentParser::Handle_ClosePath() { return; } if (m_PathStartX != m_PathCurrentX || m_PathStartY != m_PathCurrentY) { - AddPathPoint(m_PathStartX, m_PathStartY, FXPT_LINETO | FXPT_CLOSEFIGURE); - } else if (m_pPathPoints[m_PathPointCount - 1].m_Flag != FXPT_MOVETO) { - m_pPathPoints[m_PathPointCount - 1].m_Flag |= FXPT_CLOSEFIGURE; + AddPathPoint(m_PathStartX, m_PathStartY, FXPT_TYPE::LineTo, true); + } else if (m_pPathPoints[m_PathPointCount - 1].m_Type != FXPT_TYPE::MoveTo) { + m_pPathPoints[m_PathPointCount - 1].m_CloseFigure = true; } } @@ -937,14 +937,14 @@ void CPDF_StreamContentParser::Handle_LineTo() { if (m_ParamCount != 2) return; - AddPathPoint(GetNumber(1), GetNumber(0), FXPT_LINETO); + AddPathPoint(GetNumber(1), GetNumber(0), FXPT_TYPE::LineTo, false); } void CPDF_StreamContentParser::Handle_MoveTo() { if (m_ParamCount != 2) return; - AddPathPoint(GetNumber(1), GetNumber(0), FXPT_MOVETO); + AddPathPoint(GetNumber(1), GetNumber(0), FXPT_TYPE::MoveTo, false); ParsePathObject(); } @@ -982,11 +982,11 @@ void CPDF_StreamContentParser::AddPathRect(FX_FLOAT x, FX_FLOAT y, FX_FLOAT w, FX_FLOAT h) { - AddPathPoint(x, y, FXPT_MOVETO); - AddPathPoint(x + w, y, FXPT_LINETO); - AddPathPoint(x + w, y + h, FXPT_LINETO); - AddPathPoint(x, y + h, FXPT_LINETO); - AddPathPoint(x, y, FXPT_LINETO | FXPT_CLOSEFIGURE); + AddPathPoint(x, y, FXPT_TYPE::MoveTo, false); + AddPathPoint(x + w, y, FXPT_TYPE::LineTo, false); + AddPathPoint(x + w, y + h, FXPT_TYPE::LineTo, false); + AddPathPoint(x, y + h, FXPT_TYPE::LineTo, false); + AddPathPoint(x, y, FXPT_TYPE::LineTo, true); } void CPDF_StreamContentParser::Handle_SetRGBColor_Fill() { @@ -1416,9 +1416,9 @@ void CPDF_StreamContentParser::Handle_MoveToNextLine() { } void CPDF_StreamContentParser::Handle_CurveTo_23() { - AddPathPoint(m_PathCurrentX, m_PathCurrentY, FXPT_BEZIERTO); - AddPathPoint(GetNumber(3), GetNumber(2), FXPT_BEZIERTO); - AddPathPoint(GetNumber(1), GetNumber(0), FXPT_BEZIERTO); + AddPathPoint(m_PathCurrentX, m_PathCurrentY, FXPT_TYPE::BezierTo, false); + AddPathPoint(GetNumber(3), GetNumber(2), FXPT_TYPE::BezierTo, false); + AddPathPoint(GetNumber(1), GetNumber(0), FXPT_TYPE::BezierTo, false); } void CPDF_StreamContentParser::Handle_SetLineWidth() { @@ -1434,9 +1434,9 @@ void CPDF_StreamContentParser::Handle_EOClip() { } void CPDF_StreamContentParser::Handle_CurveTo_13() { - AddPathPoint(GetNumber(3), GetNumber(2), FXPT_BEZIERTO); - AddPathPoint(GetNumber(1), GetNumber(0), FXPT_BEZIERTO); - AddPathPoint(GetNumber(1), GetNumber(0), FXPT_BEZIERTO); + AddPathPoint(GetNumber(3), GetNumber(2), FXPT_TYPE::BezierTo, false); + AddPathPoint(GetNumber(1), GetNumber(0), FXPT_TYPE::BezierTo, false); + AddPathPoint(GetNumber(1), GetNumber(0), FXPT_TYPE::BezierTo, false); } void CPDF_StreamContentParser::Handle_NextLineShowText() { @@ -1452,14 +1452,17 @@ void CPDF_StreamContentParser::Handle_NextLineShowText_Space() { void CPDF_StreamContentParser::Handle_Invalid() {} -void CPDF_StreamContentParser::AddPathPoint(FX_FLOAT x, FX_FLOAT y, int flag) { +void CPDF_StreamContentParser::AddPathPoint(FX_FLOAT x, + FX_FLOAT y, + FXPT_TYPE type, + bool close) { m_PathCurrentX = x; m_PathCurrentY = y; - if (flag == FXPT_MOVETO) { + if (type == FXPT_TYPE::MoveTo && !close) { m_PathStartX = x; m_PathStartY = y; if (m_PathPointCount && - m_pPathPoints[m_PathPointCount - 1].m_Flag == FXPT_MOVETO) { + m_pPathPoints[m_PathPointCount - 1].IsTypeAndOpen(FXPT_TYPE::MoveTo)) { m_pPathPoints[m_PathPointCount - 1].m_PointX = x; m_pPathPoints[m_PathPointCount - 1].m_PointY = y; return; @@ -1479,7 +1482,8 @@ void CPDF_StreamContentParser::AddPathPoint(FX_FLOAT x, FX_FLOAT y, int flag) { m_pPathPoints = pNewPoints; m_PathAllocSize = newsize; } - m_pPathPoints[m_PathPointCount - 1].m_Flag = flag; + m_pPathPoints[m_PathPointCount - 1].m_Type = type; + m_pPathPoints[m_PathPointCount - 1].m_CloseFigure = close; m_pPathPoints[m_PathPointCount - 1].m_PointX = x; m_pPathPoints[m_PathPointCount - 1].m_PointY = y; } @@ -1498,7 +1502,7 @@ void CPDF_StreamContentParser::AddPathObject(int FillType, bool bStroke) { return; } if (PathPointCount && - m_pPathPoints[PathPointCount - 1].m_Flag == FXPT_MOVETO) { + m_pPathPoints[PathPointCount - 1].IsTypeAndOpen(FXPT_TYPE::MoveTo)) { PathPointCount--; } CPDF_Path Path; @@ -1576,29 +1580,30 @@ void CPDF_StreamContentParser::ParsePathObject() { if (len == 1) { switch (strc[0]) { case kPathOperatorSubpath: - AddPathPoint(params[0], params[1], FXPT_MOVETO); + AddPathPoint(params[0], params[1], FXPT_TYPE::MoveTo, false); nParams = 0; break; case kPathOperatorLine: - AddPathPoint(params[0], params[1], FXPT_LINETO); + AddPathPoint(params[0], params[1], FXPT_TYPE::LineTo, false); nParams = 0; break; case kPathOperatorCubicBezier1: - AddPathPoint(params[0], params[1], FXPT_BEZIERTO); - AddPathPoint(params[2], params[3], FXPT_BEZIERTO); - AddPathPoint(params[4], params[5], FXPT_BEZIERTO); + AddPathPoint(params[0], params[1], FXPT_TYPE::BezierTo, false); + AddPathPoint(params[2], params[3], FXPT_TYPE::BezierTo, false); + AddPathPoint(params[4], params[5], FXPT_TYPE::BezierTo, false); nParams = 0; break; case kPathOperatorCubicBezier2: - AddPathPoint(m_PathCurrentX, m_PathCurrentY, FXPT_BEZIERTO); - AddPathPoint(params[0], params[1], FXPT_BEZIERTO); - AddPathPoint(params[2], params[3], FXPT_BEZIERTO); + AddPathPoint(m_PathCurrentX, m_PathCurrentY, FXPT_TYPE::BezierTo, + false); + AddPathPoint(params[0], params[1], FXPT_TYPE::BezierTo, false); + AddPathPoint(params[2], params[3], FXPT_TYPE::BezierTo, false); nParams = 0; break; case kPathOperatorCubicBezier3: - AddPathPoint(params[0], params[1], FXPT_BEZIERTO); - AddPathPoint(params[2], params[3], FXPT_BEZIERTO); - AddPathPoint(params[2], params[3], FXPT_BEZIERTO); + AddPathPoint(params[0], params[1], FXPT_TYPE::BezierTo, false); + AddPathPoint(params[2], params[3], FXPT_TYPE::BezierTo, false); + AddPathPoint(params[2], params[3], FXPT_TYPE::BezierTo, false); nParams = 0; break; case kPathOperatorClosePath: diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.h b/core/fpdfapi/page/cpdf_streamcontentparser.h index e23ae8ea99..ca7ea7c106 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.h +++ b/core/fpdfapi/page/cpdf_streamcontentparser.h @@ -96,7 +96,7 @@ class CPDF_StreamContentParser { void ConvertTextSpace(FX_FLOAT& x, FX_FLOAT& y); void OnChangeTextMatrix(); void ParsePathObject(); - void AddPathPoint(FX_FLOAT x, FX_FLOAT y, int flag); + void AddPathPoint(FX_FLOAT x, FX_FLOAT y, FXPT_TYPE type, bool close); void AddPathRect(FX_FLOAT x, FX_FLOAT y, FX_FLOAT w, FX_FLOAT h); void AddPathObject(int FillType, bool bStroke); CPDF_ImageObject* AddImage(std::unique_ptr pStream); diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index 35d061616b..8fe7a31ce4 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -816,9 +816,12 @@ void DrawCoonPatchMeshes( patch.fill_mode = fill_mode; patch.path.SetPointCount(13); FX_PATHPOINT* pPoints = patch.path.GetPoints(); - pPoints[0].m_Flag = FXPT_MOVETO; - for (int i = 1; i < 13; i++) - pPoints[i].m_Flag = FXPT_BEZIERTO; + pPoints[0].m_Type = FXPT_TYPE::MoveTo; + pPoints[0].m_CloseFigure = false; + for (int i = 1; i < 13; i++) { + pPoints[i].m_Type = FXPT_TYPE::BezierTo; + pPoints[i].m_CloseFigure = false; + } CFX_PointF coords[16]; int point_count = type == kTensorProductPatchMeshShading ? 16 : 12; while (!stream.BitStream()->IsEOF()) { diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp index 94fe72d301..fa361547a9 100644 --- a/core/fxge/agg/fx_agg_driver.cpp +++ b/core/fxge/agg/fx_agg_driver.cpp @@ -281,18 +281,19 @@ void CAgg_PathData::BuildPath(const CFX_PathData* pPathData, pObject2Device->Transform(x, y); } HardClip(x, y); - 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) { m_PathData.move_to(x, y); - } else if (point_type == FXPT_LINETO) { - if (pPoints[i - 1].m_Flag == FXPT_MOVETO && - (i == nPoints - 1 || pPoints[i + 1].m_Flag == FXPT_MOVETO) && + } else if (point_type == FXPT_TYPE::LineTo) { + if (pPoints[i - 1].IsTypeAndOpen(FXPT_TYPE::MoveTo) && + (i == nPoints - 1 || + pPoints[i + 1].IsTypeAndOpen(FXPT_TYPE::MoveTo)) && pPoints[i].m_PointX == pPoints[i - 1].m_PointX && pPoints[i].m_PointY == pPoints[i - 1].m_PointY) { x += 1; } m_PathData.line_to(x, y); - } else if (point_type == FXPT_BEZIERTO) { + } else if (point_type == FXPT_TYPE::BezierTo) { FX_FLOAT x0 = pPoints[i - 1].m_PointX, y0 = pPoints[i - 1].m_PointY; FX_FLOAT x2 = pPoints[i + 1].m_PointX, y2 = pPoints[i + 1].m_PointY; FX_FLOAT x3 = pPoints[i + 2].m_PointX, y3 = pPoints[i + 2].m_PointY; @@ -308,7 +309,7 @@ void CAgg_PathData::BuildPath(const CFX_PathData* pPathData, i += 2; m_PathData.add_path_curve(curve); } - if (pPoints[i].m_Flag & FXPT_CLOSEFIGURE) { + if (pPoints[i].m_CloseFigure) { m_PathData.end_poly(); } } diff --git a/core/fxge/cfx_pathdata.h b/core/fxge/cfx_pathdata.h index 3e0e11c4ee..46fdfeb740 100644 --- a/core/fxge/cfx_pathdata.h +++ b/core/fxge/cfx_pathdata.h @@ -12,9 +12,14 @@ #include "core/fxge/cfx_renderdevice.h" struct FX_PATHPOINT { + bool IsTypeAndOpen(FXPT_TYPE type) const { + return m_Type == type && !m_CloseFigure; + } + FX_FLOAT m_PointX; FX_FLOAT m_PointY; - int m_Flag; + FXPT_TYPE m_Type; + bool m_CloseFigure; }; class CFX_PathData { @@ -24,7 +29,10 @@ class CFX_PathData { ~CFX_PathData(); int GetPointCount() const { return m_PointCount; } - int GetFlag(int index) const { return m_pPoints[index].m_Flag; } + FXPT_TYPE GetType(int index) const { return m_pPoints[index].m_Type; } + bool IsClosingFigure(int index) const { + return m_pPoints[index].m_CloseFigure; + } FX_FLOAT GetPointX(int index) const { return m_pPoints[index].m_PointX; } FX_FLOAT GetPointY(int index) const { return m_pPoints[index].m_PointY; } FX_PATHPOINT* GetPoints() const { return m_pPoints; } @@ -43,7 +51,11 @@ class CFX_PathData { bool IsRect(const CFX_Matrix* pMatrix, CFX_FloatRect* rect) const; void Append(const CFX_PathData* pSrc, const CFX_Matrix* pMatrix); void AppendRect(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top); - void SetPoint(int index, FX_FLOAT x, FX_FLOAT y, int flag); + void SetPoint(int index, + FX_FLOAT x, + FX_FLOAT y, + FXPT_TYPE type, + bool closeFigure); void TrimPoints(int nPoints); void Copy(const CFX_PathData& src); diff --git a/core/fxge/cfx_renderdevice.h b/core/fxge/cfx_renderdevice.h index 800d0c7c52..2144206e19 100644 --- a/core/fxge/cfx_renderdevice.h +++ b/core/fxge/cfx_renderdevice.h @@ -27,12 +27,6 @@ class IFX_RenderDeviceDriver; #define FXDC_DISPLAY 1 #define FXDC_PRINTER 2 -#define FXPT_CLOSEFIGURE 0x01 -#define FXPT_LINETO 0x02 -#define FXPT_BEZIERTO 0x04 -#define FXPT_MOVETO 0x06 -#define FXPT_TYPE 0x06 - #define FXRC_GET_BITS 0x01 #define FXRC_BIT_MASK 0x02 #define FXRC_ALPHA_MASK 0x04 @@ -66,6 +60,8 @@ class IFX_RenderDeviceDriver; #define FXTEXT_PRINTIMAGETEXT 0x10 #define FXTEXT_NOSMOOTH 0x20 +enum class FXPT_TYPE : uint8_t { LineTo, BezierTo, MoveTo }; + struct FXTEXT_CHARPOS { FX_FLOAT m_AdjustMatrix[4]; FX_FLOAT m_OriginX; diff --git a/core/fxge/ge/cfx_font.cpp b/core/fxge/ge/cfx_font.cpp index 24dcb87383..3ba2667f0f 100644 --- a/core/fxge/ge/cfx_font.cpp +++ b/core/fxge/ge/cfx_font.cpp @@ -87,7 +87,8 @@ FXFT_Face FT_LoadFont(const uint8_t* pData, int size) { void Outline_CheckEmptyContour(OUTLINE_PARAMS* param) { if (param->m_PointCount >= 2 && - param->m_pPoints[param->m_PointCount - 2].m_Flag == FXPT_MOVETO && + param->m_pPoints[param->m_PointCount - 2].IsTypeAndOpen( + FXPT_TYPE::MoveTo) && param->m_pPoints[param->m_PointCount - 2].m_PointX == param->m_pPoints[param->m_PointCount - 1].m_PointX && param->m_pPoints[param->m_PointCount - 2].m_PointY == @@ -95,8 +96,10 @@ void Outline_CheckEmptyContour(OUTLINE_PARAMS* param) { param->m_PointCount -= 2; } if (param->m_PointCount >= 4 && - param->m_pPoints[param->m_PointCount - 4].m_Flag == FXPT_MOVETO && - param->m_pPoints[param->m_PointCount - 3].m_Flag == FXPT_BEZIERTO && + param->m_pPoints[param->m_PointCount - 4].IsTypeAndOpen( + FXPT_TYPE::MoveTo) && + param->m_pPoints[param->m_PointCount - 3].IsTypeAndOpen( + FXPT_TYPE::BezierTo) && param->m_pPoints[param->m_PointCount - 3].m_PointX == param->m_pPoints[param->m_PointCount - 4].m_PointX && param->m_pPoints[param->m_PointCount - 3].m_PointY == @@ -119,11 +122,12 @@ int Outline_MoveTo(const FXFT_Vector* to, void* user) { Outline_CheckEmptyContour(param); param->m_pPoints[param->m_PointCount].m_PointX = to->x / param->m_CoordUnit; param->m_pPoints[param->m_PointCount].m_PointY = to->y / param->m_CoordUnit; - param->m_pPoints[param->m_PointCount].m_Flag = FXPT_MOVETO; + param->m_pPoints[param->m_PointCount].m_Type = FXPT_TYPE::MoveTo; + param->m_pPoints[param->m_PointCount].m_CloseFigure = false; param->m_CurX = to->x; param->m_CurY = to->y; if (param->m_PointCount) - param->m_pPoints[param->m_PointCount - 1].m_Flag |= FXPT_CLOSEFIGURE; + param->m_pPoints[param->m_PointCount - 1].m_CloseFigure = true; } param->m_PointCount++; return 0; @@ -134,7 +138,8 @@ int Outline_LineTo(const FXFT_Vector* to, void* user) { if (!param->m_bCount) { param->m_pPoints[param->m_PointCount].m_PointX = to->x / param->m_CoordUnit; param->m_pPoints[param->m_PointCount].m_PointY = to->y / param->m_CoordUnit; - param->m_pPoints[param->m_PointCount].m_Flag = FXPT_LINETO; + param->m_pPoints[param->m_PointCount].m_Type = FXPT_TYPE::LineTo; + param->m_pPoints[param->m_PointCount].m_CloseFigure = false; param->m_CurX = to->x; param->m_CurY = to->y; } @@ -153,17 +158,20 @@ int Outline_ConicTo(const FXFT_Vector* control, param->m_pPoints[param->m_PointCount].m_PointY = (param->m_CurY + (control->y - param->m_CurY) * 2 / 3) / param->m_CoordUnit; - param->m_pPoints[param->m_PointCount].m_Flag = FXPT_BEZIERTO; + param->m_pPoints[param->m_PointCount].m_Type = FXPT_TYPE::BezierTo; + param->m_pPoints[param->m_PointCount].m_CloseFigure = false; param->m_pPoints[param->m_PointCount + 1].m_PointX = (control->x + (to->x - control->x) / 3) / param->m_CoordUnit; param->m_pPoints[param->m_PointCount + 1].m_PointY = (control->y + (to->y - control->y) / 3) / param->m_CoordUnit; - param->m_pPoints[param->m_PointCount + 1].m_Flag = FXPT_BEZIERTO; + param->m_pPoints[param->m_PointCount + 1].m_Type = FXPT_TYPE::BezierTo; + param->m_pPoints[param->m_PointCount + 1].m_CloseFigure = false; param->m_pPoints[param->m_PointCount + 2].m_PointX = to->x / param->m_CoordUnit; param->m_pPoints[param->m_PointCount + 2].m_PointY = to->y / param->m_CoordUnit; - param->m_pPoints[param->m_PointCount + 2].m_Flag = FXPT_BEZIERTO; + param->m_pPoints[param->m_PointCount + 2].m_Type = FXPT_TYPE::BezierTo; + param->m_pPoints[param->m_PointCount + 2].m_CloseFigure = false; param->m_CurX = to->x; param->m_CurY = to->y; } @@ -181,17 +189,20 @@ int Outline_CubicTo(const FXFT_Vector* control1, control1->x / param->m_CoordUnit; param->m_pPoints[param->m_PointCount].m_PointY = control1->y / param->m_CoordUnit; - param->m_pPoints[param->m_PointCount].m_Flag = FXPT_BEZIERTO; + param->m_pPoints[param->m_PointCount].m_Type = FXPT_TYPE::BezierTo; + param->m_pPoints[param->m_PointCount].m_CloseFigure = false; param->m_pPoints[param->m_PointCount + 1].m_PointX = control2->x / param->m_CoordUnit; param->m_pPoints[param->m_PointCount + 1].m_PointY = control2->y / param->m_CoordUnit; - param->m_pPoints[param->m_PointCount + 1].m_Flag = FXPT_BEZIERTO; + param->m_pPoints[param->m_PointCount + 1].m_Type = FXPT_TYPE::BezierTo; + param->m_pPoints[param->m_PointCount + 1].m_CloseFigure = false; param->m_pPoints[param->m_PointCount + 2].m_PointX = to->x / param->m_CoordUnit; param->m_pPoints[param->m_PointCount + 2].m_PointY = to->y / param->m_CoordUnit; - param->m_pPoints[param->m_PointCount + 2].m_Flag = FXPT_BEZIERTO; + param->m_pPoints[param->m_PointCount + 2].m_Type = FXPT_TYPE::BezierTo; + param->m_pPoints[param->m_PointCount + 2].m_CloseFigure = false; param->m_CurX = to->x; param->m_CurY = to->y; } @@ -696,7 +707,7 @@ CFX_PathData* CFX_Font::LoadGlyphPathImpl(uint32_t glyph_index, Outline_CheckEmptyContour(¶ms); pPath->TrimPoints(params.m_PointCount); if (params.m_PointCount) - pPath->GetPoints()[params.m_PointCount - 1].m_Flag |= FXPT_CLOSEFIGURE; + pPath->GetPoints()[params.m_PointCount - 1].m_CloseFigure = true; return pPath; } diff --git a/core/fxge/ge/cfx_pathdata.cpp b/core/fxge/ge/cfx_pathdata.cpp index 19e8bdb013..d1391850c0 100644 --- a/core/fxge/ge/cfx_pathdata.cpp +++ b/core/fxge/ge/cfx_pathdata.cpp @@ -71,11 +71,16 @@ void CFX_PathData::Append(const CFX_PathData* pSrc, const CFX_Matrix* pMatrix) { } } -void CFX_PathData::SetPoint(int index, FX_FLOAT x, FX_FLOAT y, int flag) { +void CFX_PathData::SetPoint(int index, + FX_FLOAT x, + FX_FLOAT y, + FXPT_TYPE type, + bool closeFigure) { ASSERT(index < m_PointCount); m_pPoints[index].m_PointX = x; m_pPoints[index].m_PointY = y; - m_pPoints[index].m_Flag = flag; + m_pPoints[index].m_Type = type; + m_pPoints[index].m_CloseFigure = closeFigure; } void CFX_PathData::AppendRect(FX_FLOAT left, @@ -85,13 +90,26 @@ void CFX_PathData::AppendRect(FX_FLOAT left, int old_count = m_PointCount; AddPointCount(5); FX_PATHPOINT* pPoints = m_pPoints + old_count; - pPoints[0].m_PointX = pPoints[1].m_PointX = pPoints[4].m_PointX = left; - pPoints[2].m_PointX = pPoints[3].m_PointX = right; - pPoints[0].m_PointY = pPoints[3].m_PointY = pPoints[4].m_PointY = bottom; - pPoints[1].m_PointY = pPoints[2].m_PointY = top; - pPoints[0].m_Flag = FXPT_MOVETO; - pPoints[1].m_Flag = pPoints[2].m_Flag = pPoints[3].m_Flag = FXPT_LINETO; - pPoints[4].m_Flag = FXPT_LINETO | FXPT_CLOSEFIGURE; + pPoints[0].m_PointX = left; + pPoints[1].m_PointX = left; + pPoints[4].m_PointX = left; + pPoints[2].m_PointX = right; + pPoints[3].m_PointX = right; + pPoints[0].m_PointY = bottom; + pPoints[3].m_PointY = bottom; + pPoints[4].m_PointY = bottom; + pPoints[1].m_PointY = top; + pPoints[2].m_PointY = top; + pPoints[0].m_Type = FXPT_TYPE::MoveTo; + pPoints[1].m_Type = FXPT_TYPE::LineTo; + pPoints[2].m_Type = FXPT_TYPE::LineTo; + pPoints[3].m_Type = FXPT_TYPE::LineTo; + pPoints[0].m_CloseFigure = false; + pPoints[1].m_CloseFigure = false; + pPoints[2].m_CloseFigure = false; + pPoints[3].m_CloseFigure = false; + pPoints[4].m_Type = FXPT_TYPE::LineTo; + pPoints[4].m_CloseFigure = true; } CFX_FloatRect CFX_PathData::GetBoundingBox() const { @@ -253,19 +271,19 @@ CFX_FloatRect CFX_PathData::GetBoundingBox(FX_FLOAT line_width, int iMiddlePoint = 0; bool bJoin; while (iPoint < m_PointCount) { - if (m_pPoints[iPoint].m_Flag == FXPT_MOVETO) { + if (m_pPoints[iPoint].IsTypeAndOpen(FXPT_TYPE::MoveTo)) { iStartPoint = iPoint + 1; iEndPoint = iPoint; bJoin = false; } else { - if (m_pPoints[iPoint].m_Flag == FXPT_BEZIERTO) { + if (m_pPoints[iPoint].IsTypeAndOpen(FXPT_TYPE::BezierTo)) { rect.UpdateRect(m_pPoints[iPoint].m_PointX, m_pPoints[iPoint].m_PointY); rect.UpdateRect(m_pPoints[iPoint + 1].m_PointX, m_pPoints[iPoint + 1].m_PointY); iPoint += 2; } if (iPoint == m_PointCount - 1 || - m_pPoints[iPoint + 1].m_Flag == FXPT_MOVETO) { + m_pPoints[iPoint + 1].IsTypeAndOpen(FXPT_TYPE::MoveTo)) { iStartPoint = iPoint - 1; iEndPoint = iPoint; bJoin = false; @@ -309,9 +327,9 @@ bool CFX_PathData::GetZeroAreaPath(CFX_PathData& NewPath, if (m_PointCount < 3) { return false; } - if (m_PointCount == 3 && (m_pPoints[0].m_Flag & FXPT_TYPE) == FXPT_MOVETO && - (m_pPoints[1].m_Flag & FXPT_TYPE) == FXPT_LINETO && - (m_pPoints[2].m_Flag & FXPT_TYPE) == FXPT_LINETO && + if (m_PointCount == 3 && m_pPoints[0].m_Type == FXPT_TYPE::MoveTo && + m_pPoints[1].m_Type == FXPT_TYPE::LineTo && + m_pPoints[2].m_Type == FXPT_TYPE::LineTo && m_pPoints[0].m_PointX == m_pPoints[2].m_PointX && m_pPoints[0].m_PointY == m_pPoints[2].m_PointY) { NewPath.AddPointCount(2); @@ -321,26 +339,26 @@ bool CFX_PathData::GetZeroAreaPath(CFX_PathData& NewPath, pMatrix->TransformPoint(x, y); x = (int)x + 0.5f; y = (int)y + 0.5f; - NewPath.SetPoint(0, x, y, FXPT_MOVETO); + NewPath.SetPoint(0, x, y, FXPT_TYPE::MoveTo, false); x = m_pPoints[1].m_PointX, y = m_pPoints[1].m_PointY; pMatrix->TransformPoint(x, y); x = (int)x + 0.5f; y = (int)y + 0.5f; - NewPath.SetPoint(1, x, y, FXPT_LINETO); + NewPath.SetPoint(1, x, y, FXPT_TYPE::LineTo, false); pMatrix->SetIdentity(); } else { FX_FLOAT x = (int)m_pPoints[0].m_PointX + 0.5f, y = (int)m_pPoints[0].m_PointY + 0.5f; - NewPath.SetPoint(0, x, y, FXPT_MOVETO); + NewPath.SetPoint(0, x, y, FXPT_TYPE::MoveTo, false); x = (int)m_pPoints[1].m_PointX + 0.5f, y = (int)m_pPoints[1].m_PointY + 0.5f; - NewPath.SetPoint(1, x, y, FXPT_LINETO); + NewPath.SetPoint(1, x, y, FXPT_TYPE::LineTo, false); } } else { NewPath.SetPoint(0, m_pPoints[0].m_PointX, m_pPoints[0].m_PointY, - FXPT_MOVETO); + FXPT_TYPE::MoveTo, false); NewPath.SetPoint(1, m_pPoints[1].m_PointX, m_pPoints[1].m_PointY, - FXPT_LINETO); + FXPT_TYPE::LineTo, false); } if (m_pPoints[0].m_PointX != m_pPoints[1].m_PointX && m_pPoints[0].m_PointY != m_pPoints[1].m_PointY) { @@ -357,17 +375,18 @@ bool CFX_PathData::GetZeroAreaPath(CFX_PathData& NewPath, m_pPoints[mid + i + 1].m_PointX && m_pPoints[mid - i - 1].m_PointY == m_pPoints[mid + i + 1].m_PointY && - ((m_pPoints[mid - i - 1].m_Flag & FXPT_TYPE) != FXPT_BEZIERTO && - (m_pPoints[mid + i + 1].m_Flag & FXPT_TYPE) != FXPT_BEZIERTO))) { + m_pPoints[mid - i - 1].m_Type != FXPT_TYPE::BezierTo && + m_pPoints[mid + i + 1].m_Type != FXPT_TYPE::BezierTo)) { bZeroArea = true; break; } int new_count = t_path.GetPointCount(); t_path.AddPointCount(2); t_path.SetPoint(new_count, m_pPoints[mid - i].m_PointX, - m_pPoints[mid - i].m_PointY, FXPT_MOVETO); + m_pPoints[mid - i].m_PointY, FXPT_TYPE::MoveTo, false); t_path.SetPoint(new_count + 1, m_pPoints[mid - i - 1].m_PointX, - m_pPoints[mid - i - 1].m_PointY, FXPT_LINETO); + m_pPoints[mid - i - 1].m_PointY, FXPT_TYPE::LineTo, + false); } if (!bZeroArea) { NewPath.Append(&t_path, nullptr); @@ -378,13 +397,13 @@ bool CFX_PathData::GetZeroAreaPath(CFX_PathData& NewPath, int stratPoint = 0; int next = 0, i; for (i = 0; i < m_PointCount; i++) { - int point_type = m_pPoints[i].m_Flag & FXPT_TYPE; - if (point_type == FXPT_MOVETO) { + FXPT_TYPE point_type = m_pPoints[i].m_Type; + if (point_type == FXPT_TYPE::MoveTo) { stratPoint = i; - } else if (point_type == FXPT_LINETO) { + } else if (point_type == FXPT_TYPE::LineTo) { next = (i + 1 - stratPoint) % (m_PointCount - stratPoint) + stratPoint; - if ((m_pPoints[next].m_Flag & FXPT_TYPE) != FXPT_BEZIERTO && - (m_pPoints[next].m_Flag & FXPT_TYPE) != FXPT_MOVETO) { + if (m_pPoints[next].m_Type != FXPT_TYPE::BezierTo && + m_pPoints[next].m_Type != FXPT_TYPE::MoveTo) { if ((m_pPoints[i - 1].m_PointX == m_pPoints[i].m_PointX && m_pPoints[i].m_PointX == m_pPoints[next].m_PointX) && ((m_pPoints[i].m_PointY - m_pPoints[i - 1].m_PointY) * @@ -399,9 +418,9 @@ bool CFX_PathData::GetZeroAreaPath(CFX_PathData& NewPath, int new_count = NewPath.GetPointCount(); NewPath.AddPointCount(2); NewPath.SetPoint(new_count, m_pPoints[pre].m_PointX, - m_pPoints[pre].m_PointY, FXPT_MOVETO); + m_pPoints[pre].m_PointY, FXPT_TYPE::MoveTo, false); NewPath.SetPoint(new_count + 1, m_pPoints[next].m_PointX, - m_pPoints[next].m_PointY, FXPT_LINETO); + m_pPoints[next].m_PointY, FXPT_TYPE::LineTo, false); } else if ((m_pPoints[i - 1].m_PointY == m_pPoints[i].m_PointY && m_pPoints[i].m_PointY == m_pPoints[next].m_PointY) && ((m_pPoints[i].m_PointX - m_pPoints[i - 1].m_PointX) * @@ -416,24 +435,24 @@ bool CFX_PathData::GetZeroAreaPath(CFX_PathData& NewPath, int new_count = NewPath.GetPointCount(); NewPath.AddPointCount(2); NewPath.SetPoint(new_count, m_pPoints[pre].m_PointX, - m_pPoints[pre].m_PointY, FXPT_MOVETO); + m_pPoints[pre].m_PointY, FXPT_TYPE::MoveTo, false); NewPath.SetPoint(new_count + 1, m_pPoints[next].m_PointX, - m_pPoints[next].m_PointY, FXPT_LINETO); - } else if ((m_pPoints[i - 1].m_Flag & FXPT_TYPE) == FXPT_MOVETO && - (m_pPoints[next].m_Flag & FXPT_TYPE) == FXPT_LINETO && + m_pPoints[next].m_PointY, FXPT_TYPE::LineTo, false); + } else if (m_pPoints[i - 1].m_Type == FXPT_TYPE::MoveTo && + m_pPoints[next].m_Type == FXPT_TYPE::LineTo && m_pPoints[i - 1].m_PointX == m_pPoints[next].m_PointX && m_pPoints[i - 1].m_PointY == m_pPoints[next].m_PointY && - m_pPoints[next].m_Flag & FXPT_CLOSEFIGURE) { + m_pPoints[next].m_CloseFigure) { int new_count = NewPath.GetPointCount(); NewPath.AddPointCount(2); NewPath.SetPoint(new_count, m_pPoints[i - 1].m_PointX, - m_pPoints[i - 1].m_PointY, FXPT_MOVETO); + m_pPoints[i - 1].m_PointY, FXPT_TYPE::MoveTo, false); NewPath.SetPoint(new_count + 1, m_pPoints[i].m_PointX, - m_pPoints[i].m_PointY, FXPT_LINETO); + m_pPoints[i].m_PointY, FXPT_TYPE::LineTo, false); bThin = true; } } - } else if (point_type == FXPT_BEZIERTO) { + } else if (point_type == FXPT_TYPE::BezierTo) { i += 2; continue; } @@ -464,7 +483,7 @@ bool CFX_PathData::IsRect() const { return false; } for (int i = 1; i < 4; i++) { - if ((m_pPoints[i].m_Flag & FXPT_TYPE) != FXPT_LINETO) { + if (m_pPoints[i].m_Type != FXPT_TYPE::LineTo) { return false; } if (m_pPoints[i].m_PointX != m_pPoints[i - 1].m_PointX && @@ -472,7 +491,7 @@ bool CFX_PathData::IsRect() const { return false; } } - return m_PointCount == 5 || (m_pPoints[3].m_Flag & FXPT_CLOSEFIGURE); + return m_PointCount == 5 || m_pPoints[3].m_CloseFigure; } bool CFX_PathData::IsRect(const CFX_Matrix* pMatrix, @@ -508,7 +527,7 @@ bool CFX_PathData::IsRect(const CFX_Matrix* pMatrix, pMatrix->Transform(m_pPoints[i].m_PointX, m_pPoints[i].m_PointY, x[i], y[i]); if (i) { - if ((m_pPoints[i].m_Flag & FXPT_TYPE) != FXPT_LINETO) { + if (m_pPoints[i].m_Type != FXPT_TYPE::LineTo) { return false; } if (x[i] != x[i - 1] && y[i] != y[i - 1]) { diff --git a/core/fxge/ge/cfx_renderdevice.cpp b/core/fxge/ge/cfx_renderdevice.cpp index 0e6a4e74af..4353e0a414 100644 --- a/core/fxge/ge/cfx_renderdevice.cpp +++ b/core/fxge/ge/cfx_renderdevice.cpp @@ -676,8 +676,8 @@ bool CFX_RenderDevice::DrawCosmeticLine(FX_FLOAT x1, CFX_GraphStateData graph_state; CFX_PathData path; path.SetPointCount(2); - path.SetPoint(0, x1, y1, FXPT_MOVETO); - path.SetPoint(1, x2, y2, FXPT_LINETO); + path.SetPoint(0, x1, y1, FXPT_TYPE::MoveTo, false); + path.SetPoint(1, x2, y2, FXPT_TYPE::LineTo, false); return m_pDeviceDriver->DrawPath(&path, nullptr, &graph_state, 0, color, fill_mode, blend_type); } diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp index 2a004836af..40bd321f56 100644 --- a/core/fxge/skia/fx_skia_device.cpp +++ b/core/fxge/skia/fx_skia_device.cpp @@ -289,18 +289,18 @@ SkPath BuildPath(const CFX_PathData* pPathData) { for (int i = 0; i < nPoints; i++) { FX_FLOAT x = pPoints[i].m_PointX; FX_FLOAT y = pPoints[i].m_PointY; - 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) { skPath.moveTo(x, y); - } else if (point_type == FXPT_LINETO) { + } else if (point_type == FXPT_TYPE::LineTo) { skPath.lineTo(x, y); - } else if (point_type == FXPT_BEZIERTO) { + } else if (point_type == FXPT_TYPE::BezierTo) { FX_FLOAT x2 = pPoints[i + 1].m_PointX, y2 = pPoints[i + 1].m_PointY; FX_FLOAT x3 = pPoints[i + 2].m_PointX, y3 = pPoints[i + 2].m_PointY; skPath.cubicTo(x, y, x2, y2, x3, y3); i += 2; } - if (pPoints[i].m_Flag & FXPT_CLOSEFIGURE) + if (pPoints[i].m_CloseFigure) skPath.close(); } return skPath; 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 { diff --git a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp index 01009d25f0..82b9549a1c 100644 --- a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp +++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp @@ -71,11 +71,14 @@ void CFFL_InteractiveFormFiller::OnDraw(CPDFSDK_PageView* pPageView, if (!rcFocus.IsEmpty()) { CFX_PathData path; path.SetPointCount(5); - path.SetPoint(0, rcFocus.left, rcFocus.top, FXPT_MOVETO); - path.SetPoint(1, rcFocus.left, rcFocus.bottom, FXPT_LINETO); - path.SetPoint(2, rcFocus.right, rcFocus.bottom, FXPT_LINETO); - path.SetPoint(3, rcFocus.right, rcFocus.top, FXPT_LINETO); - path.SetPoint(4, rcFocus.left, rcFocus.top, FXPT_LINETO); + path.SetPoint(0, rcFocus.left, rcFocus.top, FXPT_TYPE::MoveTo, false); + path.SetPoint(1, rcFocus.left, rcFocus.bottom, FXPT_TYPE::LineTo, + false); + path.SetPoint(2, rcFocus.right, rcFocus.bottom, FXPT_TYPE::LineTo, + false); + path.SetPoint(3, rcFocus.right, rcFocus.top, FXPT_TYPE::LineTo, + false); + path.SetPoint(4, rcFocus.left, rcFocus.top, FXPT_TYPE::LineTo, false); CFX_GraphStateData gsd; gsd.SetDashCount(1); diff --git a/fpdfsdk/fpdf_transformpage.cpp b/fpdfsdk/fpdf_transformpage.cpp index 13d9756bd8..6d19a6b430 100644 --- a/fpdfsdk/fpdf_transformpage.cpp +++ b/fpdfsdk/fpdf_transformpage.cpp @@ -247,20 +247,20 @@ void OutputPath(CFX_ByteTextBuf& buf, CPDF_Path path) { CFX_ByteString temp; for (int i = 0; i < pPathData->GetPointCount(); i++) { buf << (pPoints[i].m_PointX) << " " << (pPoints[i].m_PointY); - 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) { buf << " m\n"; - } else if (point_type == FXPT_BEZIERTO) { + } else if (point_type == FXPT_TYPE::BezierTo) { buf << " " << (pPoints[i + 1].m_PointX) << " " << (pPoints[i + 1].m_PointY) << " " << (pPoints[i + 2].m_PointX) << " " << (pPoints[i + 2].m_PointY); - if (pPoints[i + 2].m_Flag & FXPT_CLOSEFIGURE) + if (pPoints[i + 2].m_CloseFigure) buf << " c h\n"; else buf << " c\n"; i += 2; - } else if (point_type == FXPT_LINETO) { - if (pPoints[i].m_Flag & FXPT_CLOSEFIGURE) + } else if (point_type == FXPT_TYPE::LineTo) { + if (pPoints[i].m_CloseFigure) buf << " l h\n"; else buf << " l\n"; diff --git a/fpdfsdk/pdfwindow/PWL_Caret.cpp b/fpdfsdk/pdfwindow/PWL_Caret.cpp index 8a5f539596..6636170e81 100644 --- a/fpdfsdk/pdfwindow/PWL_Caret.cpp +++ b/fpdfsdk/pdfwindow/PWL_Caret.cpp @@ -42,14 +42,14 @@ void CPWL_Caret::DrawThisAppearance(CFX_RenderDevice* pDevice, if (!rcRect.IsEmpty()) { fCaretTop = rcRect.top; fCaretBottom = rcRect.bottom; - path.SetPoint(0, fCaretX, fCaretBottom, FXPT_MOVETO); - path.SetPoint(1, fCaretX, fCaretTop, FXPT_LINETO); + path.SetPoint(0, fCaretX, fCaretBottom, FXPT_TYPE::MoveTo, false); + path.SetPoint(1, fCaretX, fCaretTop, FXPT_TYPE::LineTo, false); } else { return; } } else { - path.SetPoint(0, fCaretX, fCaretBottom, FXPT_MOVETO); - path.SetPoint(1, fCaretX, fCaretTop, FXPT_LINETO); + path.SetPoint(0, fCaretX, fCaretBottom, FXPT_TYPE::MoveTo, false); + path.SetPoint(1, fCaretX, fCaretTop, FXPT_TYPE::LineTo, false); } CFX_GraphStateData gsd; diff --git a/fpdfsdk/pdfwindow/PWL_ComboBox.cpp b/fpdfsdk/pdfwindow/PWL_ComboBox.cpp index 8e9a04b97d..acee850024 100644 --- a/fpdfsdk/pdfwindow/PWL_ComboBox.cpp +++ b/fpdfsdk/pdfwindow/PWL_ComboBox.cpp @@ -149,10 +149,10 @@ void CPWL_CBButton::DrawThisAppearance(CFX_RenderDevice* pDevice, CFX_PathData path; path.SetPointCount(4); - path.SetPoint(0, pt1.x, pt1.y, FXPT_MOVETO); - path.SetPoint(1, pt2.x, pt2.y, FXPT_LINETO); - path.SetPoint(2, pt3.x, pt3.y, FXPT_LINETO); - path.SetPoint(3, pt1.x, pt1.y, FXPT_LINETO); + path.SetPoint(0, pt1.x, pt1.y, FXPT_TYPE::MoveTo, false); + path.SetPoint(1, pt2.x, pt2.y, FXPT_TYPE::LineTo, false); + path.SetPoint(2, pt3.x, pt3.y, FXPT_TYPE::LineTo, false); + path.SetPoint(3, pt1.x, pt1.y, FXPT_TYPE::LineTo, false); pDevice->DrawPath(&path, pUser2Device, nullptr, CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_BLACKCOLOR, diff --git a/fpdfsdk/pdfwindow/PWL_Edit.cpp b/fpdfsdk/pdfwindow/PWL_Edit.cpp index bb8ec9115d..b9958a3128 100644 --- a/fpdfsdk/pdfwindow/PWL_Edit.cpp +++ b/fpdfsdk/pdfwindow/PWL_Edit.cpp @@ -330,12 +330,12 @@ void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, i * 2, rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), - rcClient.bottom, FXPT_MOVETO); + rcClient.bottom, FXPT_TYPE::MoveTo, false); path.SetPoint( i * 2 + 1, rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), - rcClient.top, FXPT_LINETO); + rcClient.top, FXPT_TYPE::LineTo, false); } if (path.GetPointCount() > 0) { pDevice->DrawPath( @@ -362,12 +362,12 @@ void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, i * 2, rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), - rcClient.bottom, FXPT_MOVETO); + rcClient.bottom, FXPT_TYPE::MoveTo, false); path.SetPoint( i * 2 + 1, rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), - rcClient.top, FXPT_LINETO); + rcClient.top, FXPT_TYPE::LineTo, false); } if (path.GetPointCount() > 0) { pDevice->DrawPath( diff --git a/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp b/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp index 8a09ac6636..c7e6bbfa99 100644 --- a/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp +++ b/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp @@ -264,10 +264,10 @@ void CPWL_SBButton::DrawThisAppearance(CFX_RenderDevice* pDevice, CFX_PathData path; path.SetPointCount(4); - path.SetPoint(0, pt1.x, pt1.y, FXPT_MOVETO); - path.SetPoint(1, pt2.x, pt2.y, FXPT_LINETO); - path.SetPoint(2, pt3.x, pt3.y, FXPT_LINETO); - path.SetPoint(3, pt1.x, pt1.y, FXPT_LINETO); + path.SetPoint(0, pt1.x, pt1.y, FXPT_TYPE::MoveTo, false); + path.SetPoint(1, pt2.x, pt2.y, FXPT_TYPE::LineTo, false); + path.SetPoint(2, pt3.x, pt3.y, FXPT_TYPE::LineTo, false); + path.SetPoint(3, pt1.x, pt1.y, FXPT_TYPE::LineTo, false); pDevice->DrawPath(&path, pUser2Device, nullptr, CPWL_Utils::PWLColorToFXColor( @@ -288,10 +288,10 @@ void CPWL_SBButton::DrawThisAppearance(CFX_RenderDevice* pDevice, CFX_PathData path; path.SetPointCount(4); - path.SetPoint(0, pt1.x, pt1.y, FXPT_MOVETO); - path.SetPoint(1, pt2.x, pt2.y, FXPT_LINETO); - path.SetPoint(2, pt3.x, pt3.y, FXPT_LINETO); - path.SetPoint(3, pt1.x, pt1.y, FXPT_LINETO); + path.SetPoint(0, pt1.x, pt1.y, FXPT_TYPE::MoveTo, false); + path.SetPoint(1, pt2.x, pt2.y, FXPT_TYPE::LineTo, false); + path.SetPoint(2, pt3.x, pt3.y, FXPT_TYPE::LineTo, false); + path.SetPoint(3, pt1.x, pt1.y, FXPT_TYPE::LineTo, false); pDevice->DrawPath(&path, pUser2Device, nullptr, CPWL_Utils::PWLColorToFXColor( diff --git a/fpdfsdk/pdfwindow/PWL_Utils.cpp b/fpdfsdk/pdfwindow/PWL_Utils.cpp index 713a193fb3..f3caf12af9 100644 --- a/fpdfsdk/pdfwindow/PWL_Utils.cpp +++ b/fpdfsdk/pdfwindow/PWL_Utils.cpp @@ -54,15 +54,15 @@ void CPWL_Utils::GetPathDataFromArray(CFX_PathData& path, switch (pPathData[i].type) { case PWLPT_MOVETO: path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y, - FXPT_MOVETO); + FXPT_TYPE::MoveTo, false); break; case PWLPT_LINETO: path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y, - FXPT_LINETO); + FXPT_TYPE::LineTo, false); break; case PWLPT_BEZIERTO: path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y, - FXPT_BEZIERTO); + FXPT_TYPE::BezierTo, false); break; default: break; @@ -1236,9 +1236,9 @@ void CPWL_Utils::DrawFillArea(CFX_RenderDevice* pDevice, CFX_PathData path; path.SetPointCount(nCount); - path.SetPoint(0, pPts[0].x, pPts[0].y, FXPT_MOVETO); + path.SetPoint(0, pPts[0].x, pPts[0].y, FXPT_TYPE::MoveTo, false); for (int32_t i = 1; i < nCount; i++) - path.SetPoint(i, pPts[i].x, pPts[i].y, FXPT_LINETO); + path.SetPoint(i, pPts[i].x, pPts[i].y, FXPT_TYPE::LineTo, false); pDevice->DrawPath(&path, pUser2Device, nullptr, color, 0, FXFILL_ALTERNATE); } @@ -1266,8 +1266,8 @@ void CPWL_Utils::DrawStrokeLine(CFX_RenderDevice* pDevice, FX_FLOAT fWidth) { CFX_PathData path; path.SetPointCount(2); - path.SetPoint(0, ptMoveTo.x, ptMoveTo.y, FXPT_MOVETO); - path.SetPoint(1, ptLineTo.x, ptLineTo.y, FXPT_LINETO); + path.SetPoint(0, ptMoveTo.x, ptMoveTo.y, FXPT_TYPE::MoveTo, false); + path.SetPoint(1, ptLineTo.x, ptLineTo.y, FXPT_TYPE::LineTo, false); CFX_GraphStateData gsd; gsd.m_LineWidth = fWidth; @@ -1353,15 +1353,15 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, path.SetPointCount(5); path.SetPoint(0, fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f, - FXPT_MOVETO); + FXPT_TYPE::MoveTo, false); path.SetPoint(1, fLeft + fWidth / 2.0f, fTop - fWidth / 2.0f, - FXPT_LINETO); + FXPT_TYPE::LineTo, false); path.SetPoint(2, fRight - fWidth / 2.0f, fTop - fWidth / 2.0f, - FXPT_LINETO); + FXPT_TYPE::LineTo, false); path.SetPoint(3, fRight - fWidth / 2.0f, fBottom + fWidth / 2.0f, - FXPT_LINETO); + FXPT_TYPE::LineTo, false); path.SetPoint(4, fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f, - FXPT_LINETO); + FXPT_TYPE::LineTo, false); CFX_GraphStateData gsd; gsd.SetDashCount(2); @@ -1384,17 +1384,19 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, pathLT.SetPointCount(7); pathLT.SetPoint(0, fLeft + fHalfWidth, fBottom + fHalfWidth, - FXPT_MOVETO); - pathLT.SetPoint(1, fLeft + fHalfWidth, fTop - fHalfWidth, FXPT_LINETO); - pathLT.SetPoint(2, fRight - fHalfWidth, fTop - fHalfWidth, FXPT_LINETO); + FXPT_TYPE::MoveTo, false); + pathLT.SetPoint(1, fLeft + fHalfWidth, fTop - fHalfWidth, + FXPT_TYPE::LineTo, false); + pathLT.SetPoint(2, fRight - fHalfWidth, fTop - fHalfWidth, + FXPT_TYPE::LineTo, false); pathLT.SetPoint(3, fRight - fHalfWidth * 2, fTop - fHalfWidth * 2, - FXPT_LINETO); + FXPT_TYPE::LineTo, false); pathLT.SetPoint(4, fLeft + fHalfWidth * 2, fTop - fHalfWidth * 2, - FXPT_LINETO); + FXPT_TYPE::LineTo, false); pathLT.SetPoint(5, fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2, - FXPT_LINETO); + FXPT_TYPE::LineTo, false); pathLT.SetPoint(6, fLeft + fHalfWidth, fBottom + fHalfWidth, - FXPT_LINETO); + FXPT_TYPE::LineTo, false); pDevice->DrawPath(&pathLT, pUser2Device, &gsd, PWLColorToFXColor(crLeftTop, nTransparancy), 0, @@ -1403,18 +1405,20 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, CFX_PathData pathRB; pathRB.SetPointCount(7); - pathRB.SetPoint(0, fRight - fHalfWidth, fTop - fHalfWidth, FXPT_MOVETO); + pathRB.SetPoint(0, fRight - fHalfWidth, fTop - fHalfWidth, + FXPT_TYPE::MoveTo, false); pathRB.SetPoint(1, fRight - fHalfWidth, fBottom + fHalfWidth, - FXPT_LINETO); + FXPT_TYPE::LineTo, false); pathRB.SetPoint(2, fLeft + fHalfWidth, fBottom + fHalfWidth, - FXPT_LINETO); + FXPT_TYPE::LineTo, false); pathRB.SetPoint(3, fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2, - FXPT_LINETO); + FXPT_TYPE::LineTo, false); pathRB.SetPoint(4, fRight - fHalfWidth * 2, fBottom + fHalfWidth * 2, - FXPT_LINETO); + FXPT_TYPE::LineTo, false); pathRB.SetPoint(5, fRight - fHalfWidth * 2, fTop - fHalfWidth * 2, - FXPT_LINETO); - pathRB.SetPoint(6, fRight - fHalfWidth, fTop - fHalfWidth, FXPT_LINETO); + FXPT_TYPE::LineTo, false); + pathRB.SetPoint(6, fRight - fHalfWidth, fTop - fHalfWidth, + FXPT_TYPE::LineTo, false); pDevice->DrawPath(&pathRB, pUser2Device, &gsd, PWLColorToFXColor(crRightBottom, nTransparancy), 0, @@ -1435,8 +1439,9 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, CFX_PathData path; path.SetPointCount(2); - path.SetPoint(0, fLeft, fBottom + fWidth / 2, FXPT_MOVETO); - path.SetPoint(1, fRight, fBottom + fWidth / 2, FXPT_LINETO); + path.SetPoint(0, fLeft, fBottom + fWidth / 2, FXPT_TYPE::MoveTo, false); + path.SetPoint(1, fRight, fBottom + fWidth / 2, FXPT_TYPE::LineTo, + false); CFX_GraphStateData gsd; gsd.m_LineWidth = fWidth; diff --git a/xfa/fde/cfde_path.cpp b/xfa/fde/cfde_path.cpp index 6db0ccc6bf..cd65d9ee09 100644 --- a/xfa/fde/cfde_path.cpp +++ b/xfa/fde/cfde_path.cpp @@ -16,7 +16,7 @@ bool CFDE_Path::StartFigure() { bool CFDE_Path::CloseFigure() { FX_PATHPOINT* pPoint = GetLastPoint(); if (pPoint) - pPoint->m_Flag |= FXPT_CLOSEFIGURE; + pPoint->m_CloseFigure = true; return true; } @@ -32,7 +32,7 @@ FX_PATHPOINT* CFDE_Path::GetLastPoint(int32_t iCount) const { bool CFDE_Path::FigureClosed() const { FX_PATHPOINT* pPoint = GetLastPoint(); - return pPoint ? (pPoint->m_Flag & FXPT_CLOSEFIGURE) : true; + return pPoint ? pPoint->m_CloseFigure : true; } FX_PATHPOINT* CFDE_Path::AddPoints(int32_t iCount) { @@ -48,14 +48,16 @@ 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_Flag = FXPT_MOVETO; + pPoint->m_Type = FXPT_TYPE::MoveTo; + pPoint->m_CloseFigure = 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_Flag = FXPT_LINETO; + pPoint->m_Type = FXPT_TYPE::LineTo; + pPoint->m_CloseFigure = false; } void CFDE_Path::BezierTo(const CFX_PointF& p1, @@ -64,13 +66,16 @@ void CFDE_Path::BezierTo(const CFX_PointF& p1, FX_PATHPOINT* p = AddPoints(3); p[0].m_PointX = p1.x; p[0].m_PointY = p1.y; - p[0].m_Flag = FXPT_BEZIERTO; + 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_Flag = FXPT_BEZIERTO; + 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_Flag = FXPT_BEZIERTO; + p[2].m_Type = FXPT_TYPE::BezierTo; + p[2].m_CloseFigure = false; } void CFDE_Path::ArcTo(bool bStart, diff --git a/xfa/fxgraphics/cfx_path_generator.cpp b/xfa/fxgraphics/cfx_path_generator.cpp index 0122b1ce4d..c7f4c0b756 100644 --- a/xfa/fxgraphics/cfx_path_generator.cpp +++ b/xfa/fxgraphics/cfx_path_generator.cpp @@ -33,12 +33,14 @@ void CFX_PathGenerator::AddPathData(FX_PATHPOINT* pPoints, int nCount) { void CFX_PathGenerator::MoveTo(FX_FLOAT x, FX_FLOAT y) { m_pPathData->AddPointCount(1); - m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, x, y, FXPT_MOVETO); + m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, x, y, + FXPT_TYPE::MoveTo, false); } void CFX_PathGenerator::LineTo(FX_FLOAT x, FX_FLOAT y) { m_pPathData->AddPointCount(1); - m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, x, y, FXPT_LINETO); + m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, x, y, + FXPT_TYPE::LineTo, false); } void CFX_PathGenerator::BezierTo(FX_FLOAT ctrl_x1, @@ -49,16 +51,18 @@ void CFX_PathGenerator::BezierTo(FX_FLOAT ctrl_x1, FX_FLOAT to_y) { int old_count = m_pPathData->GetPointCount(); m_pPathData->AddPointCount(3); - m_pPathData->SetPoint(old_count, ctrl_x1, ctrl_y1, FXPT_BEZIERTO); - m_pPathData->SetPoint(old_count + 1, ctrl_x2, ctrl_y2, FXPT_BEZIERTO); - m_pPathData->SetPoint(old_count + 2, to_x, to_y, FXPT_BEZIERTO); + m_pPathData->SetPoint(old_count, ctrl_x1, ctrl_y1, FXPT_TYPE::BezierTo, + false); + m_pPathData->SetPoint(old_count + 1, ctrl_x2, ctrl_y2, FXPT_TYPE::BezierTo, + false); + m_pPathData->SetPoint(old_count + 2, to_x, to_y, FXPT_TYPE::BezierTo, false); } void CFX_PathGenerator::Close() { if (m_pPathData->GetPointCount() > 0) { int index = m_pPathData->GetPointCount() - 1; FX_PATHPOINT* pPoints = m_pPathData->GetPoints(); - pPoints[index].m_Flag |= FXPT_CLOSEFIGURE; + pPoints[index].m_CloseFigure = true; } } @@ -68,8 +72,8 @@ void CFX_PathGenerator::AddLine(FX_FLOAT x1, FX_FLOAT y2) { int old_count = m_pPathData->GetPointCount(); m_pPathData->AddPointCount(2); - m_pPathData->SetPoint(old_count, x1, y1, FXPT_MOVETO); - m_pPathData->SetPoint(old_count + 1, x2, y2, FXPT_LINETO); + m_pPathData->SetPoint(old_count, x1, y1, FXPT_TYPE::MoveTo, false); + m_pPathData->SetPoint(old_count + 1, x2, y2, FXPT_TYPE::LineTo, false); } void CFX_PathGenerator::AddBezier(FX_FLOAT start_x, @@ -82,10 +86,13 @@ void CFX_PathGenerator::AddBezier(FX_FLOAT start_x, FX_FLOAT end_y) { int old_count = m_pPathData->GetPointCount(); m_pPathData->AddPointCount(4); - m_pPathData->SetPoint(old_count, start_x, start_y, FXPT_MOVETO); - m_pPathData->SetPoint(old_count + 1, ctrl_x1, ctrl_y1, FXPT_BEZIERTO); - m_pPathData->SetPoint(old_count + 2, ctrl_x2, ctrl_y2, FXPT_BEZIERTO); - m_pPathData->SetPoint(old_count + 3, end_x, end_y, FXPT_BEZIERTO); + m_pPathData->SetPoint(old_count, start_x, start_y, FXPT_TYPE::MoveTo, false); + m_pPathData->SetPoint(old_count + 1, ctrl_x1, ctrl_y1, FXPT_TYPE::BezierTo, + false); + m_pPathData->SetPoint(old_count + 2, ctrl_x2, ctrl_y2, FXPT_TYPE::BezierTo, + false); + m_pPathData->SetPoint(old_count + 3, end_x, end_y, FXPT_TYPE::BezierTo, + false); } void CFX_PathGenerator::AddRectangle(FX_FLOAT x1, @@ -124,13 +131,16 @@ void CFX_PathGenerator::ArcTo(FX_FLOAT x, FX_FLOAT bezier_x, bezier_y; bezier_x = x + (width * ((px[0] * cs) - (py[0] * sn))); bezier_y = y + (height * ((px[0] * sn) + (py[0] * cs))); - m_pPathData->SetPoint(old_count, bezier_x, bezier_y, FXPT_BEZIERTO); + m_pPathData->SetPoint(old_count, bezier_x, bezier_y, FXPT_TYPE::BezierTo, + false); bezier_x = x + (width * ((px[1] * cs) - (py[1] * sn))); bezier_y = y + (height * ((px[1] * sn) + (py[1] * cs))); - m_pPathData->SetPoint(old_count + 1, bezier_x, bezier_y, FXPT_BEZIERTO); + m_pPathData->SetPoint(old_count + 1, bezier_x, bezier_y, FXPT_TYPE::BezierTo, + false); bezier_x = x + (width * FXSYS_cos(start_angle + sweep_angle)); bezier_y = y + (height * FXSYS_sin(start_angle + sweep_angle)); - m_pPathData->SetPoint(old_count + 2, bezier_x, bezier_y, FXPT_BEZIERTO); + m_pPathData->SetPoint(old_count + 2, bezier_x, bezier_y, FXPT_TYPE::BezierTo, + false); } void CFX_PathGenerator::AddArc(FX_FLOAT x, @@ -157,9 +167,9 @@ void CFX_PathGenerator::AddArc(FX_FLOAT x, sweep_angle = -FX_PI * 2; } m_pPathData->AddPointCount(1); - m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, - x + (width * FXSYS_cos(start_angle)), - y + (height * FXSYS_sin(start_angle)), FXPT_MOVETO); + m_pPathData->SetPoint( + m_pPathData->GetPointCount() - 1, x + (width * FXSYS_cos(start_angle)), + y + (height * FXSYS_sin(start_angle)), FXPT_TYPE::MoveTo, false); FX_FLOAT total_sweep = 0, local_sweep = 0, prev_sweep = 0; bool done = false; do { @@ -194,13 +204,14 @@ void CFX_PathGenerator::AddPie(FX_FLOAT x, if (sweep_angle == 0) { int old_count = m_pPathData->GetPointCount(); m_pPathData->AddPointCount(2); - m_pPathData->SetPoint(old_count, x, y, FXPT_MOVETO); + m_pPathData->SetPoint(old_count, x, y, FXPT_TYPE::MoveTo, false); m_pPathData->SetPoint(old_count + 1, x + (width * FXSYS_cos(start_angle)), - y + (height * FXSYS_sin(start_angle)), FXPT_LINETO); + y + (height * FXSYS_sin(start_angle)), + FXPT_TYPE::LineTo, false); return; } AddArc(x, y, width, height, start_angle, sweep_angle); m_pPathData->AddPointCount(1); m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, x, y, - FXPT_LINETO | FXPT_CLOSEFIGURE); + FXPT_TYPE::LineTo, true); } -- cgit v1.2.3