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

@ -182,13 +182,18 @@ 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)
switch (buffer_age)
{
case 1:
return cairo_region_create ();
break;
case 2:
if (context->old_updated_area[0])
return cairo_region_copy (context->old_updated_area[0]);
}
else if (buffer_age == 3)
{
break;
case 3:
if (context->old_updated_area[0] &&
context->old_updated_area[1])
{
@ -196,6 +201,10 @@ gdk_wayland_gl_context_get_damage (GdkGLContext *context)
cairo_region_union (damage, context->old_updated_area[1]);
return damage;
}
break;
default:
;
}
}

View File

@ -211,13 +211,18 @@ gdk_x11_gl_context_get_damage (GdkGLContext *context)
glXQueryDrawable (dpy, shared_x11->attached_drawable,
GLX_BACK_BUFFER_AGE_EXT, &buffer_age);
if (buffer_age == 2)
switch (buffer_age)
{
case 1:
return cairo_region_create ();
break;
case 2:
if (context->old_updated_area[0])
return cairo_region_copy (context->old_updated_area[0]);
}
else if (buffer_age == 3)
{
break;
case 3:
if (context->old_updated_area[0] &&
context->old_updated_area[1])
{
@ -225,7 +230,12 @@ gdk_x11_gl_context_get_damage (GdkGLContext *context)
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);