diff options
author | Simon Ser <contact@emersion.fr> | 2022-12-12 23:08:48 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2022-12-12 23:08:48 +0100 |
commit | 80074d95fba4fea5b8de1c2e948016eac63caec2 (patch) | |
tree | 4d5ae99a84543dbfe500d11e29612d1656128739 /render | |
parent | 8f58c060fd6095e34ede2a2d1c14caea517636e7 (diff) |
egl: consistently use EGLint for DMA-BUF format
EGL_EXT_image_dma_buf_import_modifiers [1] uses EGLint to carry
formats. We were casting it to int (which may not be the same
width) and uint32_t (which may change the value).
Instead, use EGLint everywhere.
[1]: https://registry.khronos.org/EGL/extensions/EXT/EGL_EXT_image_dma_buf_import_modifiers.txt
Diffstat (limited to 'render')
-rw-r--r-- | render/egl.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/render/egl.c b/render/egl.c index 19ed6918..b50fe448 100644 --- a/render/egl.c +++ b/render/egl.c @@ -95,8 +95,8 @@ static void load_egl_proc(void *proc_ptr, const char *name) { *(void **)proc_ptr = proc; } -static int get_egl_dmabuf_formats(struct wlr_egl *egl, int **formats); -static int get_egl_dmabuf_modifiers(struct wlr_egl *egl, int format, +static int get_egl_dmabuf_formats(struct wlr_egl *egl, EGLint **formats); +static int get_egl_dmabuf_modifiers(struct wlr_egl *egl, EGLint format, uint64_t **modifiers, EGLBoolean **external_only); static void log_modifier(uint64_t modifier, bool external_only) { @@ -112,7 +112,7 @@ static void init_dmabuf_formats(struct wlr_egl *egl) { wlr_log(WLR_INFO, "WLR_EGL_NO_MODIFIERS set, disabling modifiers for EGL"); } - int *formats; + EGLint *formats; int formats_len = get_egl_dmabuf_formats(egl, &formats); if (formats_len < 0) { return; @@ -122,7 +122,7 @@ static void init_dmabuf_formats(struct wlr_egl *egl) { bool has_modifiers = false; for (int i = 0; i < formats_len; i++) { - uint32_t fmt = formats[i]; + EGLint fmt = formats[i]; uint64_t *modifiers = NULL; EGLBoolean *external_only = NULL; @@ -781,7 +781,7 @@ EGLImageKHR wlr_egl_create_image_from_dmabuf(struct wlr_egl *egl, return image; } -static int get_egl_dmabuf_formats(struct wlr_egl *egl, int **formats) { +static int get_egl_dmabuf_formats(struct wlr_egl *egl, EGLint **formats) { if (!egl->exts.EXT_image_dma_buf_import) { wlr_log(WLR_DEBUG, "DMA-BUF import extension not present"); return -1; @@ -793,14 +793,13 @@ static int get_egl_dmabuf_formats(struct wlr_egl *egl, int **formats) { // Just a guess but better than not supporting dmabufs at all, // given that the modifiers extension isn't supported everywhere. if (!egl->exts.EXT_image_dma_buf_import_modifiers) { - static const int fallback_formats[] = { + static const EGLint fallback_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB8888, }; - static unsigned num = sizeof(fallback_formats) / - sizeof(fallback_formats[0]); + int num = sizeof(fallback_formats) / sizeof(fallback_formats[0]); - *formats = calloc(num, sizeof(int)); + *formats = calloc(num, sizeof(EGLint)); if (!*formats) { wlr_log_errno(WLR_ERROR, "Allocation failed"); return -1; @@ -816,7 +815,7 @@ static int get_egl_dmabuf_formats(struct wlr_egl *egl, int **formats) { return -1; } - *formats = calloc(num, sizeof(int)); + *formats = calloc(num, sizeof(EGLint)); if (*formats == NULL) { wlr_log(WLR_ERROR, "Allocation failed: %s", strerror(errno)); return -1; @@ -830,7 +829,7 @@ static int get_egl_dmabuf_formats(struct wlr_egl *egl, int **formats) { return num; } -static int get_egl_dmabuf_modifiers(struct wlr_egl *egl, int format, +static int get_egl_dmabuf_modifiers(struct wlr_egl *egl, EGLint format, uint64_t **modifiers, EGLBoolean **external_only) { *modifiers = NULL; *external_only = NULL; |