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
This commit is contained in:
Timm Bäder 2018-11-30 13:14:00 +01:00
parent 538491efa1
commit 94745241c2
2 changed files with 49 additions and 30 deletions

View File

@ -170,7 +170,7 @@ gdk_wayland_gl_context_get_damage (GdkGLContext *context)
{ {
GdkGLContext *shared; GdkGLContext *shared;
GdkWaylandGLContext *shared_wayland; GdkWaylandGLContext *shared_wayland;
shared = gdk_gl_context_get_shared_context (context); shared = gdk_gl_context_get_shared_context (context);
if (shared == NULL) if (shared == NULL)
shared = context; shared = context;
@ -182,20 +182,29 @@ gdk_wayland_gl_context_get_damage (GdkGLContext *context)
eglQuerySurface (display_wayland->egl_display, egl_surface, eglQuerySurface (display_wayland->egl_display, egl_surface,
EGL_BUFFER_AGE_EXT, &buffer_age); EGL_BUFFER_AGE_EXT, &buffer_age);
if (buffer_age == 2) switch (buffer_age)
{ {
if (context->old_updated_area[0]) case 1:
return cairo_region_copy (context->old_updated_area[0]); return cairo_region_create ();
} break;
else if (buffer_age == 3)
{ case 2:
if (context->old_updated_area[0] && if (context->old_updated_area[0])
context->old_updated_area[1]) return cairo_region_copy (context->old_updated_area[0]);
{ break;
cairo_region_t *damage = cairo_region_copy (context->old_updated_area[0]);
cairo_region_union (damage, context->old_updated_area[1]); case 3:
return damage; 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:
;
} }
} }

View File

@ -201,31 +201,41 @@ gdk_x11_gl_context_get_damage (GdkGLContext *context)
{ {
GdkGLContext *shared; GdkGLContext *shared;
GdkX11GLContext *shared_x11; GdkX11GLContext *shared_x11;
shared = gdk_gl_context_get_shared_context (context); shared = gdk_gl_context_get_shared_context (context);
if (shared == NULL) if (shared == NULL)
shared = context; shared = context;
shared_x11 = GDK_X11_GL_CONTEXT (shared); shared_x11 = GDK_X11_GL_CONTEXT (shared);
gdk_gl_context_make_current (shared); gdk_gl_context_make_current (shared);
glXQueryDrawable(dpy, shared_x11->attached_drawable, glXQueryDrawable (dpy, shared_x11->attached_drawable,
GLX_BACK_BUFFER_AGE_EXT, &buffer_age); GLX_BACK_BUFFER_AGE_EXT, &buffer_age);
if (buffer_age == 2) switch (buffer_age)
{ {
if (context->old_updated_area[0]) case 1:
return cairo_region_copy (context->old_updated_area[0]); return cairo_region_create ();
} break;
else if (buffer_age == 3)
{ case 2:
if (context->old_updated_area[0] && if (context->old_updated_area[0])
context->old_updated_area[1]) return cairo_region_copy (context->old_updated_area[0]);
{ break;
cairo_region_t *damage = cairo_region_copy (context->old_updated_area[0]);
cairo_region_union (damage, context->old_updated_area[1]); case 3:
return damage; 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); return GDK_GL_CONTEXT_CLASS (gdk_x11_gl_context_parent_class)->get_damage (context);