diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp | 19 | ||||
-rw-r--r-- | core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp | 51 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_path.cpp | 4 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_path.h | 1 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_streamcontentparser.cpp | 77 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_streamcontentparser.h | 2 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_renderstatus.cpp | 9 | ||||
-rw-r--r-- | core/fxge/agg/fx_agg_driver.cpp | 15 | ||||
-rw-r--r-- | core/fxge/cfx_pathdata.h | 18 | ||||
-rw-r--r-- | core/fxge/cfx_renderdevice.h | 8 | ||||
-rw-r--r-- | core/fxge/ge/cfx_font.cpp | 37 | ||||
-rw-r--r-- | core/fxge/ge/cfx_pathdata.cpp | 105 | ||||
-rw-r--r-- | core/fxge/ge/cfx_renderdevice.cpp | 4 | ||||
-rw-r--r-- | core/fxge/skia/fx_skia_device.cpp | 10 | ||||
-rw-r--r-- | core/fxge/win32/cfx_psrenderer.cpp | 23 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_device.cpp | 10 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_gdipext.cpp | 15 |
17 files changed, 234 insertions, 174 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<CPDF_Page>(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<CPDF_Stream> 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 { |