Commit 59bf3a08 authored by Emmanuele Bassi's avatar Emmanuele Bassi

gdk: Explicitly create a cairo context inside GdkDrawingContext

Instead of using gdk_cairo_create(), which we'll soon deprecate.

https://bugzilla.gnome.org/show_bug.cgi?id=766675
parent b1b0a251
......@@ -231,12 +231,21 @@ gdk_drawing_context_get_cairo_context (GdkDrawingContext *context)
if (context->cr == NULL)
{
context->cr = gdk_cairo_create (context->window);
cairo_region_t *region;
cairo_surface_t *surface;
surface = _gdk_window_ref_cairo_surface (context->window);
context->cr = cairo_create (surface);
gdk_cairo_set_drawing_context (context->cr, context);
gdk_cairo_region (context->cr, context->clip);
region = gdk_window_get_current_paint_region (context->window);
cairo_region_union (region, context->clip);
gdk_cairo_region (context->cr, region);
cairo_clip (context->cr);
cairo_region_destroy (region);
cairo_surface_destroy (surface);
}
return context->cr;
......
......@@ -472,6 +472,8 @@ void gdk_window_get_unscaled_size (GdkWindow *window,
GdkDrawingContext *gdk_window_get_drawing_context (GdkWindow *window);
cairo_region_t *gdk_window_get_current_paint_region (GdkWindow *window);
void _gdk_window_process_updates_recurse (GdkWindow *window,
cairo_region_t *expose_region);
......
......@@ -3235,6 +3235,32 @@ gdk_window_end_draw_frame (GdkWindow *window,
window->drawing_context = NULL;
}
/*< private >
* gdk_window_get_current_paint_region:
* @window: a #GdkWindow
*
* Retrieves a copy of the current paint region.
*
* Returns: (transfer full): a Cairo region
*/
cairo_region_t *
gdk_window_get_current_paint_region (GdkWindow *window)
{
cairo_region_t *region;
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);
}
return region;
}
/*< private >
* gdk_window_get_drawing_context:
* @window: a #GdkWindow
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment