[Mesa-dev] [PATCH] egl/wayland: Try to use wl_surface.damage_buffer for SwapBuffersWithDamage

Emil Velikov emil.l.velikov at gmail.com
Fri Feb 12 22:46:46 UTC 2016


On 11 February 2016 at 16:34, Derek Foreman <derekf at osg.samsung.com> wrote:
> Since commit d1314de293e9e4a63c35f094c3893aaaed8580b4 we ignore
> damage passed to SwapBuffersWithDamage.
>
> Wayland 1.10 now has functionality that allows us to properly
> process those damage rectangles, and a way to query if it's
> available.
>
> Now we can use wl_surface.damage_buffer and interpret the incoming
> damage as being in buffer co-ordinates.
>
> Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
> ---
>  src/egl/drivers/dri2/platform_wayland.c | 32 +++++++++++++++++++++++++++++---
>  1 file changed, 29 insertions(+), 3 deletions(-)
>
> diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
> index c2438f7..b5a5b59 100644
> --- a/src/egl/drivers/dri2/platform_wayland.c
> +++ b/src/egl/drivers/dri2/platform_wayland.c
> @@ -653,6 +653,30 @@ create_wl_buffer(struct dri2_egl_surface *dri2_surf)
>                            &wl_buffer_listener, dri2_surf);
>  }
>
> +static EGLBoolean
> +try_damage_buffer(struct dri2_egl_surface *dri2_surf,
> +                  const EGLint *rects,
> +                  EGLint n_rects)
> +{
> +#ifdef WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION
> +   int i;
> +
> +   if (wl_proxy_get_version((struct wl_proxy *) dri2_surf->wl_win->surface)
> +       < WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION)
> +      return EGL_FALSE;
> +
> +   for (i = 0; i < n_rects; i++) {
> +      const int *rect = &rects[i * 4];
> +
> +      wl_surface_damage_buffer(dri2_surf->wl_win->surface,
> +                               rect[0],
> +                               dri2_surf->base.Height - rect[1] - rect[3],
> +                               rect[2], rect[3]);
> +   }
> +   return EGL_TRUE;
> +#endif

I'm slightly worried about keeping this compile time. For example if
we compile against old wayland, and then run against a capable one...
this code won't exist thus will never get executed. Thus leading to a
handful of "wtf" moments.

I would just ensure it's defined at the top.

#ifndef WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION
#define WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION foo
#endif

Cheers,
Emil


More information about the mesa-dev mailing list