diff --git a/gdk/gdkdmabuf.c b/gdk/gdkdmabuf.c index 6188c6bb90..d2d7757337 100644 --- a/gdk/gdkdmabuf.c +++ b/gdk/gdkdmabuf.c @@ -527,4 +527,27 @@ gdk_dmabuf_sanitize (GdkDmabuf *dest, 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 */ diff --git a/gdk/gdkdmabufprivate.h b/gdk/gdkdmabufprivate.h index 36af9fe734..67ed9c1d6b 100644 --- a/gdk/gdkdmabufprivate.h +++ b/gdk/gdkdmabufprivate.h @@ -48,4 +48,6 @@ gboolean gdk_dmabuf_sanitize (GdkDmabuf gsize height, const GdkDmabuf *src, GError **error); +gboolean gdk_dmabuf_is_disjoint (const GdkDmabuf *dmabuf); + #endif