[PATCH 3/6] glamor: egl: add function to back a pixmap with a dma-buf.

Eric Anholt eric at anholt.net
Fri Jun 19 10:44:38 PDT 2015


Dave Airlie <airlied at gmail.com> writes:

> Rather than create the pixmap, this uses the file descriptor
> to change an existing pixmaps backing store.
>
> This is required for reverse prime slaves, where we create
> the slave pixmap, then set the backing store.
>
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
>  glamor/glamor.h     | 19 +++++++++++++++++++
>  glamor/glamor_egl.c | 52 +++++++++++++++++++++++++++++++++++-----------------
>  2 files changed, 54 insertions(+), 17 deletions(-)
>
> diff --git a/glamor/glamor.h b/glamor/glamor.h
> index 657354d..f402d7d 100644
> --- a/glamor/glamor.h
> +++ b/glamor/glamor.h
> @@ -218,6 +218,25 @@ extern _X_EXPORT PixmapPtr glamor_pixmap_from_fd(ScreenPtr screen,
>                                                   CARD8 depth,
>                                                   CARD8 bpp);
>  
> +/* @glamor_back_pixmap_from_fd: Backs an existing pixmap with a dma-buf fd.
> + *
> + * @pixmap: Pixmap to change backing for
> + * @fd: The dma-buf fd to import.
> + * @width: The width of the buffer.
> + * @height: The height of the buffer.
> + * @stride: The stride of the buffer.
> + * @depth: The depth of the buffer.
> + * @bpp: The number of bpp of the buffer.
> + *
> + * Returns TRUE if successful, FALSE on failure.
> + * */
> +extern _X_EXPORT Bool glamor_back_pixmap_from_fd(PixmapPtr pixmap,
> +                                                 int fd,
> +                                                 CARD16 width,
> +                                                 CARD16 height,
> +                                                 CARD16 stride,
> +                                                 CARD8 depth,
> +                                                 CARD8 bpp);
>  #ifdef GLAMOR_FOR_XORG
>  
>  #define GLAMOR_EGL_MODULE_NAME  "glamoregl"
> diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
> index 4c0db6a..994dbd2 100644
> --- a/glamor/glamor_egl.c
> +++ b/glamor/glamor_egl.c
> @@ -461,19 +461,18 @@ glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen,
>  #endif
>  }
>  
> -_X_EXPORT PixmapPtr
> -glamor_pixmap_from_fd(ScreenPtr screen,
> -                      int fd,
> -                      CARD16 width,
> -                      CARD16 height,
> -                      CARD16 stride, CARD8 depth, CARD8 bpp)
> +_X_EXPORT Bool
> +glamor_back_pixmap_from_fd(PixmapPtr pixmap,
> +                           int fd,
> +                           CARD16 width,
> +                           CARD16 height,
> +                           CARD16 stride, CARD8 depth, CARD8 bpp)
>  {
>  #ifdef GLAMOR_HAS_GBM
> -    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
> +    ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);

I slightly prefer having a local "ScreenPtr screen =
pixmap->drawable.pScreen", but either way:

Reviewed-by: Eric Anholt <eric at annholt.net>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20150619/fc6f4dfb/attachment-0001.sig>


More information about the xorg-devel mailing list