summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Gilg <subdiff@gmail.com>2018-03-13 16:00:52 +0100
committerAdam Jackson <ajax@redhat.com>2018-03-28 14:36:45 -0400
commit8fba2a03f1410f3bc7504e218ac1e5c964279ea2 (patch)
tree62c102f710f76608a95948a3ac806909c1711124
parent902429f077325b98e30ede2710bd7a88440d2937 (diff)
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>
-rw-r--r--hw/xwayland/xwayland-glamor.c23
-rw-r--r--hw/xwayland/xwayland.c5
-rw-r--r--hw/xwayland/xwayland.h5
3 files changed, 25 insertions, 8 deletions
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 4de3beb9d..7e9815626 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -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,
diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index d6a2887ac..f3fd49764 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -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);
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
index 36ebeaa83..49fb5ba28 100644
--- a/hw/xwayland/xwayland.h
+++ b/hw/xwayland/xwayland.h
@@ -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);