diff options
author | emersion <contact@emersion.fr> | 2018-05-31 12:33:27 +0100 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2018-05-31 12:33:27 +0100 |
commit | 21928cbe615184a81d157ccc68e503282efff83c (patch) | |
tree | e2523e48aadc69a109909ee37af18c76d88e4859 /render | |
parent | c844eaa1b32894417263ce2b5030033bdd7c7851 (diff) | |
parent | 32013abae63f1c31598ac716acd7e73c24fadae1 (diff) |
Merge branch 'master' into screencontent
Diffstat (limited to 'render')
-rw-r--r-- | render/dmabuf.c | 10 | ||||
-rw-r--r-- | render/egl.c | 31 | ||||
-rw-r--r-- | render/gles2/renderer.c | 8 | ||||
-rw-r--r-- | render/gles2/texture.c | 8 | ||||
-rw-r--r-- | render/meson.build | 1 | ||||
-rw-r--r-- | render/wlr_renderer.c | 4 | ||||
-rw-r--r-- | render/wlr_texture.c | 4 |
7 files changed, 36 insertions, 30 deletions
diff --git a/render/dmabuf.c b/render/dmabuf.c new file mode 100644 index 00000000..6b500748 --- /dev/null +++ b/render/dmabuf.c @@ -0,0 +1,10 @@ +#include <unistd.h> +#include <wlr/render/dmabuf.h> + +void wlr_dmabuf_attributes_finish( struct wlr_dmabuf_attributes *attribs) { + for (int i = 0; i < attribs->n_planes; ++i) { + close(attribs->fd[i]); + attribs->fd[i] = -1; + } + attribs->n_planes = 0; +} diff --git a/render/egl.c b/render/egl.c index 1182a72f..93e4ec55 100644 --- a/render/egl.c +++ b/render/egl.c @@ -344,9 +344,9 @@ EGLImageKHR wlr_egl_create_image_from_wl_drm(struct wlr_egl *egl, } EGLImageKHR wlr_egl_create_image_from_dmabuf(struct wlr_egl *egl, - struct wlr_dmabuf_buffer_attribs *attributes) { + struct wlr_dmabuf_attributes *attributes) { bool has_modifier = false; - if (attributes->modifier[0] != DRM_FORMAT_MOD_INVALID) { + if (attributes->modifier != DRM_FORMAT_MOD_INVALID) { if (!egl->egl_exts.dmabuf_import_modifiers) { return NULL; } @@ -368,7 +368,7 @@ EGLImageKHR wlr_egl_create_image_from_dmabuf(struct wlr_egl *egl, EGLint pitch; EGLint mod_lo; EGLint mod_hi; - } attr_names[WLR_LINUX_DMABUF_MAX_PLANES] = { + } attr_names[WLR_DMABUF_MAX_PLANES] = { { EGL_DMA_BUF_PLANE0_FD_EXT, EGL_DMA_BUF_PLANE0_OFFSET_EXT, @@ -405,9 +405,9 @@ EGLImageKHR wlr_egl_create_image_from_dmabuf(struct wlr_egl *egl, attribs[atti++] = attributes->stride[i]; if (has_modifier) { attribs[atti++] = attr_names[i].mod_lo; - attribs[atti++] = attributes->modifier[i] & 0xFFFFFFFF; + attribs[atti++] = attributes->modifier & 0xFFFFFFFF; attribs[atti++] = attr_names[i].mod_hi; - attribs[atti++] = attributes->modifier[i] >> 32; + attribs[atti++] = attributes->modifier >> 32; } } attribs[atti++] = EGL_NONE; @@ -421,8 +421,8 @@ EGLImageKHR wlr_egl_create_image_from_dmabuf(struct wlr_egl *egl, #define DRM_FORMAT_BIG_ENDIAN 0x80000000 #endif bool wlr_egl_check_import_dmabuf(struct wlr_egl *egl, - struct wlr_dmabuf_buffer *dmabuf) { - switch (dmabuf->attributes.format & ~DRM_FORMAT_BIG_ENDIAN) { + struct wlr_dmabuf_attributes *attribs) { + switch (attribs->format & ~DRM_FORMAT_BIG_ENDIAN) { /* TODO: YUV based formats not yet supported, require multiple * wlr_create_image_from_dmabuf */ case WL_SHM_FORMAT_YUYV: @@ -435,8 +435,7 @@ bool wlr_egl_check_import_dmabuf(struct wlr_egl *egl, break; } - EGLImage egl_image = wlr_egl_create_image_from_dmabuf(egl, - &dmabuf->attributes); + EGLImage egl_image = wlr_egl_create_image_from_dmabuf(egl, attribs); if (egl_image) { /* We can import the image, good. No need to keep it since wlr_texture_upload_dmabuf will import it again */ @@ -507,8 +506,8 @@ int wlr_egl_get_dmabuf_modifiers(struct wlr_egl *egl, 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_buffer_attribs *attribs) { - memset(attribs, 0, sizeof(struct wlr_dmabuf_buffer_attribs)); + struct wlr_dmabuf_attributes *attribs) { + memset(attribs, 0, sizeof(struct wlr_dmabuf_attributes)); if (!egl->egl_exts.dmabuf_export || !eglExportDMABUFImageQueryMESA || !eglExportDMABUFImageMESA) { @@ -516,19 +515,15 @@ bool wlr_egl_export_image_to_dmabuf(struct wlr_egl *egl, EGLImageKHR image, } // Only one set of modifiers is returned for all planes - EGLuint64KHR modifiers; if (!eglExportDMABUFImageQueryMESA(egl->display, image, - (int *)&attribs->format, &attribs->n_planes, &modifiers)) { + (int *)&attribs->format, &attribs->n_planes, &attribs->modifier)) { return false; } - if (attribs->n_planes > WLR_LINUX_DMABUF_MAX_PLANES) { + 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_LINUX_DMABUF_MAX_PLANES); + attribs->n_planes, WLR_DMABUF_MAX_PLANES); return false; } - for (int i = 0; i < attribs->n_planes; ++i) { - attribs->modifier[i] = modifiers; - } if (!eglExportDMABUFImageMESA(egl->display, image, attribs->fd, (EGLint *)attribs->stride, (EGLint *)attribs->offset)) { diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index 5cea5c3b..00a5c285 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -84,7 +84,7 @@ static void gles2_scissor(struct wlr_renderer *wlr_renderer, POP_GLES2_DEBUG; } -static void draw_quad() { +static void draw_quad(void) { GLfloat verts[] = { 1, 0, // top right 0, 0, // top left @@ -243,9 +243,9 @@ static int gles2_get_dmabuf_modifiers(struct wlr_renderer *wlr_renderer, } static bool gles2_check_import_dmabuf(struct wlr_renderer *wlr_renderer, - struct wlr_dmabuf_buffer *dmabuf) { + struct wlr_dmabuf_attributes *attribs) { struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer); - return wlr_egl_check_import_dmabuf(renderer->egl, dmabuf); + return wlr_egl_check_import_dmabuf(renderer->egl, attribs); } static bool gles2_read_pixels(struct wlr_renderer *wlr_renderer, @@ -299,7 +299,7 @@ static struct wlr_texture *gles2_texture_from_wl_drm( static struct wlr_texture *gles2_texture_from_dmabuf( struct wlr_renderer *wlr_renderer, - struct wlr_dmabuf_buffer_attribs *attribs) { + struct wlr_dmabuf_attributes *attribs) { struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer); return wlr_gles2_texture_from_dmabuf(renderer->egl, attribs); } diff --git a/render/gles2/texture.c b/render/gles2/texture.c index 742f9da0..0f061f59 100644 --- a/render/gles2/texture.c +++ b/render/gles2/texture.c @@ -75,7 +75,7 @@ static bool gles2_texture_write_pixels(struct wlr_texture *wlr_texture, } static bool gles2_texture_to_dmabuf(struct wlr_texture *wlr_texture, - struct wlr_dmabuf_buffer_attribs *attribs) { + struct wlr_dmabuf_attributes *attribs) { struct wlr_gles2_texture *texture = gles2_get_texture(wlr_texture); if (!texture->image) { @@ -95,7 +95,7 @@ static bool gles2_texture_to_dmabuf(struct wlr_texture *wlr_texture, uint32_t flags = 0; if (texture->inverted_y) { - flags |= WLR_DMABUF_BUFFER_ATTRIBS_FLAGS_Y_INVERT; + flags |= WLR_DMABUF_ATTRIBUTES_FLAGS_Y_INVERT; } return wlr_egl_export_image_to_dmabuf(texture->egl, texture->image, @@ -228,7 +228,7 @@ struct wlr_texture *wlr_gles2_texture_from_wl_drm(struct wlr_egl *egl, } struct wlr_texture *wlr_gles2_texture_from_dmabuf(struct wlr_egl *egl, - struct wlr_dmabuf_buffer_attribs *attribs) { + struct wlr_dmabuf_attributes *attribs) { assert(wlr_egl_is_current(egl)); if (!glEGLImageTargetTexture2DOES) { @@ -254,7 +254,7 @@ struct wlr_texture *wlr_gles2_texture_from_dmabuf(struct wlr_egl *egl, texture->type = WLR_GLES2_TEXTURE_DMABUF; texture->has_alpha = true; texture->inverted_y = - (attribs->flags & WLR_DMABUF_BUFFER_ATTRIBS_FLAGS_Y_INVERT) != 0; + (attribs->flags & WLR_DMABUF_ATTRIBUTES_FLAGS_Y_INVERT) != 0; texture->image = wlr_egl_create_image_from_dmabuf(egl, attribs); if (texture->image == NULL) { diff --git a/render/meson.build b/render/meson.build index 4fe9ea67..4b90c229 100644 --- a/render/meson.build +++ b/render/meson.build @@ -9,6 +9,7 @@ glapi = custom_target('glapi', lib_wlr_render = static_library( 'wlr_render', files( + 'dmabuf.c', 'egl.c', 'gles2/pixel_format.c', 'gles2/renderer.c', diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c index aed821c9..32b0a779 100644 --- a/render/wlr_renderer.c +++ b/render/wlr_renderer.c @@ -136,11 +136,11 @@ int wlr_renderer_get_dmabuf_modifiers(struct wlr_renderer *r, int format, } bool wlr_renderer_check_import_dmabuf(struct wlr_renderer *r, - struct wlr_dmabuf_buffer *dmabuf) { + struct wlr_dmabuf_attributes *attribs) { if (!r->impl->check_import_dmabuf) { return false; } - return r->impl->check_import_dmabuf(r, dmabuf); + return r->impl->check_import_dmabuf(r, attribs); } bool wlr_renderer_read_pixels(struct wlr_renderer *r, enum wl_shm_format fmt, diff --git a/render/wlr_texture.c b/render/wlr_texture.c index f7ce0b44..76986920 100644 --- a/render/wlr_texture.c +++ b/render/wlr_texture.c @@ -35,7 +35,7 @@ struct wlr_texture *wlr_texture_from_wl_drm(struct wlr_renderer *renderer, } struct wlr_texture *wlr_texture_from_dmabuf(struct wlr_renderer *renderer, - struct wlr_dmabuf_buffer_attribs *attribs) { + struct wlr_dmabuf_attributes *attribs) { if (!renderer->impl->texture_from_dmabuf) { return NULL; } @@ -56,7 +56,7 @@ bool wlr_texture_write_pixels(struct wlr_texture *texture, } bool wlr_texture_to_dmabuf(struct wlr_texture *texture, - struct wlr_dmabuf_buffer_attribs *attribs) { + struct wlr_dmabuf_attributes *attribs) { if (!texture->impl->to_dmabuf) { return false; } |