From bb253bfd67ac6cadc15748dbc0064b69e10fd223 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Fri, 2 Apr 2004 08:37:46 +0000 Subject: [PATCH 1/1] adding QDSwapPort for performance reasons git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26578 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/dc.cpp | 9 +++++---- src/mac/carbon/tooltip.cpp | 6 +++--- src/mac/carbon/window.cpp | 6 +++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/mac/carbon/dc.cpp b/src/mac/carbon/dc.cpp index 49de162c0a..c0f44cf484 100644 --- a/src/mac/carbon/dc.cpp +++ b/src/mac/carbon/dc.cpp @@ -79,8 +79,7 @@ public : wxMacFastPortSetter( const wxDC *dc ) { wxASSERT( dc->Ok() ) ; - GetPort( &m_oldPort ) ; - SetPort( (GrafPtr) dc->m_macPort ) ; + m_swapped = QDSwapPort( (GrafPtr) dc->m_macPort , &m_oldPort ) ; m_clipRgn = NewRgn() ; GetClip( m_clipRgn ) ; m_dc = dc ; @@ -88,13 +87,15 @@ public : } ~wxMacFastPortSetter() { - SetPort( (GrafPtr) m_dc->m_macPort ) ; + // SetPort( (GrafPtr) m_dc->m_macPort ) ; SetClip( m_clipRgn ) ; - SetPort( m_oldPort ) ; + if ( m_swapped ) + SetPort( m_oldPort ) ; m_dc->MacCleanupPort( NULL ) ; DisposeRgn( m_clipRgn ) ; } private : + bool m_swapped ; RgnHandle m_clipRgn ; GrafPtr m_oldPort ; const wxDC* m_dc ; diff --git a/src/mac/carbon/tooltip.cpp b/src/mac/carbon/tooltip.cpp index 934ef3e624..f2793110dd 100644 --- a/src/mac/carbon/tooltip.cpp +++ b/src/mac/carbon/tooltip.cpp @@ -228,11 +228,11 @@ void wxMacToolTip::Draw() tag.version = kMacHelpVersion; SetRect( &tag.absHotRect , m_position.x - 2 , m_position.y - 2 , m_position.x + 2 , m_position.y + 2 ) ; GrafPtr port ; - GetPort( &port ) ; - SetPortWindowPort(m_window) ; + bool swapped = QDSwapPort( GetWindowPort( m_window ) , &port ) ; LocalToGlobal( (Point *) &tag.absHotRect.top ); LocalToGlobal( (Point *) &tag.absHotRect.bottom ); - SetPort( port ); + if ( swapped ) + SetPort( port ); m_helpTextRef.Assign( m_label , wxFONTENCODING_DEFAULT ) ; tag.content[kHMMinimumContentIndex].contentType = kHMCFStringContent ; tag.content[kHMMinimumContentIndex].u.tagCFString = m_helpTextRef ; diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index f80f5edf71..b42ab7d15c 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -909,10 +909,10 @@ void wxWindowMac::MacGetPositionAndSizeFromControl(int& x, int& y, { Point tlworigin = { 0 , 0 } ; GrafPtr port ; - ::GetPort( &port ) ; - ::SetPort( UMAGetWindowPort( (WindowRef) tlw->MacGetWindowRef() ) ) ; + bool swapped = QDSwapPort( UMAGetWindowPort( (WindowRef) tlw->MacGetWindowRef() ) , &port ) ; ::LocalToGlobal( &tlworigin ) ; - ::SetPort( port ) ; + if ( swapped ) + ::SetPort( port ) ; x = tlworigin.h ; y = tlworigin.v ; } -- 2.45.2