From 008a16224178d1d84442e5c49a974b901b3d8fe1 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Wed, 4 May 2016 21:59:13 +0200 Subject: [PATCH] Fixed appending circle/ellipse to wxGraphicsPath with Direct2D renderer. Circle/ellipse should be appended as a closed sub-path and the current point after the operation should be moved to "the rightmost point" of the figure ((x+r,y) and (x+w,y+h/2) respectively). See #17520 --- interface/wx/graphics.h | 5 ++++- src/msw/graphicsd2d.cpp | 22 ++++++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/interface/wx/graphics.h b/interface/wx/graphics.h index d23a309b24..e6611a5843 100644 --- a/interface/wx/graphics.h +++ b/interface/wx/graphics.h @@ -51,6 +51,7 @@ public: /** Appends a circle around (@a x,@a y) with radius @a r as a new closed subpath. + After this call the current point will be at (@a x+@a r, @a y). */ virtual void AddCircle(wxDouble x, wxDouble y, wxDouble r); @@ -70,7 +71,9 @@ public: const wxPoint2DDouble& e); /** - Appends an ellipse fitting into the passed in rectangle. + Appends an ellipse fitting into the passed in rectangle as a new + closed subpath. + After this call the current point will be at (@a x+@a w, @a y+@a h/2). */ virtual void AddEllipse(wxDouble x, wxDouble y, wxDouble w, wxDouble h); diff --git a/src/msw/graphicsd2d.cpp b/src/msw/graphicsd2d.cpp index 7332bcafdd..3686a6c682 100644 --- a/src/msw/graphicsd2d.cpp +++ b/src/msw/graphicsd2d.cpp @@ -1239,7 +1239,17 @@ void wxD2DPathData::AddEllipse(wxDouble x, wxDouble y, wxDouble w, wxDouble h) const wxDouble rx = w / 2.0; const wxDouble ry = h / 2.0; - MoveToPoint(x, y + ry); + MoveToPoint(x + w, y + ry); + + D2D1_ARC_SEGMENT arcSegmentLower = + { + D2D1::Point2((FLOAT)(x), (FLOAT)(y + ry)), // end point + D2D1::SizeF((FLOAT)(rx), (FLOAT)(ry)), // size + 0.0f, + D2D1_SWEEP_DIRECTION_CLOCKWISE, + D2D1_ARC_SIZE_SMALL + }; + m_geometrySink->AddArc(arcSegmentLower); D2D1_ARC_SEGMENT arcSegmentUpper = { @@ -1251,15 +1261,7 @@ void wxD2DPathData::AddEllipse(wxDouble x, wxDouble y, wxDouble w, wxDouble h) }; m_geometrySink->AddArc(arcSegmentUpper); - D2D1_ARC_SEGMENT arcSegmentLower = - { - D2D1::Point2((FLOAT)(x), (FLOAT)(y + ry)), // end point - D2D1::SizeF((FLOAT)(rx), (FLOAT)(ry)), // size - 0.0f, - D2D1_SWEEP_DIRECTION_CLOCKWISE, - D2D1_ARC_SIZE_SMALL - }; - m_geometrySink->AddArc(arcSegmentLower); + CloseSubpath(); } // gets the last point of the current path, (0,0) if not yet set