diff options
author | Benjamin Otte <otte@redhat.com> | 2018-04-09 00:58:31 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2018-04-09 01:00:31 +0200 |
commit | bb8f6f87ae0fa65c1f9747e5bc6978d790d6230a (patch) | |
tree | 1c626d8dd9b478b0e82b46d0bc72863d34795613 | |
parent | c8e38c606536316e25ad565755a2163b3320afe7 (diff) | |
download | gtk+-bb8f6f87ae0fa65c1f9747e5bc6978d790d6230a.tar.gz |
glcontext: Store the buffer age regions in the GL context
That way, we can store the right region there: The actual painted area
instead of the exposed area (which is way too small).
Also, the GL context is the only user of this data, so storing it there
seems way smarter.
-rw-r--r-- | gdk/gdkglcontext.c | 27 | ||||
-rw-r--r-- | gdk/gdkglcontextprivate.h | 3 | ||||
-rw-r--r-- | gdk/gdkinternals.h | 2 | ||||
-rw-r--r-- | gdk/gdksurface.c | 30 | ||||
-rw-r--r-- | gdk/wayland/gdkglcontext-wayland.c | 12 | ||||
-rw-r--r-- | gdk/x11/gdkglcontext-x11.c | 13 |
6 files changed, 42 insertions, 45 deletions
diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c index b3703eef34..07f25aadfb 100644 --- a/gdk/gdkglcontext.c +++ b/gdk/gdkglcontext.c @@ -134,12 +134,25 @@ G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkGLContext, gdk_gl_context, GDK_TYPE_DRAW static GPrivate thread_current_context = G_PRIVATE_INIT (g_object_unref); static void +gdk_gl_context_clear_old_updated_area (GdkGLContext *context) +{ + int i; + + for (i = 0; i < 2; i++) + { + g_clear_pointer (&context->old_updated_area[i], cairo_region_destroy); + } +} + +static void gdk_gl_context_dispose (GObject *gobject) { GdkGLContext *context = GDK_GL_CONTEXT (gobject); GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context); GdkGLContext *current; + gdk_gl_context_clear_old_updated_area (context); + current = g_private_get (&thread_current_context); if (current == context) g_private_replace (&thread_current_context, NULL); @@ -325,6 +338,19 @@ gdk_gl_context_real_end_frame (GdkDrawContext *draw_context, gdk_draw_context_end_frame (GDK_DRAW_CONTEXT (shared), painted, damage); return; } + + if (context->old_updated_area[1]) + cairo_region_destroy (context->old_updated_area[1]); + context->old_updated_area[1] = context->old_updated_area[0]; + context->old_updated_area[0] = cairo_region_reference (painted); +} + +static void +gdk_gl_context_surface_resized (GdkDrawContext *draw_context) +{ + GdkGLContext *context = GDK_GL_CONTEXT (draw_context); + + gdk_gl_context_clear_old_updated_area (context); } static void @@ -338,6 +364,7 @@ gdk_gl_context_class_init (GdkGLContextClass *klass) draw_context_class->begin_frame = gdk_gl_context_real_begin_frame; draw_context_class->end_frame = gdk_gl_context_real_end_frame; + draw_context_class->surface_resized = gdk_gl_context_surface_resized; /** * GdkGLContext:shared-context: diff --git a/gdk/gdkglcontextprivate.h b/gdk/gdkglcontextprivate.h index cf834da3a7..7fe2d008cf 100644 --- a/gdk/gdkglcontextprivate.h +++ b/gdk/gdkglcontextprivate.h @@ -35,6 +35,9 @@ typedef struct _GdkGLContextClass GdkGLContextClass; struct _GdkGLContext { GdkDrawContext parent_instance; + + /* We store the old drawn areas to support buffer-age optimizations */ + cairo_region_t *old_updated_area[2]; }; struct _GdkGLContextClass diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h index 4a56b91c1d..95ac10cb9d 100644 --- a/gdk/gdkinternals.h +++ b/gdk/gdkinternals.h @@ -177,8 +177,6 @@ struct _GdkSurface started. It may be smaller than the expose area if we'e painting more than we have to, but it represents the "true" damage. */ cairo_region_t *active_update_area; - /* We store the old expose areas to support buffer-age optimizations */ - cairo_region_t *old_updated_area[2]; GdkSurfaceState old_state; GdkSurfaceState state; diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c index d9bbcb7534..57dd82fab3 100644 --- a/gdk/gdksurface.c +++ b/gdk/gdksurface.c @@ -594,31 +594,6 @@ recompute_visible_regions (GdkSurface *private, recalculate_children); } -static void -gdk_surface_clear_old_updated_area (GdkSurface *surface) -{ - int i; - - for (i = 0; i < 2; i++) - { - if (surface->old_updated_area[i]) - { - cairo_region_destroy (surface->old_updated_area[i]); - surface->old_updated_area[i] = NULL; - } - } -} - -static void -gdk_surface_append_old_updated_area (GdkSurface *surface, - cairo_region_t *region) -{ - if (surface->old_updated_area[1]) - cairo_region_destroy (surface->old_updated_area[1]); - surface->old_updated_area[1] = surface->old_updated_area[0]; - surface->old_updated_area[0] = cairo_region_reference (region); -} - void _gdk_surface_update_size (GdkSurface *surface) { @@ -627,7 +602,6 @@ _gdk_surface_update_size (GdkSurface *surface) for (l = surface->draw_contexts; l; l = l->next) gdk_draw_context_surface_resized (l->data); - gdk_surface_clear_old_updated_area (surface); recompute_visible_regions (surface, FALSE); } @@ -2120,8 +2094,6 @@ gdk_surface_process_updates_internal (GdkSurface *surface) gdk_surface_process_updates_recurse (surface, expose_region); - gdk_surface_append_old_updated_area (surface, surface->active_update_area); - cairo_region_destroy (expose_region); } @@ -3035,7 +3007,6 @@ G_GNUC_END_IGNORE_DEPRECATIONS impl_class->hide (surface); } - gdk_surface_clear_old_updated_area (surface); recompute_visible_regions (surface, FALSE); if (was_mapped && !gdk_surface_has_impl (surface)) @@ -3093,7 +3064,6 @@ gdk_surface_withdraw (GdkSurface *surface) gdk_gl_context_clear_current (); recompute_visible_regions (surface, FALSE); - gdk_surface_clear_old_updated_area (surface); } } diff --git a/gdk/wayland/gdkglcontext-wayland.c b/gdk/wayland/gdkglcontext-wayland.c index 700baa02d6..3db9db5ac4 100644 --- a/gdk/wayland/gdkglcontext-wayland.c +++ b/gdk/wayland/gdkglcontext-wayland.c @@ -184,16 +184,16 @@ gdk_wayland_gl_context_get_damage (GdkGLContext *context) if (buffer_age == 2) { - if (surface->old_updated_area[0]) - return cairo_region_copy (surface->old_updated_area[0]); + if (context->old_updated_area[0]) + return cairo_region_copy (context->old_updated_area[0]); } else if (buffer_age == 3) { - if (surface->old_updated_area[0] && - surface->old_updated_area[1]) + if (context->old_updated_area[0] && + context->old_updated_area[1]) { - cairo_region_t *damage = cairo_region_copy (surface->old_updated_area[0]); - cairo_region_union (damage, surface->old_updated_area[1]); + cairo_region_t *damage = cairo_region_copy (context->old_updated_area[0]); + cairo_region_union (damage, context->old_updated_area[1]); return damage; } } diff --git a/gdk/x11/gdkglcontext-x11.c b/gdk/x11/gdkglcontext-x11.c index 8eca015b1c..dc89483311 100644 --- a/gdk/x11/gdkglcontext-x11.c +++ b/gdk/x11/gdkglcontext-x11.c @@ -196,7 +196,6 @@ gdk_x11_gl_context_get_damage (GdkGLContext *context) GdkDisplay *display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context)); GdkX11Display *display_x11 = GDK_X11_DISPLAY (display); Display *dpy = gdk_x11_display_get_xdisplay (display); - GdkSurface *surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context)); unsigned int buffer_age = 0; if (display_x11->has_glx_buffer_age) @@ -215,16 +214,16 @@ gdk_x11_gl_context_get_damage (GdkGLContext *context) if (buffer_age == 2) { - if (surface->old_updated_area[0]) - return cairo_region_copy (surface->old_updated_area[0]); + if (context->old_updated_area[0]) + return cairo_region_copy (context->old_updated_area[0]); } else if (buffer_age == 3) { - if (surface->old_updated_area[0] && - surface->old_updated_area[1]) + if (context->old_updated_area[0] && + context->old_updated_area[1]) { - cairo_region_t *damage = cairo_region_copy (surface->old_updated_area[0]); - cairo_region_union (damage, surface->old_updated_area[1]); + cairo_region_t *damage = cairo_region_copy (context->old_updated_area[0]); + cairo_region_union (damage, context->old_updated_area[1]); return damage; } } |