From 81d92084243bdac355d271817ae8fa103fa9291f Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 5 Jun 2016 21:53:31 +0200 Subject: [PATCH] Optimize adding rounded rectangle to wxGraphicsPath In AddRoundedRectangle() we know in advance (angle = 90 deg) or can easily determine (center point) parameters of all arcs at the vertices of the rectangle so instead of using AddArcToPoint() function which is generic and hence computationally expensive we can use AddArc() function which implementation is simpler and execution should be faster. --- src/common/graphcmn.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/common/graphcmn.cpp b/src/common/graphcmn.cpp index d08ee27282..f4226eadb9 100644 --- a/src/common/graphcmn.cpp +++ b/src/common/graphcmn.cpp @@ -434,11 +434,11 @@ void wxGraphicsPathData::AddRoundedRectangle( wxDouble x, wxDouble y, wxDouble w AddRectangle(x,y,w,h); else { - MoveToPoint( x + w, y + h / 2); - AddArcToPoint(x + w, y + h, x + w / 2, y + h, radius); - AddArcToPoint(x, y + h, x, y + h / 2, radius); - AddArcToPoint(x, y , x + w / 2, y, radius); - AddArcToPoint(x + w, y, x + w, y + h / 2, radius); + MoveToPoint(x+w, y+h/2); + AddArc(x+w-radius, y+h-radius, radius, 0.0, M_PI/2.0, true); + AddArc(x+radius, y+h-radius, radius, M_PI/2.0, M_PI, true); + AddArc(x+radius, y+radius, radius, M_PI, 3.0*M_PI/2.0, true); + AddArc(x+w-radius, y+radius, radius, 3.0*M_PI/2.0, 2.0*M_PI, true); CloseSubpath(); } }