dmabuf: Add gdk_dmabuf_close_fds()
... and use it inside GtkGLArea I made thatfunction available outside of HAVE_DMABUF so I don't need to wrap it in ifdefs.
This commit is contained in:
@@ -2372,3 +2372,20 @@ gdk_dmabuf_is_disjoint (const GdkDmabuf *dmabuf)
|
||||
}
|
||||
|
||||
#endif /* HAVE_DMABUF */
|
||||
|
||||
void
|
||||
gdk_dmabuf_close_fds (GdkDmabuf *dmabuf)
|
||||
{
|
||||
guint i, j;
|
||||
|
||||
for (i = 0; i < dmabuf->n_planes; i++)
|
||||
{
|
||||
for (j = 0; j < i; j++)
|
||||
{
|
||||
if (dmabuf->planes[i].fd == dmabuf->planes[j].fd)
|
||||
break;
|
||||
}
|
||||
if (i == j)
|
||||
g_close (dmabuf->planes[i].fd, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ struct _GdkDmabuf
|
||||
} planes[GDK_DMABUF_MAX_PLANES];
|
||||
};
|
||||
|
||||
void gdk_dmabuf_close_fds (GdkDmabuf *dmabuf);
|
||||
|
||||
#ifdef HAVE_DMABUF
|
||||
|
||||
GdkDmabufFormats * gdk_dmabuf_get_mmap_formats (void) G_GNUC_CONST;
|
||||
@@ -30,7 +32,6 @@ void gdk_dmabuf_download_mmap (GdkTexture
|
||||
guchar *data,
|
||||
gsize stride);
|
||||
|
||||
|
||||
int gdk_dmabuf_ioctl (int fd,
|
||||
unsigned long request,
|
||||
void *arg);
|
||||
|
||||
@@ -727,15 +727,6 @@ release_gl_texture (gpointer data)
|
||||
texture->gl_texture = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
release_dmabuf (const GdkDmabuf *dmabuf)
|
||||
{
|
||||
#ifndef G_OS_WIN32
|
||||
for (unsigned int i = 0; i < dmabuf->n_planes; i++)
|
||||
close (dmabuf->planes[i].fd);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
release_dmabuf_texture (gpointer data)
|
||||
{
|
||||
@@ -746,7 +737,7 @@ release_dmabuf_texture (gpointer data)
|
||||
if (texture->dmabuf_texture == NULL)
|
||||
return;
|
||||
|
||||
release_dmabuf (gdk_dmabuf_texture_get_dmabuf (GDK_DMABUF_TEXTURE (texture->dmabuf_texture )));
|
||||
gdk_dmabuf_close_fds ((GdkDmabuf *) gdk_dmabuf_texture_get_dmabuf (GDK_DMABUF_TEXTURE (texture->dmabuf_texture)));
|
||||
|
||||
texture->dmabuf_texture = NULL;
|
||||
}
|
||||
@@ -843,7 +834,7 @@ gtk_gl_area_snapshot (GtkWidget *widget,
|
||||
if (texture->dmabuf_texture != NULL)
|
||||
holder = texture->dmabuf_texture;
|
||||
else
|
||||
release_dmabuf (&dmabuf);
|
||||
gdk_dmabuf_close_fds (&dmabuf);
|
||||
}
|
||||
|
||||
/* Our texture is rendered by OpenGL, so it is upside down,
|
||||
|
||||
Reference in New Issue
Block a user