From d9228f471c932a4e19e7f0f8487c134815b0bc17 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Mon, 26 Jun 2017 09:55:17 +0200 Subject: [PATCH] Optimize rectangle drawing under Cairo --- src/generic/graphicc.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/generic/graphicc.cpp b/src/generic/graphicc.cpp index 7a739c42d4..201369399e 100644 --- a/src/generic/graphicc.cpp +++ b/src/generic/graphicc.cpp @@ -476,6 +476,7 @@ public: virtual void StrokePath( const wxGraphicsPath& p ) wxOVERRIDE; virtual void FillPath( const wxGraphicsPath& p , wxPolygonFillMode fillStyle = wxWINDING_RULE ) wxOVERRIDE; virtual void ClearRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h ) wxOVERRIDE; + virtual void DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h) wxOVERRIDE; virtual void Translate( wxDouble dx , wxDouble dy ) wxOVERRIDE; virtual void Scale( wxDouble xScale , wxDouble yScale ) wxOVERRIDE; @@ -2454,6 +2455,24 @@ void wxCairoContext::ClearRectangle( wxDouble x, wxDouble y, wxDouble w, wxDoubl cairo_restore(m_context); } +void wxCairoContext::DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h ) +{ + if ( !m_brush.IsNull() ) + { + wxCairoOffsetHelper helper( m_context, ShouldOffset() ) ; + ((wxCairoBrushData*)m_brush.GetRefData())->Apply(this); + cairo_rectangle(m_context, x, y, w, h); + cairo_fill(m_context); + } + if ( !m_pen.IsNull() ) + { + wxCairoOffsetHelper helper( m_context, ShouldOffset() ) ; + ((wxCairoPenData*)m_pen.GetRefData())->Apply(this); + cairo_rectangle(m_context, x, y, w, h); + cairo_stroke(m_context); + } +} + void wxCairoContext::Rotate( wxDouble angle ) { cairo_rotate(m_context,angle);