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.
This commit is contained in:
Benjamin Otte 2023-12-13 06:29:18 +01:00
parent ff082a7758
commit f0eceb4aa3
4 changed files with 13 additions and 21 deletions

View File

@ -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;
}

View File

@ -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,

View File

@ -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,

View File

@ -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,