diff options
author | Nicolas Pena <npm@chromium.org> | 2017-02-07 14:21:36 -0500 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-02-07 19:46:09 +0000 |
commit | 79365f7e3d2d62138e79e4403d4959318776c139 (patch) | |
tree | b00196a8cdc6777ee0224653ef70bb2f2f7bb8b9 /core/fxge | |
parent | c222907f453e8a0e6376a86f89354eedb8285854 (diff) | |
download | pdfium-79365f7e3d2d62138e79e4403d4959318776c139.tar.xz |
Use enum class for PathPoint types.
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 <npm@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxge')
-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 |
10 files changed, 143 insertions, 102 deletions
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 { |