calculating vis regions as rects (faster for Quartz) and caching the results for all implementations
fixing the background erase event always to have a wxWindowDC (had a wxClientDC in non-toplevel cases before, leading to a off-by-border error when erasing) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33220 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -222,6 +222,7 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
|
|||||||
{
|
{
|
||||||
if ( thisWindow->GetPeer()->IsCompositing() == false )
|
if ( thisWindow->GetPeer()->IsCompositing() == false )
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
if ( thisWindow->GetPeer()->IsRootControl() == false )
|
if ( thisWindow->GetPeer()->IsRootControl() == false )
|
||||||
{
|
{
|
||||||
GetControlBounds( thisWindow->GetPeer()->GetControlRef() , &controlBounds ) ;
|
GetControlBounds( thisWindow->GetPeer()->GetControlRef() , &controlBounds ) ;
|
||||||
@@ -230,6 +231,7 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
|
|||||||
{
|
{
|
||||||
thisWindow->GetPeer()->GetRect( &controlBounds ) ;
|
thisWindow->GetPeer()->GetRect( &controlBounds ) ;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
allocatedRgn = NewRgn() ;
|
allocatedRgn = NewRgn() ;
|
||||||
CopyRgn( updateRgn , allocatedRgn ) ;
|
CopyRgn( updateRgn , allocatedRgn ) ;
|
||||||
OffsetRgn( allocatedRgn , -controlBounds.left , -controlBounds.top ) ;
|
OffsetRgn( allocatedRgn , -controlBounds.left , -controlBounds.top ) ;
|
||||||
@@ -749,6 +751,7 @@ void wxWindowMac::Init()
|
|||||||
m_cgContextRef = NULL ;
|
m_cgContextRef = NULL ;
|
||||||
#endif
|
#endif
|
||||||
m_clipChildren = false ;
|
m_clipChildren = false ;
|
||||||
|
m_cachedClippedRectValid = false ;
|
||||||
// we need a valid font for the encodings
|
// we need a valid font for the encodings
|
||||||
wxWindowBase::SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
|
wxWindowBase::SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
|
||||||
}
|
}
|
||||||
@@ -1342,9 +1345,13 @@ void wxWindowMac::MacRootWindowToWindow( int *x , int *y ) const
|
|||||||
|
|
||||||
if ( !IsTopLevel() )
|
if ( !IsTopLevel() )
|
||||||
{
|
{
|
||||||
wxMacControl::Convert( &pt , MacGetTopLevelWindow()->m_peer , m_peer ) ;
|
wxTopLevelWindowMac* top = MacGetTopLevelWindow();
|
||||||
pt.x += MacGetLeftBorderSize() ;
|
if (top)
|
||||||
pt.y += MacGetTopBorderSize() ;
|
{
|
||||||
|
wxMacControl::Convert( &pt , top->m_peer , m_peer ) ;
|
||||||
|
pt.x += MacGetLeftBorderSize() ;
|
||||||
|
pt.y += MacGetTopBorderSize() ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( x ) *x = (int) pt.x ;
|
if ( x ) *x = (int) pt.x ;
|
||||||
@@ -1742,6 +1749,7 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height)
|
|||||||
|
|
||||||
MacInvalidateBorders() ;
|
MacInvalidateBorders() ;
|
||||||
|
|
||||||
|
m_cachedClippedRectValid = false ;
|
||||||
m_peer->SetRect( &r ) ;
|
m_peer->SetRect( &r ) ;
|
||||||
|
|
||||||
if ( doMove )
|
if ( doMove )
|
||||||
@@ -2726,82 +2734,120 @@ wxTopLevelWindowMac* wxWindowMac::MacGetTopLevelWindow() const
|
|||||||
}
|
}
|
||||||
return win ;
|
return win ;
|
||||||
}
|
}
|
||||||
wxRegion wxWindowMac::MacGetVisibleRegion( bool includeOuterStructures )
|
|
||||||
|
const wxRect& wxWindowMac::MacGetClippedRect() const
|
||||||
{
|
{
|
||||||
|
MacUpdateClippedRects() ;
|
||||||
|
return m_cachedClippedRect ;
|
||||||
|
}
|
||||||
|
|
||||||
|
const wxRect&wxWindowMac:: MacGetClippedRectWithOuterStructure() const
|
||||||
|
{
|
||||||
|
MacUpdateClippedRects() ;
|
||||||
|
return m_cachedClippedRectWithOuterStructure ;
|
||||||
|
}
|
||||||
|
|
||||||
|
const wxRegion& wxWindowMac::MacGetVisibleRegion( bool includeOuterStructures )
|
||||||
|
{
|
||||||
|
static wxRegion emptyrgn ;
|
||||||
|
if ( !m_isBeingDeleted && MacIsReallyShown() /*m_peer->IsVisible() */ )
|
||||||
|
{
|
||||||
|
MacUpdateClippedRects() ;
|
||||||
|
if ( includeOuterStructures )
|
||||||
|
return m_cachedClippedRegionWithOuterStructure ;
|
||||||
|
else
|
||||||
|
return m_cachedClippedRegion ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return emptyrgn ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxWindowMac::MacUpdateClippedRects() const
|
||||||
|
{
|
||||||
|
if ( m_cachedClippedRectValid )
|
||||||
|
return ;
|
||||||
|
|
||||||
// includeOuterStructures is true if we try to draw somthing like a focus ring etc.
|
// includeOuterStructures is true if we try to draw somthing like a focus ring etc.
|
||||||
// also a window dc uses this, in this case we only clip in the hierarchy for hard
|
// also a window dc uses this, in this case we only clip in the hierarchy for hard
|
||||||
// borders like a scrollwindow, splitter etc otherwise we end up in a paranoia having
|
// borders like a scrollwindow, splitter etc otherwise we end up in a paranoia having
|
||||||
// to add focus borders everywhere
|
// to add focus borders everywhere
|
||||||
|
|
||||||
Rect r ;
|
Rect r ;
|
||||||
RgnHandle visRgn = NewRgn() ;
|
Rect rIncludingOuterStructures ;
|
||||||
RgnHandle tempRgn = NewRgn() ;
|
|
||||||
if ( !m_isBeingDeleted && MacIsReallyShown() /*m_peer->IsVisible() */ )
|
m_peer->GetRect( &r ) ;
|
||||||
|
r.left -= MacGetLeftBorderSize() ;
|
||||||
|
r.top -= MacGetTopBorderSize() ;
|
||||||
|
r.bottom += MacGetBottomBorderSize() ;
|
||||||
|
r.right += MacGetRightBorderSize() ;
|
||||||
|
|
||||||
|
r.right -= r.left ;
|
||||||
|
r.bottom -= r.top ;
|
||||||
|
r.left = 0 ;
|
||||||
|
r.top = 0 ;
|
||||||
|
|
||||||
|
rIncludingOuterStructures = r ;
|
||||||
|
InsetRect( &rIncludingOuterStructures , -4 , -4 ) ;
|
||||||
|
|
||||||
|
if ( !IsTopLevel() )
|
||||||
{
|
{
|
||||||
m_peer->GetRect( &r ) ;
|
const wxWindow* child = this ;
|
||||||
r.left -= MacGetLeftBorderSize() ;
|
const wxWindow* parent = child->GetParent() ;
|
||||||
r.top -= MacGetTopBorderSize() ;
|
while( parent )
|
||||||
r.bottom += MacGetBottomBorderSize() ;
|
|
||||||
r.right += MacGetRightBorderSize() ;
|
|
||||||
|
|
||||||
r.right -= r.left ;
|
|
||||||
r.bottom -= r.top ;
|
|
||||||
r.left = 0 ;
|
|
||||||
r.top = 0 ;
|
|
||||||
|
|
||||||
if ( includeOuterStructures )
|
|
||||||
InsetRect( &r , -4 , -4 ) ;
|
|
||||||
RectRgn( visRgn , &r ) ;
|
|
||||||
|
|
||||||
if ( !IsTopLevel() )
|
|
||||||
{
|
{
|
||||||
wxWindow* child = this ;
|
int x , y ;
|
||||||
wxWindow* parent = child->GetParent() ;
|
wxSize size ;
|
||||||
while( parent )
|
// we have to find a better clipping algorithm here, in order not to clip things
|
||||||
|
// positioned like status and toolbar
|
||||||
|
if ( 1 /* parent->IsTopLevel() && child->IsKindOf( CLASSINFO( wxToolBar ) ) */ )
|
||||||
{
|
{
|
||||||
int x , y ;
|
size = parent->GetSize() ;
|
||||||
wxSize size ;
|
x = y = 0 ;
|
||||||
// we have to find a better clipping algorithm here, in order not to clip things
|
|
||||||
// positioned like status and toolbar
|
|
||||||
if ( 1 /* parent->IsTopLevel() && child->IsKindOf( CLASSINFO( wxToolBar ) ) */ )
|
|
||||||
{
|
|
||||||
size = parent->GetSize() ;
|
|
||||||
x = y = 0 ;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
size = parent->GetClientSize() ;
|
|
||||||
wxPoint origin = parent->GetClientAreaOrigin() ;
|
|
||||||
x = origin.x ;
|
|
||||||
y = origin.y ;
|
|
||||||
}
|
|
||||||
parent->MacWindowToRootWindow( &x, &y ) ;
|
|
||||||
MacRootWindowToWindow( &x , &y ) ;
|
|
||||||
|
|
||||||
if ( !includeOuterStructures || (
|
|
||||||
parent->MacClipChildren() ||
|
|
||||||
( parent->GetParent() && parent->GetParent()->MacClipGrandChildren() )
|
|
||||||
) )
|
|
||||||
{
|
|
||||||
SetRectRgn( tempRgn ,
|
|
||||||
x + parent->MacGetLeftBorderSize() , y + parent->MacGetTopBorderSize() ,
|
|
||||||
x + size.x - parent->MacGetRightBorderSize(),
|
|
||||||
y + size.y - parent->MacGetBottomBorderSize()) ;
|
|
||||||
|
|
||||||
SectRgn( visRgn , tempRgn , visRgn ) ;
|
|
||||||
}
|
|
||||||
if ( parent->IsTopLevel() )
|
|
||||||
break ;
|
|
||||||
child = parent ;
|
|
||||||
parent = child->GetParent() ;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
size = parent->GetClientSize() ;
|
||||||
|
wxPoint origin = parent->GetClientAreaOrigin() ;
|
||||||
|
x = origin.x ;
|
||||||
|
y = origin.y ;
|
||||||
|
}
|
||||||
|
parent->MacWindowToRootWindow( &x, &y ) ;
|
||||||
|
MacRootWindowToWindow( &x , &y ) ;
|
||||||
|
|
||||||
|
Rect rparent = {
|
||||||
|
y + parent->MacGetTopBorderSize() , x + parent->MacGetLeftBorderSize() ,
|
||||||
|
y + size.y - parent->MacGetBottomBorderSize() ,
|
||||||
|
x + size.x - parent->MacGetRightBorderSize() } ;
|
||||||
|
|
||||||
|
// the content will always be clipped
|
||||||
|
SectRect( &r , &rparent , &r ) ;
|
||||||
|
|
||||||
|
// the structure only at 'hard' borders
|
||||||
|
if ( parent->MacClipChildren() ||
|
||||||
|
( parent->GetParent() && parent->GetParent()->MacClipGrandChildren() ) )
|
||||||
|
{
|
||||||
|
SectRect( &rIncludingOuterStructures , &rparent , &rIncludingOuterStructures ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( parent->IsTopLevel() )
|
||||||
|
break ;
|
||||||
|
child = parent ;
|
||||||
|
parent = child->GetParent() ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxRegion vis = visRgn ;
|
m_cachedClippedRect = wxRect( r.left , r.top , r.right - r.left , r.bottom - r.top ) ;
|
||||||
DisposeRgn( visRgn ) ;
|
m_cachedClippedRectWithOuterStructure = wxRect(
|
||||||
DisposeRgn( tempRgn ) ;
|
rIncludingOuterStructures.left , rIncludingOuterStructures.top ,
|
||||||
return vis ;
|
rIncludingOuterStructures.right - rIncludingOuterStructures.left ,
|
||||||
|
rIncludingOuterStructures.bottom - rIncludingOuterStructures.top ) ;
|
||||||
|
|
||||||
|
m_cachedClippedRegionWithOuterStructure = wxRegion( m_cachedClippedRectWithOuterStructure ) ;
|
||||||
|
m_cachedClippedRegion = wxRegion( m_cachedClippedRect ) ;
|
||||||
|
|
||||||
|
m_cachedClippedRectValid = true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -2830,12 +2876,12 @@ bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr , long time )
|
|||||||
// for all the others only their client area, otherwise they
|
// for all the others only their client area, otherwise they
|
||||||
// might be drawing with full alpha and eg put blue into
|
// might be drawing with full alpha and eg put blue into
|
||||||
// the grow-box area of a scrolled window (scroll sample)
|
// the grow-box area of a scrolled window (scroll sample)
|
||||||
wxDC* dc ;
|
wxDC* dc = new wxWindowDC(this);
|
||||||
if ( IsTopLevel() )
|
if ( IsTopLevel() )
|
||||||
dc = new wxWindowDC(this);
|
dc->SetClippingRegion(wxRegion(updatergn));
|
||||||
else
|
else
|
||||||
dc = new wxClientDC(this);
|
dc->SetClippingRegion(wxRegion(newupdate));
|
||||||
dc->SetClippingRegion(wxRegion(updatergn));
|
|
||||||
wxEraseEvent eevent( GetId(), dc );
|
wxEraseEvent eevent( GetId(), dc );
|
||||||
eevent.SetEventObject( this );
|
eevent.SetEventObject( this );
|
||||||
GetEventHandler()->ProcessEvent( eevent );
|
GetEventHandler()->ProcessEvent( eevent );
|
||||||
@@ -3055,6 +3101,7 @@ bool wxWindowMac::AcceptsFocus() const
|
|||||||
|
|
||||||
void wxWindowMac::MacSuperChangedPosition()
|
void wxWindowMac::MacSuperChangedPosition()
|
||||||
{
|
{
|
||||||
|
m_cachedClippedRectValid = false ;
|
||||||
// only window-absolute structures have to be moved i.e. controls
|
// only window-absolute structures have to be moved i.e. controls
|
||||||
|
|
||||||
wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
|
wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
|
||||||
|
Reference in New Issue
Block a user