diff options
author | Benjamin Otte <otte@redhat.com> | 2018-04-21 00:47:35 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2018-04-24 23:16:58 +0200 |
commit | dbe4f1d766f0c571ea0d778cd561929c19e63c94 (patch) | |
tree | 75f7ad7544e71e4c909e340bfc72804ca946d9a1 /gdk | |
parent | e7d6648f4618ec9fb44aa218d6965e1d613718c2 (diff) | |
download | gtk+-dbe4f1d766f0c571ea0d778cd561929c19e63c94.tar.gz |
gdk: Add gdk_draw_context_get_frame_region()
This does the same as gdk_drawing_context_get_clip().
Diffstat (limited to 'gdk')
-rw-r--r-- | gdk/gdkdrawcontext.c | 23 | ||||
-rw-r--r-- | gdk/gdkdrawcontext.h | 5 | ||||
-rw-r--r-- | gdk/gdkdrawcontextprivate.h | 2 | ||||
-rw-r--r-- | gdk/gdksurface.c | 26 |
4 files changed, 36 insertions, 20 deletions
diff --git a/gdk/gdkdrawcontext.c b/gdk/gdkdrawcontext.c index 33324f44e3..45a353b086 100644 --- a/gdk/gdkdrawcontext.c +++ b/gdk/gdkdrawcontext.c @@ -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; +} diff --git a/gdk/gdkdrawcontext.h b/gdk/gdkdrawcontext.h index 70bc802c4a..5b542667cd 100644 --- a/gdk/gdkdrawcontext.h +++ b/gdk/gdkdrawcontext.h @@ -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 diff --git a/gdk/gdkdrawcontextprivate.h b/gdk/gdkdrawcontextprivate.h index 33c4b72546..242919698f 100644 --- a/gdk/gdkdrawcontextprivate.h +++ b/gdk/gdkdrawcontextprivate.h @@ -34,6 +34,8 @@ typedef struct _GdkDrawContextClass GdkDrawContextClass; struct _GdkDrawContext { GObject parent_instance; + + cairo_region_t *frame_region; }; struct _GdkDrawContextClass diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c index 6e7f125896..90486c4ed8 100644 --- a/gdk/gdksurface.c +++ b/gdk/gdksurface.c @@ -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); } |