#endif
{
internal IntPtr nativeObject = IntPtr.Zero;
+ internal IntPtr cgContext;
private bool disposed = false;
private static float defDpiX = 0;
private static float defDpiY = 0;
status = GDIPlus.GdipDeleteGraphics (nativeObject);
nativeObject = IntPtr.Zero;
GDIPlus.CheckStatus (status);
+ if ((GDIPlus.UseQuartzDrawable || GDIPlus.UseCocoaDrawable) && cgContext != IntPtr.Zero)
+ Carbon.CFRelease (cgContext);
disposed = true;
}
+
GC.SuppressFinalize(this);
}
Status status = GDIPlus.GdipFlush (nativeObject, intention);
GDIPlus.CheckStatus (status);
- if ((GDIPlus.UseQuartzDrawable || GDIPlus.UseCocoaDrawable) && GDIPlus.Display != IntPtr.Zero)
- Carbon.CGContextSynchronize (GDIPlus.Display);
+ if ((GDIPlus.UseQuartzDrawable || GDIPlus.UseCocoaDrawable) && cgContext != IntPtr.Zero)
+ Carbon.CGContextSynchronize (cgContext);
}
[EditorBrowsable (EditorBrowsableState.Advanced)]
IntPtr graphics;
if (GDIPlus.UseCocoaDrawable) {
- CarbonContext cgContext = Carbon.GetCGContextForNSView (hwnd);
- GDIPlus.GdipCreateFromQuartz_macosx (cgContext.ctx, cgContext.width, cgContext.height, out graphics);
+ CarbonContext context = Carbon.GetCGContextForNSView (hwnd);
+ GDIPlus.GdipCreateFromQuartz_macosx (context.ctx, context.width, context.height, out graphics);
+
+ Graphics g = new Graphics (graphics);
+ g.cgContext = context.ctx;
- GDIPlus.Display = cgContext.ctx;
- return new Graphics (graphics);
+ return g;
}
if (GDIPlus.UseQuartzDrawable) {
- CarbonContext cgContext = Carbon.GetCGContextForView (hwnd);
- GDIPlus.GdipCreateFromQuartz_macosx (cgContext.ctx, cgContext.width, cgContext.height, out graphics);
+ CarbonContext context = Carbon.GetCGContextForView (hwnd);
+ GDIPlus.GdipCreateFromQuartz_macosx (context.ctx, context.width, context.height, out graphics);
+
+ Graphics g = new Graphics (graphics);
+ g.cgContext = context.ctx;
- GDIPlus.Display = cgContext.ctx;
- return new Graphics (graphics);
+ return g;
}
if (GDIPlus.UseX11Drawable) {
if (GDIPlus.Display == IntPtr.Zero) {
[DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
internal static extern IntPtr GetWindowPort (IntPtr hWnd);
[DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int CFRelease (IntPtr cgContext);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
internal static extern int CGContextClipToRect (IntPtr cgContext, HIRect clip);
[DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
internal static extern int CGContextClipToRects (IntPtr cgContext, HIRect [] clip_rects, int count);