[Mesa-dev] [PATCH 08/11] egl/wayland: Make create_wl_buffer more generic

Lucas Stach l.stach at pengutronix.de
Wed Jun 28 15:11:19 UTC 2017


Am Freitag, den 16.06.2017, 18:14 +0100 schrieb Daniel Stone:
> Remove surface-specific code from create_wl_buffer, so it's now just a
> generic translation from DRIimage to wl_buffer.
> 
> Signed-off-by: Daniel Stone <daniels at collabora.com>

Reviewed-by: Lucas Stach <l.stach at pengutronix.de>

> ---
>  src/egl/drivers/dri2/platform_wayland.c | 66 +++++++++++++++++----------------
>  1 file changed, 34 insertions(+), 32 deletions(-)
> 
> diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
> index c1cbb11f26..7a85cb1073 100644
> --- a/src/egl/drivers/dri2/platform_wayland.c
> +++ b/src/egl/drivers/dri2/platform_wayland.c
> @@ -642,51 +642,40 @@ static const struct wl_callback_listener throttle_listener = {
>     .done = wayland_throttle_callback
>  };
>  
> -static void
> -create_wl_buffer(struct dri2_egl_surface *dri2_surf)
> +static struct wl_buffer *
> +create_wl_buffer(struct dri2_egl_display *dri2_dpy,
> +                 struct dri2_egl_surface *dri2_surf,
> +                 __DRIimage *image)
>  {
> -   struct dri2_egl_display *dri2_dpy =
> -      dri2_egl_display(dri2_surf->base.Resource.Display);
> -   __DRIimage *image;
> +   struct wl_buffer *ret;
>     int fd, stride, name;
>  
> -   if (dri2_surf->current->wl_buffer != NULL)
> -      return;
> -
> -   if (dri2_dpy->is_different_gpu) {
> -      image = dri2_surf->current->linear_copy;
> -   } else {
> -      image = dri2_surf->current->dri_image;
> -   }
>     if (dri2_dpy->capabilities & WL_DRM_CAPABILITY_PRIME) {
>        dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_FD, &fd);
>        dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_STRIDE, &stride);
>  
> -      dri2_surf->current->wl_buffer =
> -         wl_drm_create_prime_buffer(dri2_surf->wl_drm_wrapper,
> -                                    fd,
> -                                    dri2_surf->base.Width,
> -                                    dri2_surf->base.Height,
> -                                    dri2_surf->format,
> -                                    0, stride,
> -                                    0, 0,
> -                                    0, 0);
> +      ret = wl_drm_create_prime_buffer(dri2_surf->wl_drm_wrapper,
> +                                       fd,
> +                                       dri2_surf->base.Width,
> +                                       dri2_surf->base.Height,
> +                                       dri2_surf->format,
> +                                       0, stride,
> +                                       0, 0,
> +                                       0, 0);
>        close(fd);
>     } else {
>        dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_NAME, &name);
>        dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_STRIDE, &stride);
>  
> -      dri2_surf->current->wl_buffer =
> -         wl_drm_create_buffer(dri2_surf->wl_drm_wrapper,
> -                              name,
> -                              dri2_surf->base.Width,
> -                              dri2_surf->base.Height,
> -                              stride,
> -                              dri2_surf->format);
> +      ret = wl_drm_create_buffer(dri2_surf->wl_drm_wrapper,
> +                                 name,
> +                                 dri2_surf->base.Width,
> +                                 dri2_surf->base.Height,
> +                                 stride,
> +                                 dri2_surf->format);
>     }
>  
> -   wl_buffer_add_listener(dri2_surf->current->wl_buffer,
> -                          &wl_buffer_listener, dri2_surf);
> +   return ret;
>  }
>  
>  static EGLBoolean
> @@ -751,7 +740,20 @@ dri2_wl_swap_buffers_with_damage(_EGLDriver *drv,
>     dri2_surf->current = dri2_surf->back;
>     dri2_surf->back = NULL;
>  
> -   create_wl_buffer(dri2_surf);
> +   if (!dri2_surf->current->wl_buffer) {
> +      __DRIimage *image;
> +
> +      if (dri2_dpy->is_different_gpu)
> +         image = dri2_surf->current->linear_copy;
> +      else
> +         image = dri2_surf->current->dri_image;
> +
> +      dri2_surf->current->wl_buffer =
> +         create_wl_buffer(dri2_dpy, dri2_surf, image);
> +
> +      wl_buffer_add_listener(dri2_surf->current->wl_buffer,
> +                             &wl_buffer_listener, dri2_surf);
> +   }
>  
>     wl_surface_attach(dri2_surf->wl_surface_wrapper,
>                       dri2_surf->current->wl_buffer,




More information about the mesa-dev mailing list