In .:
authorGeoff Norton <grompf@sublimeintervention.com>
Fri, 1 Feb 2008 17:37:42 +0000 (17:37 -0000)
committerGeoff Norton <grompf@sublimeintervention.com>
Fri, 1 Feb 2008 17:37:42 +0000 (17:37 -0000)
2008-02-01  Geoff Norton  <gnorton@novell.com>

* carbonFunction.cs:  Rework the clipping interaction with
CoreGraphics.  Our old method was buggy in certain cases causing
improper / inefficient clip handling.

svn path=/trunk/mcs/; revision=94533

mcs/class/System.Drawing/System.Drawing/ChangeLog
mcs/class/System.Drawing/System.Drawing/carbonFunctions.cs

index 60c364c9652edf76c2eca7580030276db1f14123..5e391abb88f1a43eff3fda11b78a3f3b4dbb2b4b 100644 (file)
@@ -1,3 +1,9 @@
+2008-02-01  Geoff Norton  <gnorton@novell.com>
+
+       * carbonFunction.cs:  Rework the clipping interaction with 
+       CoreGraphics.  Our old method was buggy in certain cases causing
+       improper / inefficient clip handling.
+
 2008-01-23  Geoff Norton  <gnorton@novell.com>
 
        * carbonFunction.cs:  Remove some debug code.  Thanks spouliot.
index 1f3525564472d633b6fc857dcb1a5cf90b806324..97beb6e66f13b3c3a29eb7260e68a0d3f84a2e96 100644 (file)
@@ -87,13 +87,10 @@ namespace System.Drawing {
                        CGContextTranslateCTM (context, view_bounds.origin.x, (window_bounds.bottom - window_bounds.top) - (view_bounds.origin.y + view_bounds.size.height));
 
                        // Create the original rect path and clip to it
-                       IntPtr clip_path = CGPathCreateMutable ();
                        Rect rc_clip = new Rect (0, 0, view_bounds.size.width, view_bounds.size.height);
-                       CGPathAddRect (clip_path, IntPtr.Zero, rc_clip);
-                       CGContextBeginPath (context);
 
                        Rectangle [] clip_rectangles = (Rectangle []) hwnd_delegate.DynamicInvoke (new object [] {handle});
-                       if (clip_rectangles != null) {
+                       if (clip_rectangles != null && clip_rectangles.Length > 0) {
                                int length = clip_rectangles.Length;
                                Rect [] clip_rects = new Rect [length];
                                for (int i = 0; i < length; i++) {
@@ -104,9 +101,16 @@ namespace System.Drawing {
                                        clip_rects [i].size.width = r.Width; 
                                        clip_rects [i].size.height = r.Height; 
                                }
-                               CGPathAddRects (clip_path, IntPtr.Zero, clip_rects, length);
-                               CGContextAddPath (context, clip_path);
+                               CGContextBeginPath (context);
+                               CGContextAddRect (context, rc_clip);
+                               CGContextAddRects (context, clip_rects, length);
+                               CGContextClosePath (context);
                                CGContextEOClip (context);
+                       } else {
+                               CGContextBeginPath (context);
+                               CGContextAddRect (context, rc_clip);
+                               CGContextClosePath (context);
+                               CGContextClip (context);
                        }
 
                        return new CarbonContext (port, context, (int)view_bounds.size.width, (int)view_bounds.size.height);
@@ -197,8 +201,14 @@ namespace System.Drawing {
                [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
                internal static extern void CGPathAddRect (IntPtr path, IntPtr _void, Rect rect);
                [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+               internal static extern void CGContextAddRects (IntPtr context, Rect [] rects, int count);
+               [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+               internal static extern void CGContextAddRect (IntPtr context, Rect rect);
+               [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
                internal static extern void CGContextBeginPath (IntPtr context);
                [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+               internal static extern void CGContextClosePath (IntPtr context);
+               [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
                internal static extern void CGContextAddPath (IntPtr context, IntPtr path);
                [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
                internal static extern void CGContextClip (IntPtr context);