dmabuf: Add gdk_dmabuf_is_disjoint()

No users yet, but Vulkan will use this later. So have it available
already.
This commit is contained in:
Benjamin Otte 2023-10-21 21:23:11 +02:00
parent 98f02f6221
commit beb9e0c906
2 changed files with 25 additions and 0 deletions

View File

@ -527,4 +527,27 @@ gdk_dmabuf_sanitize (GdkDmabuf *dest,
return TRUE; return TRUE;
} }
/*
* gdk_dmabuf_is_disjoint:
* @dmabuf: a sanitized GdkDmabuf
*
* A dmabuf is considered disjoint if it uses more than
* 1 file descriptor.
*
* Returns: %TRUE if the dmabuf is disjoint
**/
gboolean
gdk_dmabuf_is_disjoint (const GdkDmabuf *dmabuf)
{
unsigned i;
for (i = 1; i < dmabuf->n_planes; i++)
{
if (dmabuf->planes[0].fd != dmabuf->planes[i].fd)
return TRUE;
}
return FALSE;
}
#endif /* HAVE_LINUX_DMA_BUF_H */ #endif /* HAVE_LINUX_DMA_BUF_H */

View File

@ -48,4 +48,6 @@ gboolean gdk_dmabuf_sanitize (GdkDmabuf
gsize height, gsize height,
const GdkDmabuf *src, const GdkDmabuf *src,
GError **error); GError **error);
gboolean gdk_dmabuf_is_disjoint (const GdkDmabuf *dmabuf);
#endif #endif