From fa5f3818b9e577b33141bd84a83f629626ea4019 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 8 May 2016 19:44:22 +0200 Subject: [PATCH] Fixed adding a line to wxGraphicsPath with Direct2D renderer. When current point is not yet set then wxGraphicsPath::AddLineToPoint() should behave as MoveToPoint(). We have to determine whether current point is set or not using additional flag because native renderer doesn't provide any support regarding this matter. See #17525 --- src/msw/graphicsd2d.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/msw/graphicsd2d.cpp b/src/msw/graphicsd2d.cpp index c29cc05d04..06a5ba98b0 100644 --- a/src/msw/graphicsd2d.cpp +++ b/src/msw/graphicsd2d.cpp @@ -1028,6 +1028,7 @@ private : mutable wxCOMPtr m_transformedGeometry; + bool m_currentPointSet; D2D1_POINT_2F m_currentPoint; D2D1_MATRIX_3X2_F m_transformMatrix; @@ -1044,6 +1045,7 @@ private : wxD2DPathData::wxD2DPathData(wxGraphicsRenderer* renderer, ID2D1Factory* d2dFactory) : wxGraphicsPathData(renderer), m_direct2dfactory(d2dFactory), + m_currentPointSet(false), m_currentPoint(D2D1::Point2F(0.0f, 0.0f)), m_transformMatrix(D2D1::Matrix3x2F::Identity()), m_figureOpened(false), @@ -1161,11 +1163,20 @@ void wxD2DPathData::MoveToPoint(wxDouble x, wxDouble y) EnsureFigureOpen(x, y); m_currentPoint = D2D1::Point2F(x, y); + m_currentPointSet = true; } // adds a straight line from the current point to (x,y) void wxD2DPathData::AddLineToPoint(wxDouble x, wxDouble y) { + // If current point is not yet set then + // this function should behave as MoveToPoint. + if( !m_currentPointSet ) + { + MoveToPoint(x, y); + return; + } + EnsureFigureOpen(m_currentPoint.x, m_currentPoint.y); m_geometrySink->AddLine(D2D1::Point2F(x, y));