summaryrefslogtreecommitdiff
path: root/glamor
diff options
context:
space:
mode:
authorDaniel Stone <daniels@collabora.com>2018-04-04 16:16:38 +0100
committerAdam Jackson <ajax@redhat.com>2018-04-04 13:46:57 -0400
commit23c67987a337beb91292f8e318d566941453baa3 (patch)
treeddcf02e5d6862dee2b49a8794299aeef83c69106 /glamor
parent9c407f0a1b40128fc65b19b6a499f1d4dae6f702 (diff)
glamor: Add fd_from_pixmap hook
Add a fd_from_pixmap (singular) hook to go with fds_from_pixmap, which will ensure that the pixmap is allocated without modifiers and is thus exportable to non-modifier-aware clients. This makes it possible to run a compositing manager on an old GLX/EGL stack on top of an X server which allocates internal buffer storage using exotic modifiers from modifier-aware GBM/EGL/KMS. Signed-off-by: Daniel Stone <daniels@collabora.com> Reported-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
Diffstat (limited to 'glamor')
-rw-r--r--glamor/glamor_egl.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 2dffbb8dc..5a47dbd91 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -402,6 +402,32 @@ glamor_egl_fds_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, int *fds,
#endif
}
+static int
+glamor_egl_fd_from_pixmap(ScreenPtr screen, PixmapPtr pixmap,
+ CARD16 *stride, CARD32 *size)
+{
+#ifdef GLAMOR_HAS_GBM
+ struct gbm_bo *bo;
+ int fd;
+
+ if (!glamor_make_pixmap_exportable(pixmap, FALSE))
+ return -1;
+
+ bo = glamor_gbm_bo_from_pixmap(screen, pixmap);
+ if (!bo)
+ return -1;
+
+ fd = gbm_bo_get_fd(bo);
+ *stride = gbm_bo_get_stride(bo);
+ *size = *stride * gbm_bo_get_height(bo);
+ gbm_bo_destroy(bo);
+
+ return fd;
+#else
+ return -1;
+#endif
+}
+
int
glamor_egl_fd_name_from_pixmap(ScreenPtr screen,
PixmapPtr pixmap,
@@ -775,6 +801,7 @@ static dri3_screen_info_rec glamor_dri3_info = {
.version = 2,
.open_client = glamor_dri3_open_client,
.pixmap_from_fds = glamor_pixmap_from_fds,
+ .fd_from_pixmap = glamor_egl_fd_from_pixmap,
.fds_from_pixmap = glamor_egl_fds_from_pixmap,
.get_formats = glamor_get_formats,
.get_modifiers = glamor_get_modifiers,