gdk: Try harder at tracking drawing contexts

If gdk_cairo_create() is called within a frame draw operation, we can
still associate the Cairo context with a GdkDrawingContext.
This commit is contained in:
Emmanuele Bassi 2016-06-10 17:00:29 +01:00
parent 32a37351cf
commit 222bcf1a71
3 changed files with 10 additions and 11 deletions

View File

@ -180,7 +180,7 @@ gdk_drawing_context_init (GdkDrawingContext *self)
static const cairo_user_data_key_t draw_context_key;
static void
void
gdk_cairo_set_drawing_context (cairo_t *cr,
GdkDrawingContext *context)
{

View File

@ -451,6 +451,8 @@ void gdk_cairo_surface_mark_as_direct (cairo_surface_t *surface,
GdkWindow *window);
cairo_region_t *gdk_cairo_region_from_clip (cairo_t *cr);
void gdk_cairo_set_drawing_context (cairo_t *cr,
GdkDrawingContext *context);
/*************************************
* Interfaces used by windowing code *

View File

@ -3553,20 +3553,17 @@ gdk_cairo_create (GdkWindow *window)
cr = cairo_create (surface);
if (window->impl_window->current_paint.region != NULL)
{
region = cairo_region_copy (window->impl_window->current_paint.region);
cairo_region_translate (region, -window->abs_x, -window->abs_y);
}
else
{
region = cairo_region_copy (window->clip_region);
}
region = gdk_window_get_current_paint_region (window);
gdk_cairo_region (cr, region);
cairo_region_destroy (region);
cairo_clip (cr);
/* Assign a drawing context, if one is set; if gdk_cairo_create()
* is called outside of a frame drawing then this is going to be
* NULL.
*/
gdk_cairo_set_drawing_context (cr, window->drawing_context);
cairo_surface_destroy (surface);
return cr;