From 2bc4cc1ead29f6de1f0576a416025edadb13d7cc Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Mon, 6 Jun 2011 23:15:27 +0000 Subject: [PATCH] speeding up rectangle drawing by using specific methods, needs 40% less time git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67872 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/carbon/graphics.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/osx/carbon/graphics.cpp b/src/osx/carbon/graphics.cpp index 0b845f0afa..2f88325610 100644 --- a/src/osx/carbon/graphics.cpp +++ b/src/osx/carbon/graphics.cpp @@ -1487,6 +1487,11 @@ public: virtual void DrawBitmap( const wxGraphicsBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ); virtual void DrawIcon( const wxIcon &icon, wxDouble x, wxDouble y, wxDouble w, wxDouble h ); + + // fast convenience methods + + + virtual void DrawRectangleX( wxDouble x, wxDouble y, wxDouble w, wxDouble h ); void SetNativeContext( CGContextRef cg ); @@ -2611,6 +2616,27 @@ void * wxMacCoreGraphicsContext::GetNativeContext() return m_cgContext; } + +void wxMacCoreGraphicsContext::DrawRectangleX( wxDouble x, wxDouble y, wxDouble w, wxDouble h ) +{ + if (m_composition == wxCOMPOSITION_DEST) + return; + + CGRect rect = CGRectMake( (CGFloat) x , (CGFloat) y , (CGFloat) w , (CGFloat) h ); + if ( !m_brush.IsNull() ) + { + ((wxMacCoreGraphicsBrushData*)m_brush.GetRefData())->Apply(this); + CGContextFillRect(m_cgContext, rect); + } + + wxQuartzOffsetHelper helper( m_cgContext , ShouldOffset() ); + if ( !m_pen.IsNull() ) + { + ((wxMacCoreGraphicsPenData*)m_pen.GetRefData())->Apply(this); + CGContextStrokeRect(m_cgContext, rect); + } +} + // concatenates this transform with the current transform of this context void wxMacCoreGraphicsContext::ConcatTransform( const wxGraphicsMatrix& matrix ) { -- 2.45.2