From 1e6cf64a2ae84727fa9184b9e05ba104779bb17a Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 1 May 2016 19:02:58 +0200 Subject: [PATCH] Fixed creating wxGraphicsPath with Direct2D renderer. When current endpoint is moved to a new position with MoveToPoint() then current sub-path should be ended without closing the figure (no line from the current point to the beginning of the sub-path should be added). Closes #17516 --- src/msw/graphicsd2d.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/msw/graphicsd2d.cpp b/src/msw/graphicsd2d.cpp index 4c64c892a5..b557059bf6 100644 --- a/src/msw/graphicsd2d.cpp +++ b/src/msw/graphicsd2d.cpp @@ -1017,6 +1017,8 @@ private: void EnsureFigureOpen(wxDouble x = 0, wxDouble y = 0); + void EndFigure(D2D1_FIGURE_END figureEnd); + private : wxCOMPtr m_pathGeometry; @@ -1129,13 +1131,20 @@ void wxD2DPathData::EnsureFigureOpen(wxDouble x, wxDouble y) } } -void wxD2DPathData::MoveToPoint(wxDouble x, wxDouble y) +void wxD2DPathData::EndFigure(D2D1_FIGURE_END figureEnd) { if (m_figureOpened) { - CloseSubpath(); + m_geometrySink->EndFigure(figureEnd); + m_figureOpened = false; } +} +void wxD2DPathData::MoveToPoint(wxDouble x, wxDouble y) +{ + // Close current sub-path (leaving the figure as is). + EndFigure(D2D1_FIGURE_END_OPEN); + // And open a new sub-path. EnsureFigureOpen(x, y); m_currentPoint = D2D1::Point2F(x, y); @@ -1275,11 +1284,8 @@ void wxD2DPathData::AddPath(const wxGraphicsPathData* path) // closes the current sub-path void wxD2DPathData::CloseSubpath() { - if (m_figureOpened) - { - m_geometrySink->EndFigure(D2D1_FIGURE_END_CLOSED); - m_figureOpened = false; - } + // Close sub-path and close the figure. + EndFigure(D2D1_FIGURE_END_CLOSED); } void* wxD2DPathData::GetNativePath() const