buffer: Use create_immed

pixman-rendering
Andri Yngvason 2020-06-23 21:50:55 +00:00
parent a43fdd4779
commit ef91f040f9
2 changed files with 7 additions and 40 deletions

View File

@ -30,10 +30,6 @@ struct wv_buffer {
/* The following is only applicable to DMABUF */
struct gbm_bo* bo;
void* bo_map_handle;
bool is_ready;
void (*on_ready)(struct wv_buffer*);
void* userdata;
};
TAILQ_HEAD(wv_buffer_queue, wv_buffer);

View File

@ -33,7 +33,6 @@ struct wv_buffer* wv_buffer_create_shm(int width,
self->height = height;
self->stride = stride;
self->format = fourcc;
self->is_ready = true;
self->size = height * stride;
int fd = shm_alloc_fd(self->size);
@ -68,36 +67,6 @@ failure:
return NULL;
}
static void wv_buffer_dmabuf_created(void* data,
struct zwp_linux_buffer_params_v1* params,
struct wl_buffer* wl_buffer)
{
(void)params;
struct wv_buffer* self = data;
self->wl_buffer = wl_buffer;
self->is_ready = true;
if (self->on_ready)
self->on_ready(self);
}
static void wv_buffer_dmabuf_failed(void* data,
struct zwp_linux_buffer_params_v1* params)
{
(void)params;
struct wv_buffer* self = data;
if (self->on_ready)
self->on_ready(self);
}
static const struct zwp_linux_buffer_params_v1_listener
wv_buffer_params_listener = {
.created = wv_buffer_dmabuf_created,
.failed = wv_buffer_dmabuf_failed,
};
static struct wv_buffer* wv_buffer_create_dmabuf(int width, int height,
uint32_t fourcc)
{
@ -131,14 +100,16 @@ static struct wv_buffer* wv_buffer_create_dmabuf(int width, int height,
zwp_linux_buffer_params_v1_add(params, fd, 0, offset, stride,
mod >> 32, mod & 0xffffffff);
zwp_linux_buffer_params_v1_add_listener(params,
&wv_buffer_params_listener, self);
zwp_linux_buffer_params_v1_create(params, width, height, fourcc,
/* flags */ 0);
self->wl_buffer = zwp_linux_buffer_params_v1_create_immed(params, width,
height, fourcc, /* flags */ 0);
close(fd); // TODO: Maybe keep this open?
if (!self->wl_buffer)
goto buffer_failure;
return self;
buffer_failure:
fd_failure:
params_failure:
gbm_bo_destroy(self->bo);