]> git.saurik.com Git - wxWidgets.git/commitdiff
transforming clippings correctly, even if there is no native graphics context availab...
authorStefan Csomor <csomor@advancedconcepts.ch>
Mon, 6 Nov 2006 16:48:54 +0000 (16:48 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Mon, 6 Nov 2006 16:48:54 +0000 (16:48 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43124 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/mac/carbon/graphics.cpp

index 5d3ec9a148b6e8ea3a279150846add0298b3f3cf..0686ba7ebf2cf78e860b069f35597d12634b23c7 100755 (executable)
@@ -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<HIMutableShapeRef> 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 &region )
     }
     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<HIShapeRef> 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));
     }
 }