fixing a problem where CoreGraphics didn't correctly clip to an empty region

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@53845 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2008-05-30 16:47:45 +00:00
parent a69994a545
commit 66b926e0cf

View File

@@ -1345,9 +1345,6 @@ void wxMacCoreGraphicsContext::Init()
m_cgContext = NULL;
m_releaseContext = false;
m_windowRef = NULL;
HIRect r = CGRectMake(0,0,0,0);
m_clipRgn.Set(HIShapeCreateWithRect(&r));
}
wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( wxGraphicsRenderer* renderer, CGContextRef cgcontext ) : wxGraphicsContext(renderer)
@@ -1408,7 +1405,7 @@ void wxMacCoreGraphicsContext::EnsureIsValid()
CGContextConcatCTM( m_cgContext, m_windowTransform );
CGContextSaveGState( m_cgContext );
m_releaseContext = true;
if ( !HIShapeIsEmpty(m_clipRgn) )
if ( (HIShapeRef) m_clipRgn != NULL )
{
// the clip region is in device coordinates, so we convert this again to user coordinates
wxMacCFRefHolder<HIMutableShapeRef> hishape ;
@@ -1416,7 +1413,17 @@ void wxMacCoreGraphicsContext::EnsureIsValid()
CGPoint transformedOrigin = CGPointApplyAffineTransform( CGPointZero,m_windowTransform);
HIShapeOffset( hishape, -transformedOrigin.x, -transformedOrigin.y );
HIShapeReplacePathInCGContext( hishape, m_cgContext );
CGContextClip( m_cgContext );
// if the shape is empty, HIShapeReplacePathInCGContext doesn't work
if ( HIShapeIsEmpty(hishape))
{
CGRect empty = CGRectMake( 0,0,0,0 );
CGContextClipToRect( m_cgContext, empty );
}
else
{
HIShapeReplacePathInCGContext( hishape, m_cgContext );
CGContextClip( m_cgContext );
}
}
CGContextSaveGState( m_cgContext );
}
@@ -1464,10 +1471,19 @@ void wxMacCoreGraphicsContext::Clip( const wxRegion &region )
{
if( m_cgContext )
{
HIShapeRef shape = HIShapeCreateWithQDRgn( (RgnHandle) region.GetWXHRGN() );
HIShapeReplacePathInCGContext( shape, m_cgContext );
CGContextClip( m_cgContext );
CFRelease( shape );
wxMacCFRefHolder<HIShapeRef> shape;
shape = HIShapeCreateWithQDRgn( (RgnHandle) region.GetWXHRGN() );
// if the shape is empty, HIShapeReplacePathInCGContext doesn't work
if ( HIShapeIsEmpty(shape))
{
CGRect empty = CGRectMake( 0,0,0,0 );
CGContextClipToRect( m_cgContext, empty );
}
else
{
HIShapeReplacePathInCGContext( shape, m_cgContext );
CGContextClip( m_cgContext );
}
}
else
{
@@ -1517,8 +1533,7 @@ void wxMacCoreGraphicsContext::ResetClip()
}
else
{
HIRect r = CGRectMake(0,0,0,0);
m_clipRgn.Set(HIShapeCreateWithRect(&r));
m_clipRgn.Release();
}
}