diff options
Diffstat (limited to 'core/fxge')
-rw-r--r-- | core/fxge/agg/fx_agg_driver.cpp | 47 | ||||
-rw-r--r-- | core/fxge/cfx_pathdata.h | 16 | ||||
-rw-r--r-- | core/fxge/ge/cfx_font.cpp | 56 | ||||
-rw-r--r-- | core/fxge/ge/cfx_pathdata.cpp | 469 | ||||
-rw-r--r-- | core/fxge/ge/cfx_renderdevice.cpp | 8 | ||||
-rw-r--r-- | core/fxge/skia/fx_skia_device.cpp | 13 | ||||
-rw-r--r-- | core/fxge/win32/cfx_psrenderer.cpp | 22 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_device.cpp | 57 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_gdipext.cpp | 18 |
9 files changed, 353 insertions, 353 deletions
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp index e17f2df13a..8c7277752e 100644 --- a/core/fxge/agg/fx_agg_driver.cpp +++ b/core/fxge/agg/fx_agg_driver.cpp @@ -32,9 +32,9 @@ namespace { -void HardClip(FX_FLOAT& x, FX_FLOAT& y) { - x = std::max(std::min(x, 50000.0f), -50000.0f); - y = std::max(std::min(y, 50000.0f), -50000.0f); +CFX_PointF HardClip(const CFX_PointF& pos) { + return CFX_PointF(std::max(std::min(pos.x, 50000.0f), -50000.0f), + std::max(std::min(pos.y, 50000.0f), -50000.0f)); } void RgbByteOrderSetPixel(CFX_DIBitmap* pBitmap, int x, int y, uint32_t argb) { @@ -275,45 +275,44 @@ void CAgg_PathData::BuildPath(const CFX_PathData* pPathData, const CFX_Matrix* pObject2Device) { const std::vector<FX_PATHPOINT>& pPoints = pPathData->GetPoints(); for (size_t i = 0; i < pPoints.size(); i++) { - FX_FLOAT x = pPoints[i].m_PointX; - FX_FLOAT y = pPoints[i].m_PointY; + CFX_PointF pos = pPoints[i].m_Point; if (pObject2Device) - pObject2Device->TransformPoint(x, y); + pos = pObject2Device->Transform(pos); - HardClip(x, y); + pos = HardClip(pos); FXPT_TYPE point_type = pPoints[i].m_Type; if (point_type == FXPT_TYPE::MoveTo) { - m_PathData.move_to(x, y); + m_PathData.move_to(pos.x, pos.y); } else if (point_type == FXPT_TYPE::LineTo) { if (pPoints[i - 1].IsTypeAndOpen(FXPT_TYPE::MoveTo) && (i == pPoints.size() - 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; + pPoints[i].m_Point == pPoints[i - 1].m_Point) { + pos.x += 1; } - m_PathData.line_to(x, y); + m_PathData.line_to(pos.x, pos.y); } 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; + CFX_PointF pos0 = pPoints[i - 1].m_Point; + CFX_PointF pos2 = pPoints[i + 1].m_Point; + CFX_PointF pos3 = pPoints[i + 2].m_Point; if (pObject2Device) { - pObject2Device->TransformPoint(x0, y0); - pObject2Device->TransformPoint(x2, y2); - pObject2Device->TransformPoint(x3, y3); + pos0 = pObject2Device->Transform(pos0); + pos2 = pObject2Device->Transform(pos2); + pos3 = pObject2Device->Transform(pos3); } - HardClip(x0, y0); - HardClip(x2, y2); - HardClip(x3, y3); - agg::curve4 curve(x0, y0, x, y, x2, y2, x3, y3); + pos0 = HardClip(pos0); + pos2 = HardClip(pos2); + pos3 = HardClip(pos3); + agg::curve4 curve(pos0.x, pos0.y, pos.x, pos.y, pos2.x, pos2.y, pos3.x, + pos3.y); i += 2; m_PathData.add_path_curve(curve); } - if (pPoints[i].m_CloseFigure) { + if (pPoints[i].m_CloseFigure) m_PathData.end_poly(); - } } } + namespace agg { template <class BaseRenderer> diff --git a/core/fxge/cfx_pathdata.h b/core/fxge/cfx_pathdata.h index 14a8d992b9..68939bfeb2 100644 --- a/core/fxge/cfx_pathdata.h +++ b/core/fxge/cfx_pathdata.h @@ -13,13 +13,18 @@ #include "core/fxcrt/fx_system.h" #include "core/fxge/cfx_renderdevice.h" -struct FX_PATHPOINT { +class FX_PATHPOINT { + public: + FX_PATHPOINT(); + FX_PATHPOINT(const CFX_PointF& point, FXPT_TYPE type, bool close); + FX_PATHPOINT(const FX_PATHPOINT& other); + ~FX_PATHPOINT(); + bool IsTypeAndOpen(FXPT_TYPE type) const { return m_Type == type && !m_CloseFigure; } - FX_FLOAT m_PointX; - FX_FLOAT m_PointY; + CFX_PointF m_Point; FXPT_TYPE m_Type; bool m_CloseFigure; }; @@ -37,8 +42,7 @@ class CFX_PathData { return m_Points[index].m_CloseFigure; } - FX_FLOAT GetPointX(int index) const { return m_Points[index].m_PointX; } - FX_FLOAT GetPointY(int index) const { return m_Points[index].m_PointY; } + CFX_PointF GetPoint(int index) const { return m_Points[index].m_Point; } const std::vector<FX_PATHPOINT>& GetPoints() const { return m_Points; } std::vector<FX_PATHPOINT>& GetPoints() { return m_Points; } @@ -57,7 +61,7 @@ class CFX_PathData { void Append(const CFX_PathData& data); 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 AppendPoint(FX_FLOAT x, FX_FLOAT y, FXPT_TYPE type, bool closeFigure); + void AppendPoint(const CFX_PointF& pos, FXPT_TYPE type, bool closeFigure); void ClosePath(); private: diff --git a/core/fxge/ge/cfx_font.cpp b/core/fxge/ge/cfx_font.cpp index ef6960a3d7..87157b0101 100644 --- a/core/fxge/ge/cfx_font.cpp +++ b/core/fxge/ge/cfx_font.cpp @@ -88,18 +88,14 @@ void Outline_CheckEmptyContour(OUTLINE_PARAMS* param) { size_t size = points.size(); if (size >= 2 && points[size - 2].IsTypeAndOpen(FXPT_TYPE::MoveTo) && - points[size - 2].m_PointX == points[size - 1].m_PointX && - points[size - 2].m_PointY == points[size - 1].m_PointY) { + points[size - 2].m_Point == points[size - 1].m_Point) { size -= 2; } if (size >= 4 && points[size - 4].IsTypeAndOpen(FXPT_TYPE::MoveTo) && points[size - 3].IsTypeAndOpen(FXPT_TYPE::BezierTo) && - points[size - 3].m_PointX == points[size - 4].m_PointX && - points[size - 3].m_PointY == points[size - 4].m_PointY && - points[size - 2].m_PointX == points[size - 4].m_PointX && - points[size - 2].m_PointY == points[size - 4].m_PointY && - points[size - 1].m_PointX == points[size - 4].m_PointX && - points[size - 1].m_PointY == points[size - 4].m_PointY) { + points[size - 3].m_Point == points[size - 4].m_Point && + points[size - 2].m_Point == points[size - 4].m_Point && + points[size - 1].m_Point == points[size - 4].m_Point) { size -= 4; } points.resize(size); @@ -111,9 +107,9 @@ int Outline_MoveTo(const FXFT_Vector* to, void* user) { Outline_CheckEmptyContour(param); param->m_pPath->ClosePath(); - param->m_pPath->AppendPoint(to->x / param->m_CoordUnit, - to->y / param->m_CoordUnit, FXPT_TYPE::MoveTo, - false); + param->m_pPath->AppendPoint( + CFX_PointF(to->x / param->m_CoordUnit, to->y / param->m_CoordUnit), + FXPT_TYPE::MoveTo, false); param->m_CurX = to->x; param->m_CurY = to->y; @@ -123,9 +119,9 @@ int Outline_MoveTo(const FXFT_Vector* to, void* user) { int Outline_LineTo(const FXFT_Vector* to, void* user) { OUTLINE_PARAMS* param = (OUTLINE_PARAMS*)user; - param->m_pPath->AppendPoint(to->x / param->m_CoordUnit, - to->y / param->m_CoordUnit, FXPT_TYPE::LineTo, - false); + param->m_pPath->AppendPoint( + CFX_PointF(to->x / param->m_CoordUnit, to->y / param->m_CoordUnit), + FXPT_TYPE::LineTo, false); param->m_CurX = to->x; param->m_CurY = to->y; @@ -138,20 +134,20 @@ int Outline_ConicTo(const FXFT_Vector* control, OUTLINE_PARAMS* param = (OUTLINE_PARAMS*)user; param->m_pPath->AppendPoint( - (param->m_CurX + (control->x - param->m_CurX) * 2 / 3) / - param->m_CoordUnit, - (param->m_CurY + (control->y - param->m_CurY) * 2 / 3) / - param->m_CoordUnit, + CFX_PointF((param->m_CurX + (control->x - param->m_CurX) * 2 / 3) / + param->m_CoordUnit, + (param->m_CurY + (control->y - param->m_CurY) * 2 / 3) / + param->m_CoordUnit), FXPT_TYPE::BezierTo, false); param->m_pPath->AppendPoint( - (control->x + (to->x - control->x) / 3) / param->m_CoordUnit, - (control->y + (to->y - control->y) / 3) / param->m_CoordUnit, + CFX_PointF((control->x + (to->x - control->x) / 3) / param->m_CoordUnit, + (control->y + (to->y - control->y) / 3) / param->m_CoordUnit), FXPT_TYPE::BezierTo, false); - param->m_pPath->AppendPoint(to->x / param->m_CoordUnit, - to->y / param->m_CoordUnit, FXPT_TYPE::BezierTo, - false); + param->m_pPath->AppendPoint( + CFX_PointF(to->x / param->m_CoordUnit, to->y / param->m_CoordUnit), + FXPT_TYPE::BezierTo, false); param->m_CurX = to->x; param->m_CurY = to->y; @@ -164,17 +160,17 @@ int Outline_CubicTo(const FXFT_Vector* control1, void* user) { OUTLINE_PARAMS* param = (OUTLINE_PARAMS*)user; - param->m_pPath->AppendPoint(control1->x / param->m_CoordUnit, - control1->y / param->m_CoordUnit, + param->m_pPath->AppendPoint(CFX_PointF(control1->x / param->m_CoordUnit, + control1->y / param->m_CoordUnit), FXPT_TYPE::BezierTo, false); - param->m_pPath->AppendPoint(control2->x / param->m_CoordUnit, - control2->y / param->m_CoordUnit, + param->m_pPath->AppendPoint(CFX_PointF(control2->x / param->m_CoordUnit, + control2->y / param->m_CoordUnit), FXPT_TYPE::BezierTo, false); - param->m_pPath->AppendPoint(to->x / param->m_CoordUnit, - to->y / param->m_CoordUnit, FXPT_TYPE::BezierTo, - false); + param->m_pPath->AppendPoint( + CFX_PointF(to->x / param->m_CoordUnit, to->y / param->m_CoordUnit), + FXPT_TYPE::BezierTo, false); param->m_CurX = to->x; param->m_CurY = to->y; diff --git a/core/fxge/ge/cfx_pathdata.cpp b/core/fxge/ge/cfx_pathdata.cpp index e06eadd6ce..9fa2cd2aac 100644 --- a/core/fxge/ge/cfx_pathdata.cpp +++ b/core/fxge/ge/cfx_pathdata.cpp @@ -9,6 +9,164 @@ #include "core/fxcrt/fx_system.h" #include "third_party/base/numerics/safe_math.h" +namespace { + +void UpdateLineEndPoints(CFX_FloatRect* rect, + const CFX_PointF& start_pos, + const CFX_PointF& end_pos, + FX_FLOAT hw) { + if (start_pos.x == end_pos.x) { + if (start_pos.y == end_pos.y) { + rect->UpdateRect(end_pos.x + hw, end_pos.y + hw); + rect->UpdateRect(end_pos.x - hw, end_pos.y - hw); + return; + } + + FX_FLOAT point_y; + if (end_pos.y < start_pos.y) + point_y = end_pos.y - hw; + else + point_y = end_pos.y + hw; + + rect->UpdateRect(end_pos.x + hw, point_y); + rect->UpdateRect(end_pos.x - hw, point_y); + return; + } + + if (start_pos.y == end_pos.y) { + FX_FLOAT point_x; + if (end_pos.x < start_pos.x) + point_x = end_pos.x - hw; + else + point_x = end_pos.x + hw; + + rect->UpdateRect(point_x, end_pos.y + hw); + rect->UpdateRect(point_x, end_pos.y - hw); + return; + } + + CFX_PointF diff = end_pos - start_pos; + FX_FLOAT ll = FXSYS_sqrt2(diff.x, diff.y); + FX_FLOAT mx = end_pos.x + hw * diff.x / ll; + FX_FLOAT my = end_pos.y + hw * diff.y / ll; + FX_FLOAT dx1 = hw * diff.y / ll; + FX_FLOAT dy1 = hw * diff.x / ll; + rect->UpdateRect(mx - dx1, my + dy1); + rect->UpdateRect(mx + dx1, my - dy1); +} + +void UpdateLineJoinPoints(CFX_FloatRect* rect, + const CFX_PointF& start_pos, + const CFX_PointF& mid_pos, + const CFX_PointF& end_pos, + FX_FLOAT half_width, + FX_FLOAT miter_limit) { + FX_FLOAT start_k = 0; + FX_FLOAT start_c = 0; + FX_FLOAT end_k = 0; + FX_FLOAT end_c = 0; + FX_FLOAT start_len = 0; + FX_FLOAT start_dc = 0; + FX_FLOAT end_len = 0; + FX_FLOAT end_dc = 0; + FX_FLOAT one_twentieth = 1.0f / 20; + + bool bStartVert = FXSYS_fabs(start_pos.x - mid_pos.x) < one_twentieth; + bool bEndVert = FXSYS_fabs(mid_pos.x - end_pos.x) < one_twentieth; + if (bStartVert && bEndVert) { + int start_dir = mid_pos.y > start_pos.y ? 1 : -1; + FX_FLOAT point_y = mid_pos.y + half_width * start_dir; + rect->UpdateRect(mid_pos.x + half_width, point_y); + rect->UpdateRect(mid_pos.x - half_width, point_y); + return; + } + + if (!bStartVert) { + CFX_PointF start_to_mid = start_pos - mid_pos; + start_k = (mid_pos.y - start_pos.y) / (mid_pos.x - start_pos.x); + start_c = mid_pos.y - (start_k * mid_pos.x); + start_len = FXSYS_sqrt2(start_to_mid.x, start_to_mid.y); + start_dc = static_cast<FX_FLOAT>( + FXSYS_fabs(half_width * start_len / start_to_mid.x)); + } + if (!bEndVert) { + CFX_PointF end_to_mid = end_pos - mid_pos; + end_k = end_to_mid.y / end_to_mid.x; + end_c = mid_pos.y - (end_k * mid_pos.x); + end_len = FXSYS_sqrt2(end_to_mid.x, end_to_mid.y); + end_dc = + static_cast<FX_FLOAT>(FXSYS_fabs(half_width * end_len / end_to_mid.x)); + } + if (bStartVert) { + CFX_PointF outside(start_pos.x, 0); + if (end_pos.x < start_pos.x) + outside.x += half_width; + else + outside.x -= half_width; + + if (start_pos.y < (end_k * start_pos.x) + end_c) + outside.y = (end_k * outside.x) + end_c + end_dc; + else + outside.y = (end_k * outside.x) + end_c - end_dc; + + rect->UpdateRect(outside.x, outside.y); + return; + } + + if (bEndVert) { + CFX_PointF outside(end_pos.x, 0); + if (start_pos.x < end_pos.x) + outside.x += half_width; + else + outside.x -= half_width; + + if (end_pos.y < (start_k * end_pos.x) + start_c) + outside.y = (start_k * outside.x) + start_c + start_dc; + else + outside.y = (start_k * outside.x) + start_c - start_dc; + + rect->UpdateRect(outside.x, outside.y); + return; + } + + if (FXSYS_fabs(start_k - end_k) < one_twentieth) { + int start_dir = mid_pos.x > start_pos.x ? 1 : -1; + int end_dir = end_pos.x > mid_pos.x ? 1 : -1; + if (start_dir == end_dir) + UpdateLineEndPoints(rect, mid_pos, end_pos, half_width); + else + UpdateLineEndPoints(rect, start_pos, mid_pos, half_width); + return; + } + + FX_FLOAT start_outside_c = start_c; + if (end_pos.y < (start_k * end_pos.x) + start_c) + start_outside_c += start_dc; + else + start_outside_c -= start_dc; + + FX_FLOAT end_outside_c = end_c; + if (start_pos.y < (end_k * start_pos.x) + end_c) + end_outside_c += end_dc; + else + end_outside_c -= end_dc; + + FX_FLOAT join_x = (end_outside_c - start_outside_c) / (start_k - end_k); + FX_FLOAT join_y = start_k * join_x + start_outside_c; + rect->UpdateRect(join_x, join_y); +} + +} // namespace + +FX_PATHPOINT::FX_PATHPOINT() = default; + +FX_PATHPOINT::FX_PATHPOINT(const CFX_PointF& point, FXPT_TYPE type, bool close) + : m_Point(point), m_Type(type), m_CloseFigure(close) {} + +FX_PATHPOINT::FX_PATHPOINT(const FX_PATHPOINT& other) = default; + +FX_PATHPOINT::~FX_PATHPOINT() = default; + CFX_PathData::CFX_PathData() {} CFX_PathData::~CFX_PathData() {} @@ -36,25 +194,29 @@ void CFX_PathData::Append(const CFX_PathData* pSrc, const CFX_Matrix* pMatrix) { return; for (size_t i = cur_size; i < m_Points.size(); i++) - pMatrix->TransformPoint(m_Points[i].m_PointX, m_Points[i].m_PointY); + m_Points[i].m_Point = pMatrix->Transform(m_Points[i].m_Point); } -void CFX_PathData::AppendPoint(FX_FLOAT x, - FX_FLOAT y, +void CFX_PathData::AppendPoint(const CFX_PointF& point, FXPT_TYPE type, bool closeFigure) { - m_Points.push_back({x, y, type, closeFigure}); + m_Points.push_back(FX_PATHPOINT(point, type, closeFigure)); } void CFX_PathData::AppendRect(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top) { - m_Points.push_back({left, bottom, FXPT_TYPE::MoveTo, false}); - m_Points.push_back({left, top, FXPT_TYPE::LineTo, false}); - m_Points.push_back({right, top, FXPT_TYPE::LineTo, false}); - m_Points.push_back({right, bottom, FXPT_TYPE::LineTo, false}); - m_Points.push_back({left, bottom, FXPT_TYPE::LineTo, true}); + m_Points.push_back( + FX_PATHPOINT(CFX_PointF(left, bottom), FXPT_TYPE::MoveTo, false)); + m_Points.push_back( + FX_PATHPOINT(CFX_PointF(left, top), FXPT_TYPE::LineTo, false)); + m_Points.push_back( + FX_PATHPOINT(CFX_PointF(right, top), FXPT_TYPE::LineTo, false)); + m_Points.push_back( + FX_PATHPOINT(CFX_PointF(right, bottom), FXPT_TYPE::LineTo, false)); + m_Points.push_back( + FX_PATHPOINT(CFX_PointF(left, bottom), FXPT_TYPE::LineTo, true)); } CFX_FloatRect CFX_PathData::GetBoundingBox() const { @@ -62,153 +224,15 @@ CFX_FloatRect CFX_PathData::GetBoundingBox() const { return CFX_FloatRect(); CFX_FloatRect rect; - rect.InitRect(m_Points[0].m_PointX, m_Points[0].m_PointY); + rect.InitRect(m_Points[0].m_Point.x, m_Points[0].m_Point.y); for (size_t i = 1; i < m_Points.size(); i++) - rect.UpdateRect(m_Points[i].m_PointX, m_Points[i].m_PointY); + rect.UpdateRect(m_Points[i].m_Point.x, m_Points[i].m_Point.y); return rect; } -static void _UpdateLineEndPoints(CFX_FloatRect& rect, - FX_FLOAT start_x, - FX_FLOAT start_y, - FX_FLOAT end_x, - FX_FLOAT end_y, - FX_FLOAT hw) { - if (start_x == end_x) { - if (start_y == end_y) { - rect.UpdateRect(end_x + hw, end_y + hw); - rect.UpdateRect(end_x - hw, end_y - hw); - return; - } - FX_FLOAT point_y; - if (end_y < start_y) { - point_y = end_y - hw; - } else { - point_y = end_y + hw; - } - rect.UpdateRect(end_x + hw, point_y); - rect.UpdateRect(end_x - hw, point_y); - return; - } - if (start_y == end_y) { - FX_FLOAT point_x; - if (end_x < start_x) { - point_x = end_x - hw; - } else { - point_x = end_x + hw; - } - rect.UpdateRect(point_x, end_y + hw); - rect.UpdateRect(point_x, end_y - hw); - return; - } - FX_FLOAT dx = end_x - start_x; - FX_FLOAT dy = end_y - start_y; - FX_FLOAT ll = FXSYS_sqrt2(dx, dy); - FX_FLOAT mx = end_x + hw * dx / ll; - FX_FLOAT my = end_y + hw * dy / ll; - FX_FLOAT dx1 = hw * dy / ll; - FX_FLOAT dy1 = hw * dx / ll; - rect.UpdateRect(mx - dx1, my + dy1); - rect.UpdateRect(mx + dx1, my - dy1); -} - -static void _UpdateLineJoinPoints(CFX_FloatRect& rect, - FX_FLOAT start_x, - FX_FLOAT start_y, - FX_FLOAT middle_x, - FX_FLOAT middle_y, - FX_FLOAT end_x, - FX_FLOAT end_y, - FX_FLOAT half_width, - FX_FLOAT miter_limit) { - FX_FLOAT start_k = 0, start_c = 0, end_k = 0, end_c = 0, start_len = 0, - start_dc = 0, end_len = 0, end_dc = 0; - bool bStartVert = FXSYS_fabs(start_x - middle_x) < 1.0f / 20; - bool bEndVert = FXSYS_fabs(middle_x - end_x) < 1.0f / 20; - if (bStartVert && bEndVert) { - int start_dir = middle_y > start_y ? 1 : -1; - FX_FLOAT point_y = middle_y + half_width * start_dir; - rect.UpdateRect(middle_x + half_width, point_y); - rect.UpdateRect(middle_x - half_width, point_y); - return; - } - if (!bStartVert) { - start_k = (middle_y - start_y) / (middle_x - start_x); - start_c = middle_y - (start_k * middle_x); - start_len = FXSYS_sqrt2(start_x - middle_x, start_y - middle_y); - start_dc = - (FX_FLOAT)FXSYS_fabs(half_width * start_len / (start_x - middle_x)); - } - if (!bEndVert) { - end_k = (end_y - middle_y) / (end_x - middle_x); - end_c = middle_y - (end_k * middle_x); - end_len = FXSYS_sqrt2(end_x - middle_x, end_y - middle_y); - end_dc = (FX_FLOAT)FXSYS_fabs(half_width * end_len / (end_x - middle_x)); - } - if (bStartVert) { - FX_FLOAT outside_x = start_x; - if (end_x < start_x) { - outside_x += half_width; - } else { - outside_x -= half_width; - } - FX_FLOAT outside_y; - if (start_y < (end_k * start_x) + end_c) { - outside_y = (end_k * outside_x) + end_c + end_dc; - } else { - outside_y = (end_k * outside_x) + end_c - end_dc; - } - rect.UpdateRect(outside_x, outside_y); - return; - } - if (bEndVert) { - FX_FLOAT outside_x = end_x; - if (start_x < end_x) { - outside_x += half_width; - } else { - outside_x -= half_width; - } - FX_FLOAT outside_y; - if (end_y < (start_k * end_x) + start_c) { - outside_y = (start_k * outside_x) + start_c + start_dc; - } else { - outside_y = (start_k * outside_x) + start_c - start_dc; - } - rect.UpdateRect(outside_x, outside_y); - return; - } - if (FXSYS_fabs(start_k - end_k) < 1.0f / 20) { - int start_dir = middle_x > start_x ? 1 : -1; - int end_dir = end_x > middle_x ? 1 : -1; - if (start_dir == end_dir) { - _UpdateLineEndPoints(rect, middle_x, middle_y, end_x, end_y, half_width); - } else { - _UpdateLineEndPoints(rect, start_x, start_y, middle_x, middle_y, - half_width); - } - return; - } - FX_FLOAT start_outside_c = start_c; - if (end_y < (start_k * end_x) + start_c) { - start_outside_c += start_dc; - } else { - start_outside_c -= start_dc; - } - FX_FLOAT end_outside_c = end_c; - if (start_y < (end_k * start_x) + end_c) { - end_outside_c += end_dc; - } else { - end_outside_c -= end_dc; - } - FX_FLOAT join_x = (end_outside_c - start_outside_c) / (start_k - end_k); - FX_FLOAT join_y = (start_k * join_x) + start_outside_c; - rect.UpdateRect(join_x, join_y); -} - CFX_FloatRect CFX_PathData::GetBoundingBox(FX_FLOAT line_width, FX_FLOAT miter_limit) const { - CFX_FloatRect rect(100000 * 1.0f, 100000 * 1.0f, -100000 * 1.0f, - -100000 * 1.0f); + CFX_FloatRect rect(100000.0f, 100000.0f, -100000.0f, -100000.0f); size_t iPoint = 0; FX_FLOAT half_width = line_width; int iStartPoint = 0; @@ -222,9 +246,9 @@ CFX_FloatRect CFX_PathData::GetBoundingBox(FX_FLOAT line_width, bJoin = false; } else { if (m_Points[iPoint].IsTypeAndOpen(FXPT_TYPE::BezierTo)) { - rect.UpdateRect(m_Points[iPoint].m_PointX, m_Points[iPoint].m_PointY); - rect.UpdateRect(m_Points[iPoint + 1].m_PointX, - m_Points[iPoint + 1].m_PointY); + rect.UpdateRect(m_Points[iPoint].m_Point.x, m_Points[iPoint].m_Point.y); + rect.UpdateRect(m_Points[iPoint + 1].m_Point.x, + m_Points[iPoint + 1].m_Point.y); iPoint += 2; } if (iPoint == m_Points.size() - 1 || @@ -239,17 +263,15 @@ CFX_FloatRect CFX_PathData::GetBoundingBox(FX_FLOAT line_width, bJoin = true; } } - FX_FLOAT start_x = m_Points[iStartPoint].m_PointX; - FX_FLOAT start_y = m_Points[iStartPoint].m_PointY; - FX_FLOAT end_x = m_Points[iEndPoint].m_PointX; - FX_FLOAT end_y = m_Points[iEndPoint].m_PointY; + + CFX_PointF start_pos = m_Points[iStartPoint].m_Point; + CFX_PointF end_pos = m_Points[iEndPoint].m_Point; if (bJoin) { - FX_FLOAT middle_x = m_Points[iMiddlePoint].m_PointX; - FX_FLOAT middle_y = m_Points[iMiddlePoint].m_PointY; - _UpdateLineJoinPoints(rect, start_x, start_y, middle_x, middle_y, end_x, - end_y, half_width, miter_limit); + CFX_PointF mid_pos = m_Points[iMiddlePoint].m_Point; + UpdateLineJoinPoints(&rect, start_pos, mid_pos, end_pos, half_width, + miter_limit); } else { - _UpdateLineEndPoints(rect, start_x, start_y, end_x, end_y, half_width); + UpdateLineEndPoints(&rect, start_pos, end_pos, half_width); } iPoint++; } @@ -260,7 +282,7 @@ void CFX_PathData::Transform(const CFX_Matrix* pMatrix) { if (!pMatrix) return; for (auto& point : m_Points) - pMatrix->TransformPoint(point.m_PointX, point.m_PointY); + point.m_Point = pMatrix->Transform(point.m_Point); } bool CFX_PathData::GetZeroAreaPath(const CFX_Matrix* pMatrix, @@ -275,26 +297,25 @@ bool CFX_PathData::GetZeroAreaPath(const CFX_Matrix* pMatrix, if (m_Points.size() == 3 && m_Points[0].m_Type == FXPT_TYPE::MoveTo && m_Points[1].m_Type == FXPT_TYPE::LineTo && m_Points[2].m_Type == FXPT_TYPE::LineTo && - m_Points[0].m_PointX == m_Points[2].m_PointX && - m_Points[0].m_PointY == m_Points[2].m_PointY) { + m_Points[0].m_Point == m_Points[2].m_Point) { for (size_t i = 0; i < 2; i++) { - FX_FLOAT x = m_Points[i].m_PointX; - FX_FLOAT y = m_Points[i].m_PointY; + CFX_PointF point = m_Points[i].m_Point; if (bAdjust) { if (pMatrix) - pMatrix->TransformPoint(x, y); + point = pMatrix->Transform(point); - x = static_cast<int>(x) + 0.5f; - y = static_cast<int>(y) + 0.5f; + point = CFX_PointF(static_cast<int>(point.x) + 0.5f, + static_cast<int>(point.y) + 0.5f); } - NewPath->AppendPoint(x, y, i == 0 ? FXPT_TYPE::MoveTo : FXPT_TYPE::LineTo, - false); + NewPath->AppendPoint( + point, i == 0 ? FXPT_TYPE::MoveTo : FXPT_TYPE::LineTo, false); } if (bAdjust && pMatrix) *setIdentity = true; - if (m_Points[0].m_PointX != m_Points[1].m_PointX && - m_Points[0].m_PointY != m_Points[1].m_PointY) { + // Note, they both have to be not equal. + if (m_Points[0].m_Point.x != m_Points[1].m_Point.x && + m_Points[0].m_Point.y != m_Points[1].m_Point.y) { *bThin = true; } return true; @@ -305,18 +326,15 @@ bool CFX_PathData::GetZeroAreaPath(const CFX_Matrix* pMatrix, bool bZeroArea = false; CFX_PathData t_path; for (int i = 0; i < mid; i++) { - if (!(m_Points[mid - i - 1].m_PointX == m_Points[mid + i + 1].m_PointX && - m_Points[mid - i - 1].m_PointY == m_Points[mid + i + 1].m_PointY && + if (!(m_Points[mid - i - 1].m_Point == m_Points[mid + i + 1].m_Point && m_Points[mid - i - 1].m_Type != FXPT_TYPE::BezierTo && m_Points[mid + i + 1].m_Type != FXPT_TYPE::BezierTo)) { bZeroArea = true; break; } - t_path.AppendPoint(m_Points[mid - i].m_PointX, m_Points[mid - i].m_PointY, - FXPT_TYPE::MoveTo, false); - t_path.AppendPoint(m_Points[mid - i - 1].m_PointX, - m_Points[mid - i - 1].m_PointY, FXPT_TYPE::LineTo, + t_path.AppendPoint(m_Points[mid - i].m_Point, FXPT_TYPE::MoveTo, false); + t_path.AppendPoint(m_Points[mid - i - 1].m_Point, FXPT_TYPE::LineTo, false); } if (!bZeroArea) { @@ -336,48 +354,43 @@ bool CFX_PathData::GetZeroAreaPath(const CFX_Matrix* pMatrix, next = (i + 1 - stratPoint) % (m_Points.size() - stratPoint) + stratPoint; if (m_Points[next].m_Type != FXPT_TYPE::BezierTo && m_Points[next].m_Type != FXPT_TYPE::MoveTo) { - if ((m_Points[i - 1].m_PointX == m_Points[i].m_PointX && - m_Points[i].m_PointX == m_Points[next].m_PointX) && - ((m_Points[i].m_PointY - m_Points[i - 1].m_PointY) * - (m_Points[i].m_PointY - m_Points[next].m_PointY) > + if ((m_Points[i - 1].m_Point.x == m_Points[i].m_Point.x && + m_Points[i].m_Point.x == m_Points[next].m_Point.x) && + ((m_Points[i].m_Point.y - m_Points[i - 1].m_Point.y) * + (m_Points[i].m_Point.y - m_Points[next].m_Point.y) > 0)) { int pre = i; - if (FXSYS_fabs(m_Points[i].m_PointY - m_Points[i - 1].m_PointY) < - FXSYS_fabs(m_Points[i].m_PointY - m_Points[next].m_PointY)) { + if (FXSYS_fabs(m_Points[i].m_Point.y - m_Points[i - 1].m_Point.y) < + FXSYS_fabs(m_Points[i].m_Point.y - m_Points[next].m_Point.y)) { pre--; next--; } - NewPath->AppendPoint(m_Points[pre].m_PointX, m_Points[pre].m_PointY, - FXPT_TYPE::MoveTo, false); - NewPath->AppendPoint(m_Points[next].m_PointX, m_Points[next].m_PointY, - FXPT_TYPE::LineTo, false); - } else if ((m_Points[i - 1].m_PointY == m_Points[i].m_PointY && - m_Points[i].m_PointY == m_Points[next].m_PointY) && - ((m_Points[i].m_PointX - m_Points[i - 1].m_PointX) * - (m_Points[i].m_PointX - m_Points[next].m_PointX) > + NewPath->AppendPoint(m_Points[pre].m_Point, FXPT_TYPE::MoveTo, false); + NewPath->AppendPoint(m_Points[next].m_Point, FXPT_TYPE::LineTo, + false); + } else if ((m_Points[i - 1].m_Point.y == m_Points[i].m_Point.y && + m_Points[i].m_Point.y == m_Points[next].m_Point.y) && + ((m_Points[i].m_Point.x - m_Points[i - 1].m_Point.x) * + (m_Points[i].m_Point.x - m_Points[next].m_Point.x) > 0)) { int pre = i; - if (FXSYS_fabs(m_Points[i].m_PointX - m_Points[i - 1].m_PointX) < - FXSYS_fabs(m_Points[i].m_PointX - m_Points[next].m_PointX)) { + if (FXSYS_fabs(m_Points[i].m_Point.x - m_Points[i - 1].m_Point.x) < + FXSYS_fabs(m_Points[i].m_Point.x - m_Points[next].m_Point.x)) { pre--; next--; } - NewPath->AppendPoint(m_Points[pre].m_PointX, m_Points[pre].m_PointY, - FXPT_TYPE::MoveTo, false); - NewPath->AppendPoint(m_Points[next].m_PointX, m_Points[next].m_PointY, - FXPT_TYPE::LineTo, false); + NewPath->AppendPoint(m_Points[pre].m_Point, FXPT_TYPE::MoveTo, false); + NewPath->AppendPoint(m_Points[next].m_Point, FXPT_TYPE::LineTo, + false); } else if (m_Points[i - 1].m_Type == FXPT_TYPE::MoveTo && m_Points[next].m_Type == FXPT_TYPE::LineTo && - m_Points[i - 1].m_PointX == m_Points[next].m_PointX && - m_Points[i - 1].m_PointY == m_Points[next].m_PointY && + m_Points[i - 1].m_Point == m_Points[next].m_Point && m_Points[next].m_CloseFigure) { - NewPath->AppendPoint(m_Points[i - 1].m_PointX, - m_Points[i - 1].m_PointY, FXPT_TYPE::MoveTo, + NewPath->AppendPoint(m_Points[i - 1].m_Point, FXPT_TYPE::MoveTo, false); - NewPath->AppendPoint(m_Points[i].m_PointX, m_Points[i].m_PointY, - FXPT_TYPE::LineTo, false); + NewPath->AppendPoint(m_Points[i].m_Point, FXPT_TYPE::LineTo, false); *bThin = true; } } @@ -397,24 +410,23 @@ bool CFX_PathData::IsRect() const { if (m_Points.size() != 5 && m_Points.size() != 4) return false; - if ((m_Points.size() == 5 && - (m_Points[0].m_PointX != m_Points[4].m_PointX || - m_Points[0].m_PointY != m_Points[4].m_PointY)) || - (m_Points[0].m_PointX == m_Points[2].m_PointX && - m_Points[0].m_PointY == m_Points[2].m_PointY) || - (m_Points[1].m_PointX == m_Points[3].m_PointX && - m_Points[1].m_PointY == m_Points[3].m_PointY)) { + if ((m_Points.size() == 5 && m_Points[0].m_Point != m_Points[4].m_Point) || + m_Points[0].m_Point == m_Points[2].m_Point || + m_Points[1].m_Point == m_Points[3].m_Point) { return false; } - if (m_Points[0].m_PointX != m_Points[3].m_PointX && - m_Points[0].m_PointY != m_Points[3].m_PointY) { + // Note, both x,y have to not equal. + if (m_Points[0].m_Point.x != m_Points[3].m_Point.x && + m_Points[0].m_Point.y != m_Points[3].m_Point.y) { return false; } + for (int i = 1; i < 4; i++) { if (m_Points[i].m_Type != FXPT_TYPE::LineTo) return false; - if (m_Points[i].m_PointX != m_Points[i - 1].m_PointX && - m_Points[i].m_PointY != m_Points[i - 1].m_PointY) { + // Note, both x,y have to not equal. + if (m_Points[i].m_Point.x != m_Points[i - 1].m_Point.x && + m_Points[i].m_Point.y != m_Points[i - 1].m_Point.y) { return false; } } @@ -428,10 +440,10 @@ bool CFX_PathData::IsRect(const CFX_Matrix* pMatrix, return false; if (pRect) { - pRect->left = m_Points[0].m_PointX; - pRect->right = m_Points[2].m_PointX; - pRect->bottom = m_Points[0].m_PointY; - pRect->top = m_Points[2].m_PointY; + pRect->left = m_Points[0].m_Point.x; + pRect->right = m_Points[2].m_Point.x; + pRect->bottom = m_Points[0].m_Point.y; + pRect->top = m_Points[2].m_Point.y; pRect->Normalize(); } return true; @@ -440,22 +452,19 @@ bool CFX_PathData::IsRect(const CFX_Matrix* pMatrix, if (m_Points.size() != 5 && m_Points.size() != 4) return false; - if ((m_Points.size() == 5 && - (m_Points[0].m_PointX != m_Points[4].m_PointX || - m_Points[0].m_PointY != m_Points[4].m_PointY)) || - (m_Points[1].m_PointX == m_Points[3].m_PointX && - m_Points[1].m_PointY == m_Points[3].m_PointY)) { + if ((m_Points.size() == 5 && m_Points[0].m_Point != m_Points[4].m_Point) || + m_Points[1].m_Point == m_Points[3].m_Point) { return false; } - if (m_Points.size() == 4 && m_Points[0].m_PointX != m_Points[3].m_PointX && - m_Points[0].m_PointY != m_Points[3].m_PointY) { + // Note, both x,y not equal. + if (m_Points.size() == 4 && m_Points[0].m_Point.x != m_Points[3].m_Point.x && + m_Points[0].m_Point.y != m_Points[3].m_Point.y) { return false; } CFX_PointF points[5]; for (size_t i = 0; i < m_Points.size(); i++) { - points[i] = pMatrix->Transform( - CFX_PointF(m_Points[i].m_PointX, m_Points[i].m_PointY)); + points[i] = pMatrix->Transform(m_Points[i].m_Point); if (i == 0) continue; diff --git a/core/fxge/ge/cfx_renderdevice.cpp b/core/fxge/ge/cfx_renderdevice.cpp index 203fecf061..daa67ccc91 100644 --- a/core/fxge/ge/cfx_renderdevice.cpp +++ b/core/fxge/ge/cfx_renderdevice.cpp @@ -490,8 +490,8 @@ bool CFX_RenderDevice::DrawPathWithBlend(const CFX_PathData* pPathData, uint8_t fill_alpha = (fill_mode & 3) ? FXARGB_A(fill_color) : 0; const std::vector<FX_PATHPOINT>& pPoints = pPathData->GetPoints(); if (stroke_alpha == 0 && pPoints.size() == 2) { - CFX_PointF pos1(pPoints[0].m_PointX, pPoints[0].m_PointY); - CFX_PointF pos2(pPoints[1].m_PointX, pPoints[1].m_PointY); + CFX_PointF pos1 = pPoints[0].m_Point; + CFX_PointF pos2 = pPoints[1].m_Point; if (pObject2Device) { pos1 = pObject2Device->Transform(pos1); pos2 = pObject2Device->Transform(pos2); @@ -692,8 +692,8 @@ bool CFX_RenderDevice::DrawCosmeticLine(FX_FLOAT x1, } CFX_GraphStateData graph_state; CFX_PathData path; - path.AppendPoint(x1, y1, FXPT_TYPE::MoveTo, false); - path.AppendPoint(x2, y2, FXPT_TYPE::LineTo, false); + path.AppendPoint(CFX_PointF(x1, y1), FXPT_TYPE::MoveTo, false); + path.AppendPoint(CFX_PointF(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 431491d826..7e23f97287 100644 --- a/core/fxge/skia/fx_skia_device.cpp +++ b/core/fxge/skia/fx_skia_device.cpp @@ -280,17 +280,16 @@ SkPath BuildPath(const CFX_PathData* pPathData) { const CFX_PathData* pFPath = pPathData; const std::vector<FX_PATHPOINT>& pPoints = pFPath->GetPoints(); for (size_t i = 0; i < pPoints.size(); i++) { - FX_FLOAT x = pPoints[i].m_PointX; - FX_FLOAT y = pPoints[i].m_PointY; + CFX_PointF point = pPoints[i].m_Point; FXPT_TYPE point_type = pPoints[i].m_Type; if (point_type == FXPT_TYPE::MoveTo) { - skPath.moveTo(x, y); + skPath.moveTo(point.x, point.y); } else if (point_type == FXPT_TYPE::LineTo) { - skPath.lineTo(x, y); + skPath.lineTo(point.x, point.y); } 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); + CFX_PointF point2 = pPoints[i + 1].m_Point; + CFX_PointF point3 = pPoints[i + 2].m_Point; + skPath.cubicTo(point.x, point.y, point2.x, point2.y, point3.x, point3.y); i += 2; } if (pPoints[i].m_CloseFigure) diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp index a0e675e23c..74fae088d9 100644 --- a/core/fxge/win32/cfx_psrenderer.cpp +++ b/core/fxge/win32/cfx_psrenderer.cpp @@ -116,7 +116,7 @@ void CFX_PSRenderer::OutputPath(const CFX_PathData* pPathData, for (size_t i = 0; i < size; i++) { FXPT_TYPE type = pPathData->GetType(i); bool closing = pPathData->IsClosingFigure(i); - CFX_PointF pos(pPathData->GetPointX(i), pPathData->GetPointY(i)); + CFX_PointF pos = pPathData->GetPoint(i); if (pObject2Device) pos = pObject2Device->Transform(pos); @@ -131,10 +131,8 @@ void CFX_PSRenderer::OutputPath(const CFX_PathData* pPathData, buf << "h "; break; case FXPT_TYPE::BezierTo: { - CFX_PointF pos1(pPathData->GetPointX(i + 1), - pPathData->GetPointY(i + 1)); - CFX_PointF pos2(pPathData->GetPointX(i + 2), - pPathData->GetPointY(i + 2)); + CFX_PointF pos1 = pPathData->GetPoint(i + 1); + CFX_PointF pos2 = pPathData->GetPoint(i + 2); if (pObject2Device) { pos1 = pObject2Device->Transform(pos1); pos2 = pObject2Device->Transform(pos2); @@ -604,21 +602,21 @@ void CFX_PSRenderer::FindPSFontGlyph(CFX_FaceCache* pFaceCache, buf << "/X" << *ps_fontnum << " Ff/CharProcs get begin/" << glyphindex << "{n "; for (size_t p = 0; p < TransformedPath.GetPoints().size(); p++) { - FX_FLOAT x = TransformedPath.GetPointX(p), y = TransformedPath.GetPointY(p); + CFX_PointF point = TransformedPath.GetPoint(p); switch (TransformedPath.GetType(p)) { case FXPT_TYPE::MoveTo: { - buf << x << " " << y << " m\n"; + buf << point.x << " " << point.y << " m\n"; break; } case FXPT_TYPE::LineTo: { - buf << x << " " << y << " l\n"; + buf << point.x << " " << point.y << " l\n"; break; } case FXPT_TYPE::BezierTo: { - buf << x << " " << y << " " << TransformedPath.GetPointX(p + 1) << " " - << TransformedPath.GetPointY(p + 1) << " " - << TransformedPath.GetPointX(p + 2) << " " - << TransformedPath.GetPointY(p + 2) << " c\n"; + CFX_PointF point1 = TransformedPath.GetPoint(p + 1); + CFX_PointF point2 = TransformedPath.GetPoint(p + 2); + buf << point.x << " " << point.y << " " << point1.x << " " << point1.y + << " " << point2.x << " " << point2.y << " c\n"; p += 2; break; } diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index b5ce7345c6..92e9b41e06 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -169,45 +169,42 @@ void SetPathToDC(HDC hDC, const std::vector<FX_PATHPOINT>& pPoints = pPathData->GetPoints(); for (size_t i = 0; i < pPoints.size(); i++) { - FX_FLOAT posx = pPoints[i].m_PointX; - FX_FLOAT posy = pPoints[i].m_PointY; + CFX_PointF pos = pPoints[i].m_Point; if (pMatrix) - pMatrix->TransformPoint(posx, posy); + pos = pMatrix->Transform(pos); - int screen_x = FXSYS_round(posx), screen_y = FXSYS_round(posy); + CFX_Point screen(FXSYS_round(pos.x), FXSYS_round(pos.y)); FXPT_TYPE point_type = pPoints[i].m_Type; if (point_type == FXPT_TYPE::MoveTo) { - MoveToEx(hDC, screen_x, screen_y, nullptr); + MoveToEx(hDC, screen.x, screen.y, nullptr); } 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); + if (pPoints[i].m_Point == pPoints[i - 1].m_Point) + screen.x++; + + LineTo(hDC, screen.x, screen.y); } else if (point_type == FXPT_TYPE::BezierTo) { POINT lppt[3]; - lppt[0].x = screen_x; - lppt[0].y = screen_y; - posx = pPoints[i + 1].m_PointX; - posy = pPoints[i + 1].m_PointY; + lppt[0].x = screen.x; + lppt[0].y = screen.y; + + pos = pPoints[i + 1].m_Point; if (pMatrix) - pMatrix->TransformPoint(posx, posy); + pos = pMatrix->Transform(pos); - lppt[1].x = FXSYS_round(posx); - lppt[1].y = FXSYS_round(posy); - posx = pPoints[i + 2].m_PointX; - posy = pPoints[i + 2].m_PointY; + lppt[1].x = FXSYS_round(pos.x); + lppt[1].y = FXSYS_round(pos.y); + + pos = pPoints[i + 2].m_Point; if (pMatrix) - pMatrix->TransformPoint(posx, posy); + pos = pMatrix->Transform(pos); - lppt[2].x = FXSYS_round(posx); - lppt[2].y = FXSYS_round(posy); + lppt[2].x = FXSYS_round(pos.x); + lppt[2].y = FXSYS_round(pos.y); PolyBezierTo(hDC, lppt, 3); i += 2; } - if (pPoints[i].m_CloseFigure) { + if (pPoints[i].m_CloseFigure) CloseFigure(hDC); - } } EndPath(hDC); } @@ -1047,15 +1044,13 @@ bool CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData, } if (pPathData->GetPoints().size() == 2 && pGraphState && pGraphState->m_DashCount) { - FX_FLOAT x1 = pPathData->GetPointX(0); - FX_FLOAT y1 = pPathData->GetPointY(0); - FX_FLOAT x2 = pPathData->GetPointX(1); - FX_FLOAT y2 = pPathData->GetPointY(1); + CFX_PointF pos1 = pPathData->GetPoint(0); + CFX_PointF pos2 = pPathData->GetPoint(1); if (pMatrix) { - pMatrix->TransformPoint(x1, y1); - pMatrix->TransformPoint(x2, y2); + pos1 = pMatrix->Transform(pos1); + pos2 = pMatrix->Transform(pos2); } - DrawLine(x1, y1, x2, y2); + DrawLine(pos1.x, pos1.y, pos2.x, pos2.y); } else { SetPathToDC(m_hDC, pPathData, pMatrix); if (pGraphState && stroke_alpha) { diff --git a/core/fxge/win32/fx_win32_gdipext.cpp b/core/fxge/win32/fx_win32_gdipext.cpp index c766ac8f3b..54711ceef5 100644 --- a/core/fxge/win32/fx_win32_gdipext.cpp +++ b/core/fxge/win32/fx_win32_gdipext.cpp @@ -1129,20 +1129,20 @@ bool CGdiplusExt::DrawPath(HDC hDC, bool bSmooth = false; int startpoint = 0; for (size_t i = 0; i < pPoints.size(); i++) { - points[i].X = pPoints[i].m_PointX; - points[i].Y = pPoints[i].m_PointY; - FX_FLOAT x = pPoints[i].m_PointX; - FX_FLOAT y = pPoints[i].m_PointY; + points[i].X = pPoints[i].m_Point.x; + points[i].Y = pPoints[i].m_Point.y; + + CFX_PointF pos = pPoints[i].m_Point; if (pObject2Device) - pObject2Device->TransformPoint(x, y); + pos = pObject2Device->Transform(pos); - if (x > 50000 * 1.0f) + if (pos.x > 50000 * 1.0f) points[i].X = 50000 * 1.0f; - if (x < -50000 * 1.0f) + if (pos.x < -50000 * 1.0f) points[i].X = -50000 * 1.0f; - if (y > 50000 * 1.0f) + if (pos.y > 50000 * 1.0f) points[i].Y = 50000 * 1.0f; - if (y < -50000 * 1.0f) + if (pos.y < -50000 * 1.0f) points[i].Y = -50000 * 1.0f; FXPT_TYPE point_type = pPoints[i].m_Type; |