dmabuf: Allow downloaders to fail initialization

When adding the formats of a downloader, allow them to return FALSE to
mean "This method is not supported", which is a useful way to opt out
when checking GL or Vulkan extensions and finding out that the desired
one isn't supported.
This commit is contained in:
Benjamin Otte 2023-10-22 15:59:02 +02:00
parent 0817dfe67f
commit 13848969f4
3 changed files with 6 additions and 3 deletions

View File

@ -1847,7 +1847,8 @@ gdk_display_add_dmabuf_downloader (GdkDisplay *display,
{
gsize i;
downloader->add_formats (downloader, display, builder);
if (!downloader->add_formats (downloader, display, builder))
return;
/* dmabuf_downloaders is NULL-terminated */
for (i = 0; i < G_N_ELEMENTS (display->dmabuf_downloaders) - 1; i++)

View File

@ -264,7 +264,7 @@ get_drm_format_info (guint32 fourcc)
return NULL;
}
static void
static gboolean
gdk_dmabuf_direct_downloader_add_formats (const GdkDmabufDownloader *downloader,
GdkDisplay *display,
GdkDmabufFormatsBuilder *builder)
@ -277,6 +277,8 @@ gdk_dmabuf_direct_downloader_add_formats (const GdkDmabufDownloader *downloader,
supported_formats[i].fourcc,
DRM_FORMAT_MOD_LINEAR);
}
return TRUE;
}
static gboolean

View File

@ -22,7 +22,7 @@ struct _GdkDmabuf
struct _GdkDmabufDownloader
{
const char *name;
void (* add_formats) (const GdkDmabufDownloader *downloader,
gboolean (* add_formats) (const GdkDmabufDownloader *downloader,
GdkDisplay *display,
GdkDmabufFormatsBuilder *builder);