From f0eceb4aa3f3082196fe4867b2411ec841096dee Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 13 Dec 2023 06:29:18 +0100 Subject: [PATCH] dmabuf: Remove out argument The format is the same everywhere, so instead of letting every implementation do the same thing, do it in a central place instead. --- gdk/gdkdmabuf.c | 6 ------ gdk/gdkdmabufegl.c | 13 +------------ gdk/gdkdmabufprivate.h | 1 - gdk/gdkdmabuftexture.c | 14 ++++++++++++-- 4 files changed, 13 insertions(+), 21 deletions(-) diff --git a/gdk/gdkdmabuf.c b/gdk/gdkdmabuf.c index 9650684af5..4ad05dc1ff 100644 --- a/gdk/gdkdmabuf.c +++ b/gdk/gdkdmabuf.c @@ -676,7 +676,6 @@ gdk_dmabuf_direct_downloader_supports (const GdkDmabufDownloader *downloader, GdkDisplay *display, const GdkDmabuf *dmabuf, gboolean premultiplied, - GdkMemoryFormat *out_format, GError **error) { const GdkDrmFormatInfo *info; @@ -701,11 +700,6 @@ gdk_dmabuf_direct_downloader_supports (const GdkDmabufDownloader *downloader, return FALSE; } - if (premultiplied) - *out_format = gdk_memory_format_get_premultiplied (info->memory_format); - else - *out_format = gdk_memory_format_get_straight (info->memory_format); - return TRUE; } diff --git a/gdk/gdkdmabufegl.c b/gdk/gdkdmabufegl.c index cfe1394d68..fe2422558b 100644 --- a/gdk/gdkdmabufegl.c +++ b/gdk/gdkdmabufegl.c @@ -166,21 +166,10 @@ gdk_dmabuf_egl_downloader_supports (const GdkDmabufDownloader *downloader, GdkDisplay *display, const GdkDmabuf *dmabuf, gboolean premultiplied, - GdkMemoryFormat *out_format, GError **error) { if (gdk_dmabuf_formats_contains (display->egl_dmabuf_formats, dmabuf->fourcc, dmabuf->modifier)) - { - if (!gdk_dmabuf_get_memory_format (dmabuf->fourcc, premultiplied, out_format)) - { - GDK_DISPLAY_DEBUG (display, DMABUF, - "Falling back to generic ARGB for dmabuf format %.4s", - (char *) &dmabuf->fourcc); - *out_format = premultiplied ? GDK_MEMORY_R8G8B8A8_PREMULTIPLIED - : GDK_MEMORY_R8G8B8A8; - } - return TRUE; - } + return TRUE; g_set_error (error, GDK_DMABUF_ERROR, GDK_DMABUF_ERROR_UNSUPPORTED_FORMAT, diff --git a/gdk/gdkdmabufprivate.h b/gdk/gdkdmabufprivate.h index e001ef0ea3..031729bfd1 100644 --- a/gdk/gdkdmabufprivate.h +++ b/gdk/gdkdmabufprivate.h @@ -29,7 +29,6 @@ struct _GdkDmabufDownloader GdkDisplay *display, const GdkDmabuf *dmabuf, gboolean premultiplied, - GdkMemoryFormat *out_format, GError **error); void (* download) (const GdkDmabufDownloader *downloader, GdkTexture *texture, diff --git a/gdk/gdkdmabuftexture.c b/gdk/gdkdmabuftexture.c index ee83d4434b..3b222ef00d 100644 --- a/gdk/gdkdmabuftexture.c +++ b/gdk/gdkdmabuftexture.c @@ -132,11 +132,13 @@ gdk_dmabuf_texture_new_from_builder (GdkDmabufTextureBuilder *builder, GdkMemoryFormat format; GError *local_error = NULL; int width, height; + gboolean premultiplied; gsize i; display = gdk_dmabuf_texture_builder_get_display (builder); width = gdk_dmabuf_texture_builder_get_width (builder); height = gdk_dmabuf_texture_builder_get_height (builder); + premultiplied = gdk_dmabuf_texture_builder_get_premultiplied (builder); if (!gdk_dmabuf_sanitize (&dmabuf, width, @@ -155,8 +157,7 @@ gdk_dmabuf_texture_new_from_builder (GdkDmabufTextureBuilder *builder, if (display->dmabuf_downloaders[i]->supports (display->dmabuf_downloaders[i], display, &dmabuf, - gdk_dmabuf_texture_builder_get_premultiplied (builder), - &format, + premultiplied, local_error ? NULL : &local_error)) break; } @@ -167,6 +168,15 @@ gdk_dmabuf_texture_new_from_builder (GdkDmabufTextureBuilder *builder, return NULL; } + if (!gdk_dmabuf_get_memory_format (dmabuf.fourcc, premultiplied, &format)) + { + GDK_DISPLAY_DEBUG (display, DMABUF, + "Falling back to generic ARGB for dmabuf format %.4s", + (char *) &dmabuf.fourcc); + format = premultiplied ? GDK_MEMORY_R8G8B8A8_PREMULTIPLIED + : GDK_MEMORY_R8G8B8A8; + } + GDK_DISPLAY_DEBUG (display, DMABUF, "Creating dmabuf texture, format %.4s:%#" G_GINT64_MODIFIER "x, %s%u planes, memory format %u, downloader %s", (char *) &dmabuf.fourcc, dmabuf.modifier,