making sure clip (device coordinages) is applied before any transforms, fixes #13216

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67761 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2011-05-18 07:32:58 +00:00
parent 715efa4e25
commit 73be128174

View File

@@ -1703,16 +1703,10 @@ bool wxMacCoreGraphicsContext::EnsureIsValid()
if ( m_cgContext ) if ( m_cgContext )
{ {
CGContextSaveGState( m_cgContext ); CGContextSaveGState( m_cgContext );
CGContextConcatCTM( m_cgContext, m_windowTransform );
CGContextSetTextMatrix( m_cgContext, CGAffineTransformIdentity );
m_contextSynthesized = true;
#if wxOSX_USE_COCOA_OR_CARBON #if wxOSX_USE_COCOA_OR_CARBON
if ( m_clipRgn.get() ) if ( m_clipRgn.get() )
{ {
// the clip region is in device coordinates, so we convert this again to user coordinates
wxCFRef<HIMutableShapeRef> hishape( HIShapeCreateMutableCopy( m_clipRgn ) ); wxCFRef<HIMutableShapeRef> hishape( HIShapeCreateMutableCopy( m_clipRgn ) );
CGPoint transformedOrigin = CGPointApplyAffineTransform( CGPointZero,m_windowTransform);
HIShapeOffset( hishape, -transformedOrigin.x, -transformedOrigin.y );
// if the shape is empty, HIShapeReplacePathInCGContext doesn't work // if the shape is empty, HIShapeReplacePathInCGContext doesn't work
if ( HIShapeIsEmpty(hishape)) if ( HIShapeIsEmpty(hishape))
{ {
@@ -1726,6 +1720,9 @@ bool wxMacCoreGraphicsContext::EnsureIsValid()
} }
} }
#endif #endif
CGContextConcatCTM( m_cgContext, m_windowTransform );
CGContextSetTextMatrix( m_cgContext, CGAffineTransformIdentity );
m_contextSynthesized = true;
CGContextSaveGState( m_cgContext ); CGContextSaveGState( m_cgContext );
#if 0 // turn on for debugging of clientdc #if 0 // turn on for debugging of clientdc
@@ -1955,6 +1952,7 @@ void wxMacCoreGraphicsContext::Clip( wxDouble x, wxDouble y, wxDouble w, wxDoubl
// the clipping itself must be stored as device coordinates, otherwise // the clipping itself must be stored as device coordinates, otherwise
// we cannot apply it back correctly // we cannot apply it back correctly
r.origin= CGPointApplyAffineTransform( r.origin, m_windowTransform ); r.origin= CGPointApplyAffineTransform( r.origin, m_windowTransform );
r.size= CGSizeApplyAffineTransform(r.size, m_windowTransform);
m_clipRgn.reset(HIShapeCreateWithRect(&r)); m_clipRgn.reset(HIShapeCreateWithRect(&r));
#else #else
// allow usage as measuring context // allow usage as measuring context