Don't use drawable_get,release_context in _gdk_windowing_create_cairo_surface

This fixes a mismatch in save/release gstate for the CGContext. If
this function is ever used for pixmaps, we need to add support for
that, probably will have to do so soon.
This commit is contained in:
Richard Hult 2009-01-20 14:04:03 +01:00 committed by Alexander Larsson
parent edb35763a2
commit 348abef6f2

View File

@ -45,12 +45,21 @@ _gdk_windowing_create_cairo_surface (GdkDrawable *drawable,
int height)
{
CGContextRef cg_context;
cairo_surface_t *surface;
cg_context = gdk_quartz_drawable_get_context (drawable, TRUE);
/* FIXME: Can this ever be called on a non-window drawable? If so we
* need to check whether it's a window or pixmap and get the right
* kind of context, and also release it in destroy below (for bitmap
* context).
*/
cg_context = [[NSGraphicsContext currentContext] graphicsPort];
if (!cg_context)
return NULL;
return cairo_quartz_surface_create_for_cg_context (cg_context, width, height);
surface = cairo_quartz_surface_create_for_cg_context (cg_context, width, height);
return surface;
}
static void
@ -59,9 +68,6 @@ gdk_quartz_cairo_surface_destroy (void *data)
GdkQuartzCairoSurfaceData *surface_data = data;
GdkDrawableImplQuartz *impl = GDK_DRAWABLE_IMPL_QUARTZ (surface_data->drawable);
gdk_quartz_drawable_release_context (surface_data->drawable,
surface_data->cg_context);
impl->cairo_surface = NULL;
g_free (surface_data);
@ -204,8 +210,6 @@ gdk_quartz_draw_arc (GdkDrawable *drawable,
GDK_QUARTZ_CONTEXT_FILL :
GDK_QUARTZ_CONTEXT_STROKE);
CGContextSaveGState (context);
start_angle = angle1 * 2.0 * G_PI / 360.0 / 64.0;
end_angle = start_angle + angle2 * 2.0 * G_PI / 360.0 / 64.0;
@ -254,8 +258,6 @@ gdk_quartz_draw_arc (GdkDrawable *drawable,
CGContextStrokePath (context);
}
CGContextRestoreGState (context);
gdk_quartz_drawable_release_context (drawable, context);
}