From 28020ff57728d07ae0715fc15696b8fe40337b3d Mon Sep 17 00:00:00 2001 From: emersion Date: Tue, 29 May 2018 22:38:00 +0100 Subject: Only allow one modifier per DMA-BUF, split attributes struct in render/ --- render/egl.c | 19 +++++++++---------- render/gles2/renderer.c | 6 +++--- render/gles2/texture.c | 4 ++-- render/wlr_renderer.c | 4 ++-- render/wlr_texture.c | 2 +- 5 files changed, 17 insertions(+), 18 deletions(-) (limited to 'render') diff --git a/render/egl.c b/render/egl.c index 579bb5fe..6ac3ee2a 100644 --- a/render/egl.c +++ b/render/egl.c @@ -340,9 +340,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; } @@ -364,7 +364,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, @@ -401,9 +401,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; @@ -414,11 +414,11 @@ EGLImageKHR wlr_egl_create_image_from_dmabuf(struct wlr_egl *egl, } #ifndef DRM_FORMAT_BIG_ENDIAN -# define DRM_FORMAT_BIG_ENDIAN 0x80000000 +#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: @@ -431,8 +431,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 */ diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index 5cea5c3b..e68bb83f 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -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 37424802..2627e292 100644 --- a/render/gles2/texture.c +++ b/render/gles2/texture.c @@ -199,7 +199,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) { @@ -225,7 +225,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/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 9aecfd98..38c75d28 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; } -- cgit v1.2.3 From d1cf9acbd5ab6735952d013e5eb685e7139094a7 Mon Sep 17 00:00:00 2001 From: Genki Sky Date: Wed, 30 May 2018 20:11:57 -0400 Subject: cleanup: Use void for zero-parameter functions Signed-off-by: Genki Sky --- CONTRIBUTING.md | 2 +- examples/layer-shell.c | 4 ++-- examples/simple.c | 2 +- render/gles2/renderer.c | 2 +- types/wlr_cursor.c | 2 +- types/wlr_output_layout.c | 2 +- types/wlr_surface.c | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) (limited to 'render') diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 41f504bc..aca308b3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -96,7 +96,7 @@ not use GNU extensions. Brackets always go on the same line, including in functions. Always include brackets for if/while/for, even if it's a single statement. ```c -void function() { +void function(void) { if (condition1) { do_thing1(); } diff --git a/examples/layer-shell.c b/examples/layer-shell.c index ec25fe42..21ef3e93 100644 --- a/examples/layer-shell.c +++ b/examples/layer-shell.c @@ -149,7 +149,7 @@ static void draw(void) { demo.last_frame = ts; } -static void draw_popup() { +static void draw_popup(void) { static float alpha_mod = -0.01; eglMakeCurrent(egl.display, popup_egl_surface, popup_egl_surface, egl.context); @@ -188,7 +188,7 @@ static void xdg_popup_configure(void *data, struct xdg_popup *xdg_popup, } } -static void popup_destroy() { +static void popup_destroy(void) { wlr_egl_destroy_surface(&egl, popup_egl_surface); wl_egl_window_destroy(popup_egl_window); xdg_popup_destroy(popup); diff --git a/examples/simple.c b/examples/simple.c index 60acd7db..cbe60c98 100644 --- a/examples/simple.c +++ b/examples/simple.c @@ -143,7 +143,7 @@ void new_input_notify(struct wl_listener *listener, void *data) { } } -int main() { +int main(void) { wlr_log_init(L_DEBUG, NULL); struct wl_display *display = wl_display_create(); struct sample_state state = { diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index e68bb83f..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 diff --git a/types/wlr_cursor.c b/types/wlr_cursor.c index 9a31fca2..32d990cf 100644 --- a/types/wlr_cursor.c +++ b/types/wlr_cursor.c @@ -56,7 +56,7 @@ struct wlr_cursor_state { struct wl_listener layout_destroy; }; -struct wlr_cursor *wlr_cursor_create() { +struct wlr_cursor *wlr_cursor_create(void) { struct wlr_cursor *cur = calloc(1, sizeof(struct wlr_cursor)); if (!cur) { wlr_log(L_ERROR, "Failed to allocate wlr_cursor"); diff --git a/types/wlr_output_layout.c b/types/wlr_output_layout.c index 38329a48..bb1d399a 100644 --- a/types/wlr_output_layout.c +++ b/types/wlr_output_layout.c @@ -25,7 +25,7 @@ struct wlr_output_layout_output_state { struct wl_listener output_destroy; }; -struct wlr_output_layout *wlr_output_layout_create() { +struct wlr_output_layout *wlr_output_layout_create(void) { struct wlr_output_layout *layout = calloc(1, sizeof(struct wlr_output_layout)); if (layout == NULL) { diff --git a/types/wlr_surface.c b/types/wlr_surface.c index 3949f3e2..61284416 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -570,7 +570,7 @@ struct wlr_surface *wlr_surface_from_resource(struct wl_resource *resource) { return wl_resource_get_user_data(resource); } -static struct wlr_surface_state *surface_state_create() { +static struct wlr_surface_state *surface_state_create(void) { struct wlr_surface_state *state = calloc(1, sizeof(struct wlr_surface_state)); if (state == NULL) { -- cgit v1.2.3