[gtk] GdkGLContext: Fix damage computation with buffer_age
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] GdkGLContext: Fix damage computation with buffer_age
- Date: Sun, 2 Dec 2018 15:18:07 +0000 (UTC)
commit 94745241c2957794cbc1ad308f749d5d3bc7e702
Author: Timm Bäder <mail baedert org>
Date: Fri Nov 30 13:14:00 2018 +0100
GdkGLContext: Fix damage computation with buffer_age
As per the spec:
> The back buffer can
> either be reported as invalid (has an age of 0) or it may be
> reported to contain the contents from n frames prior to the
> current frame.
So a buffer age of 1 means that the buffer was used in the last frame.
We were handling buffer_age==1 the same as buffer_age==0, i.e. we
returned the full damage for the surface.
[1] https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_buffer_age.txt
gdk/wayland/gdkglcontext-wayland.c | 37 ++++++++++++++++++++-------------
gdk/x11/gdkglcontext-x11.c | 42 +++++++++++++++++++++++---------------
2 files changed, 49 insertions(+), 30 deletions(-)
---
diff --git a/gdk/wayland/gdkglcontext-wayland.c b/gdk/wayland/gdkglcontext-wayland.c
index 1e1259bbac..75c4acfd87 100644
--- a/gdk/wayland/gdkglcontext-wayland.c
+++ b/gdk/wayland/gdkglcontext-wayland.c
@@ -170,7 +170,7 @@ gdk_wayland_gl_context_get_damage (GdkGLContext *context)
{
GdkGLContext *shared;
GdkWaylandGLContext *shared_wayland;
-
+
shared = gdk_gl_context_get_shared_context (context);
if (shared == NULL)
shared = context;
@@ -182,20 +182,29 @@ gdk_wayland_gl_context_get_damage (GdkGLContext *context)
eglQuerySurface (display_wayland->egl_display, egl_surface,
EGL_BUFFER_AGE_EXT, &buffer_age);
- if (buffer_age == 2)
- {
- if (context->old_updated_area[0])
- return cairo_region_copy (context->old_updated_area[0]);
- }
- else if (buffer_age == 3)
+ switch (buffer_age)
{
- if (context->old_updated_area[0] &&
- context->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;
- }
+ case 1:
+ return cairo_region_create ();
+ break;
+
+ case 2:
+ if (context->old_updated_area[0])
+ return cairo_region_copy (context->old_updated_area[0]);
+ break;
+
+ case 3:
+ if (context->old_updated_area[0] &&
+ context->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;
+ }
+ break;
+
+ default:
+ ;
}
}
diff --git a/gdk/x11/gdkglcontext-x11.c b/gdk/x11/gdkglcontext-x11.c
index 0c8970fd5c..5de9d55cf0 100644
--- a/gdk/x11/gdkglcontext-x11.c
+++ b/gdk/x11/gdkglcontext-x11.c
@@ -201,31 +201,41 @@ gdk_x11_gl_context_get_damage (GdkGLContext *context)
{
GdkGLContext *shared;
GdkX11GLContext *shared_x11;
-
+
shared = gdk_gl_context_get_shared_context (context);
if (shared == NULL)
shared = context;
shared_x11 = GDK_X11_GL_CONTEXT (shared);
gdk_gl_context_make_current (shared);
- glXQueryDrawable(dpy, shared_x11->attached_drawable,
- GLX_BACK_BUFFER_AGE_EXT, &buffer_age);
+ glXQueryDrawable (dpy, shared_x11->attached_drawable,
+ GLX_BACK_BUFFER_AGE_EXT, &buffer_age);
- if (buffer_age == 2)
- {
- if (context->old_updated_area[0])
- return cairo_region_copy (context->old_updated_area[0]);
- }
- else if (buffer_age == 3)
+ switch (buffer_age)
{
- if (context->old_updated_area[0] &&
- context->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;
- }
+ case 1:
+ return cairo_region_create ();
+ break;
+
+ case 2:
+ if (context->old_updated_area[0])
+ return cairo_region_copy (context->old_updated_area[0]);
+ break;
+
+ case 3:
+ if (context->old_updated_area[0] &&
+ context->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;
+ }
+ break;
+
+ default:
+ ;
}
+
}
return GDK_GL_CONTEXT_CLASS (gdk_x11_gl_context_parent_class)->get_damage (context);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]