aboutsummaryrefslogtreecommitdiff
path: root/render/gles2
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-05-23 00:03:26 +0100
committeremersion <contact@emersion.fr>2018-05-29 18:47:17 +0100
commit5ba1a9af5652aa2407738ec6290e7a9a59a86ea6 (patch)
tree13b44184db8f3e2b32f1b1205aa6a9997065dab8 /render/gles2
parentbd430b8620f5dec485e49269d6add8dc3c20a8ab (diff)
render: add wlr_texture_to_dmabuf
Diffstat (limited to 'render/gles2')
-rw-r--r--render/gles2/texture.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/render/gles2/texture.c b/render/gles2/texture.c
index 37424802..742f9da0 100644
--- a/render/gles2/texture.c
+++ b/render/gles2/texture.c
@@ -74,6 +74,34 @@ static bool gles2_texture_write_pixels(struct wlr_texture *wlr_texture,
return true;
}
+static bool gles2_texture_to_dmabuf(struct wlr_texture *wlr_texture,
+ struct wlr_dmabuf_buffer_attribs *attribs) {
+ struct wlr_gles2_texture *texture = gles2_get_texture(wlr_texture);
+
+ if (!texture->image) {
+ assert(texture->type == WLR_GLES2_TEXTURE_GLTEX);
+
+ if (!eglCreateImageKHR) {
+ return false;
+ }
+
+ texture->image = eglCreateImageKHR(texture->egl->display,
+ texture->egl->context, EGL_GL_TEXTURE_2D_KHR,
+ (EGLClientBuffer)(uintptr_t)texture->gl_tex, NULL);
+ if (texture->image == EGL_NO_IMAGE_KHR) {
+ return false;
+ }
+ }
+
+ uint32_t flags = 0;
+ if (texture->inverted_y) {
+ flags |= WLR_DMABUF_BUFFER_ATTRIBS_FLAGS_Y_INVERT;
+ }
+
+ return wlr_egl_export_image_to_dmabuf(texture->egl, texture->image,
+ texture->width, texture->height, flags, attribs);
+}
+
static void gles2_texture_destroy(struct wlr_texture *wlr_texture) {
if (wlr_texture == NULL) {
return;
@@ -102,6 +130,7 @@ static void gles2_texture_destroy(struct wlr_texture *wlr_texture) {
static const struct wlr_texture_impl texture_impl = {
.get_size = gles2_texture_get_size,
.write_pixels = gles2_texture_write_pixels,
+ .to_dmabuf = gles2_texture_to_dmabuf,
.destroy = gles2_texture_destroy,
};