aboutsummaryrefslogtreecommitdiff
path: root/render/egl.c
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2018-06-24 18:16:42 -0400
committerTony Crisci <tony@dubstepdish.com>2018-06-24 18:16:42 -0400
commite8c0996b93c2d184d9d68ae4bee92dd4c469685c (patch)
treede9e94484a8f341836231af6d8a7daa3cd32d06e /render/egl.c
parent28d718c0ddd8f2ba083be374f3d97e4836f615d9 (diff)
parente459fe0ec713ea65b35b966f9bb3c6c70c9504aa (diff)
Merge branch 'master' into cancel-grab-on-focus-change
Diffstat (limited to 'render/egl.c')
-rw-r--r--render/egl.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/render/egl.c b/render/egl.c
index 450562db..7f910e86 100644
--- a/render/egl.c
+++ b/render/egl.c
@@ -164,6 +164,11 @@ bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *remote_display,
egl->exts.image_dmabuf_import_modifiers_ext =
check_egl_ext(egl->exts_str, "EGL_EXT_image_dma_buf_import_modifiers")
&& eglQueryDmaBufFormatsEXT && eglQueryDmaBufModifiersEXT;
+
+ egl->exts.image_dma_buf_export_mesa =
+ check_egl_ext(egl->exts_str, "EGL_MESA_image_dma_buf_export") &&
+ eglExportDMABUFImageQueryMESA && eglExportDMABUFImageMESA;
+
print_dmabuf_formats(egl);
egl->exts.bind_wayland_display_wl =
@@ -511,6 +516,37 @@ int wlr_egl_get_dmabuf_modifiers(struct wlr_egl *egl,
return num;
}
+bool wlr_egl_export_image_to_dmabuf(struct wlr_egl *egl, EGLImageKHR image,
+ int32_t width, int32_t height, uint32_t flags,
+ struct wlr_dmabuf_attributes *attribs) {
+ memset(attribs, 0, sizeof(struct wlr_dmabuf_attributes));
+
+ if (!egl->exts.image_dma_buf_export_mesa) {
+ return false;
+ }
+
+ // Only one set of modifiers is returned for all planes
+ if (!eglExportDMABUFImageQueryMESA(egl->display, image,
+ (int *)&attribs->format, &attribs->n_planes, &attribs->modifier)) {
+ return false;
+ }
+ if (attribs->n_planes > WLR_DMABUF_MAX_PLANES) {
+ wlr_log(L_ERROR, "EGL returned %d planes, but only %d are supported",
+ attribs->n_planes, WLR_DMABUF_MAX_PLANES);
+ return false;
+ }
+
+ if (!eglExportDMABUFImageMESA(egl->display, image, attribs->fd,
+ (EGLint *)attribs->stride, (EGLint *)attribs->offset)) {
+ return false;
+ }
+
+ attribs->width = width;
+ attribs->height = height;
+ attribs->flags = flags;
+ return true;
+}
+
bool wlr_egl_destroy_surface(struct wlr_egl *egl, EGLSurface surface) {
if (!surface) {
return true;