Commit dbe4f1d7 authored by Benjamin Otte's avatar Benjamin Otte

gdk: Add gdk_draw_context_get_frame_region()

This does the same as gdk_drawing_context_get_clip().
parent e7d6648f
......@@ -1106,6 +1106,7 @@ gdk_frame_timings_get_type
GdkDrawContext
gdk_draw_context_get_display
gdk_draw_context_get_surface
gdk_draw_context_get_frame_region
<SUBSECTION Standard>
GDK_DRAW_CONTEXT
......
......@@ -303,3 +303,26 @@ gdk_draw_context_get_surface (GdkDrawContext *context)
return priv->surface;
}
/**
* gdk_draw_context_get_frame_region:
* @context: a #GdkDrawContext
*
* Retrieves the region that is currently in the process of being repainted.
*
* After a call to gdk_draw_context_begin_frame() this function will return
* a union of the region passed to that function and the area of the surface
* that the @context determined needs to be repainted.
*
* If @context is not inbetween calls to gdk_draw_context_begin_frame() and
* gdk_draw_context_end_frame(), %NULL will be returned.
*
* Returns: (transfer none) (nullable): a Cairo region or %NULL if not drawing
* a frame.
*/
const cairo_region_t *
gdk_draw_context_get_frame_region (GdkDrawContext *context)
{
g_return_val_if_fail (GDK_IS_DRAW_CONTEXT (context), NULL);
return context->frame_region;
}
......@@ -40,7 +40,10 @@ GType gdk_draw_context_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GdkDisplay * gdk_draw_context_get_display (GdkDrawContext *context);
GDK_AVAILABLE_IN_ALL
GdkSurface * gdk_draw_context_get_surface (GdkDrawContext *context);
GdkSurface * gdk_draw_context_get_surface (GdkDrawContext *context);
GDK_AVAILABLE_IN_ALL
const cairo_region_t * gdk_draw_context_get_frame_region (GdkDrawContext *context);
G_END_DECLS
......
......@@ -34,6 +34,8 @@ typedef struct _GdkDrawContextClass GdkDrawContextClass;
struct _GdkDrawContext
{
GObject parent_instance;
cairo_region_t *frame_region;
};
struct _GdkDrawContextClass
......
......@@ -1586,7 +1586,6 @@ gdk_surface_begin_draw_frame (GdkSurface *surface,
const cairo_region_t *region)
{
GdkDrawingContext *context;
cairo_region_t *real_region;
g_return_val_if_fail (GDK_IS_SURFACE (surface), NULL);
g_return_val_if_fail (gdk_surface_has_native (surface), NULL);
......@@ -1606,21 +1605,19 @@ gdk_surface_begin_draw_frame (GdkSurface *surface,
return NULL;
}
real_region = cairo_region_copy (region);
draw_context->frame_region = cairo_region_copy (region);
gdk_draw_context_begin_frame (draw_context, real_region);
gdk_draw_context_begin_frame (draw_context, draw_context->frame_region);
context = g_object_new (GDK_TYPE_DRAWING_CONTEXT,
"surface", surface,
"paint-context", draw_context,
"clip", real_region,
"clip", draw_context->frame_region,
NULL);
/* Do not take a reference, to avoid creating cycles */
surface->drawing_context = context;
cairo_region_destroy (real_region);
return context;
}
......@@ -1659,22 +1656,13 @@ gdk_surface_end_draw_frame (GdkSurface *surface,
g_return_if_fail (surface->drawing_context == context);
paint_context = gdk_drawing_context_get_paint_context (context);
if (paint_context)
{
cairo_region_t *clip = gdk_drawing_context_get_clip (context);
gdk_draw_context_end_frame (paint_context,
clip,
surface->active_update_area);
cairo_region_destroy (clip);
}
else
{
}
gdk_draw_context_end_frame (paint_context,
paint_context->frame_region,
surface->active_update_area);
surface->drawing_context = NULL;
g_clear_pointer (&paint_context->frame_region, cairo_region_destroy);
g_object_unref (context);
}
......
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