xwayland: Add arguments to glamor_pixmap_get_wl_buffer

Add arguments to give the caller more information and control
over the creation of a wl_buffer with GBM, in particular let
the caller determine the size of the buffer.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
Roman Gilg 2018-03-13 16:00:52 +01:00 committed by Adam Jackson
parent 902429f077
commit 8fba2a03f1
3 changed files with 25 additions and 8 deletions

View File

@ -158,7 +158,10 @@ xwl_glamor_create_pixmap_for_bo(ScreenPtr screen, struct gbm_bo *bo, int depth)
}
struct wl_buffer *
xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap)
xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap,
unsigned short width,
unsigned short height,
Bool *created)
{
struct xwl_screen *xwl_screen = xwl_screen_get(pixmap->drawable.pScreen);
struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
@ -169,8 +172,16 @@ xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap)
uint64_t modifier;
int i;
if (xwl_pixmap->buffer)
if (xwl_pixmap->buffer) {
/* Buffer already exists. Return it and inform caller if interested. */
if (created)
*created = FALSE;
return xwl_pixmap->buffer;
}
/* Buffer does not exist yet. Create now and inform caller if interested. */
if (created)
*created = TRUE;
if (!xwl_pixmap->bo)
return NULL;
@ -205,16 +216,16 @@ xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap)
xwl_pixmap->buffer =
zwp_linux_buffer_params_v1_create_immed(params,
pixmap->drawable.width,
pixmap->drawable.height,
width,
height,
wl_drm_format_for_depth(pixmap->drawable.depth),
0);
zwp_linux_buffer_params_v1_destroy(params);
} else if (num_planes == 1) {
xwl_pixmap->buffer =
wl_drm_create_prime_buffer(xwl_screen->drm, prime_fd,
pixmap->drawable.width,
pixmap->drawable.height,
width,
height,
wl_drm_format_for_depth(pixmap->drawable.depth),
0, gbm_bo_get_stride(xwl_pixmap->bo),
0, 0,

View File

@ -649,7 +649,10 @@ xwl_window_post_damage(struct xwl_window *xwl_window)
#ifdef GLAMOR_HAS_GBM
if (xwl_screen->glamor)
buffer = xwl_glamor_pixmap_get_wl_buffer(pixmap);
buffer = xwl_glamor_pixmap_get_wl_buffer(pixmap,
pixmap->drawable.width,
pixmap->drawable.height,
NULL);
else
#endif
buffer = xwl_shm_pixmap_get_wl_buffer(pixmap);

View File

@ -341,7 +341,10 @@ Bool xwl_screen_set_drm_interface(struct xwl_screen *xwl_screen,
uint32_t id, uint32_t version);
Bool xwl_screen_set_dmabuf_interface(struct xwl_screen *xwl_screen,
uint32_t id, uint32_t version);
struct wl_buffer *xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap);
struct wl_buffer *xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap,
unsigned short width,
unsigned short height,
Bool *created);
void xwl_screen_release_tablet_manager(struct xwl_screen *xwl_screen);