From: Stefan Csomor Date: Mon, 6 Nov 2006 16:48:54 +0000 (+0000) Subject: transforming clippings correctly, even if there is no native graphics context availab... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/1acf0e5cff9fe6f320e39c36400f8637a6e62a4d?ds=inline transforming clippings correctly, even if there is no native graphics context available yet git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43124 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/mac/carbon/graphics.cpp b/src/mac/carbon/graphics.cpp index 5d3ec9a148..0686ba7ebf 100755 --- a/src/mac/carbon/graphics.cpp +++ b/src/mac/carbon/graphics.cpp @@ -1275,7 +1275,12 @@ void wxMacCoreGraphicsContext::EnsureIsValid() m_releaseContext = true; if ( !HIShapeIsEmpty(m_clipRgn) ) { - HIShapeReplacePathInCGContext( m_clipRgn, m_cgContext ); + // the clip region is in device coordinates, so we convert this again to user coordinates + wxMacCFRefHolder hishape ; + hishape.Set( HIShapeCreateMutableCopy( m_clipRgn ) ); + CGPoint transformedOrigin = CGPointApplyAffineTransform( CGPointZero,m_windowTransform); + HIShapeOffset( hishape, -transformedOrigin.x, -transformedOrigin.y ); + HIShapeReplacePathInCGContext( hishape, m_cgContext ); CGContextClip( m_cgContext ); } CGContextSaveGState( m_cgContext ); @@ -1294,7 +1299,15 @@ void wxMacCoreGraphicsContext::Clip( const wxRegion ®ion ) } else { - m_clipRgn.Set(HIShapeCreateWithQDRgn( (RgnHandle) region.GetWXHRGN() )); + // this offsetting to device coords is not really correct, but since we cannot apply affine transforms + // to regions we try at least to have correct translations + wxMacCFRefHolder hishape ; + hishape.Set( HIShapeCreateWithQDRgn( (RgnHandle) region.GetWXHRGN() )); + HIMutableShapeRef mutableShape = HIShapeCreateMutableCopy( hishape ); + + CGPoint transformedOrigin = CGPointApplyAffineTransform( CGPointZero, m_windowTransform ); + HIShapeOffset( mutableShape, transformedOrigin.x, transformedOrigin.y ); + m_clipRgn.Set(mutableShape); } } @@ -1308,6 +1321,9 @@ void wxMacCoreGraphicsContext::Clip( wxDouble x, wxDouble y, wxDouble w, wxDoubl } else { + // the clipping itself must be stored as device coordinates, otherwise + // we cannot apply it back correctly + r.origin= CGPointApplyAffineTransform( r.origin, m_windowTransform ); m_clipRgn.Set(HIShapeCreateWithRect(&r)); } }