2019-04-29 19:32:35 +00:00
|
|
|
#define _POSIX_C_SOURCE 200809L
|
|
|
|
#include <fcntl.h>
|
2018-05-31 11:33:27 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <wlr/render/dmabuf.h>
|
2019-04-29 19:32:35 +00:00
|
|
|
#include <wlr/util/log.h>
|
2018-05-31 11:33:27 +00:00
|
|
|
|
2019-04-29 19:32:35 +00:00
|
|
|
void wlr_dmabuf_attributes_finish(struct wlr_dmabuf_attributes *attribs) {
|
2018-05-31 11:33:27 +00:00
|
|
|
for (int i = 0; i < attribs->n_planes; ++i) {
|
|
|
|
close(attribs->fd[i]);
|
|
|
|
attribs->fd[i] = -1;
|
|
|
|
}
|
|
|
|
attribs->n_planes = 0;
|
|
|
|
}
|
2019-04-29 19:32:35 +00:00
|
|
|
|
|
|
|
bool wlr_dmabuf_attributes_copy(struct wlr_dmabuf_attributes *dst,
|
|
|
|
struct wlr_dmabuf_attributes *src) {
|
|
|
|
memcpy(dst, src, sizeof(struct wlr_dmabuf_attributes));
|
|
|
|
|
|
|
|
for (int i = 0; i < src->n_planes; ++i) {
|
|
|
|
dst->fd[i] = fcntl(src->fd[i], F_DUPFD_CLOEXEC, 0);
|
|
|
|
if (dst->fd[i] < 0) {
|
|
|
|
wlr_log_errno(WLR_ERROR, "fcntl(F_DUPFD_CLOEXEC) failed");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|