buffer: Use create_immed
parent
a43fdd4779
commit
ef91f040f9
|
@ -30,10 +30,6 @@ struct wv_buffer {
|
||||||
/* The following is only applicable to DMABUF */
|
/* The following is only applicable to DMABUF */
|
||||||
struct gbm_bo* bo;
|
struct gbm_bo* bo;
|
||||||
void* bo_map_handle;
|
void* bo_map_handle;
|
||||||
|
|
||||||
bool is_ready;
|
|
||||||
void (*on_ready)(struct wv_buffer*);
|
|
||||||
void* userdata;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TAILQ_HEAD(wv_buffer_queue, wv_buffer);
|
TAILQ_HEAD(wv_buffer_queue, wv_buffer);
|
||||||
|
|
43
src/buffer.c
43
src/buffer.c
|
@ -33,7 +33,6 @@ struct wv_buffer* wv_buffer_create_shm(int width,
|
||||||
self->height = height;
|
self->height = height;
|
||||||
self->stride = stride;
|
self->stride = stride;
|
||||||
self->format = fourcc;
|
self->format = fourcc;
|
||||||
self->is_ready = true;
|
|
||||||
|
|
||||||
self->size = height * stride;
|
self->size = height * stride;
|
||||||
int fd = shm_alloc_fd(self->size);
|
int fd = shm_alloc_fd(self->size);
|
||||||
|
@ -68,36 +67,6 @@ failure:
|
||||||
return NULL;
|
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,
|
static struct wv_buffer* wv_buffer_create_dmabuf(int width, int height,
|
||||||
uint32_t fourcc)
|
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,
|
zwp_linux_buffer_params_v1_add(params, fd, 0, offset, stride,
|
||||||
mod >> 32, mod & 0xffffffff);
|
mod >> 32, mod & 0xffffffff);
|
||||||
zwp_linux_buffer_params_v1_add_listener(params,
|
self->wl_buffer = zwp_linux_buffer_params_v1_create_immed(params, width,
|
||||||
&wv_buffer_params_listener, self);
|
height, fourcc, /* flags */ 0);
|
||||||
zwp_linux_buffer_params_v1_create(params, width, height, fourcc,
|
|
||||||
/* flags */ 0);
|
|
||||||
|
|
||||||
close(fd); // TODO: Maybe keep this open?
|
close(fd); // TODO: Maybe keep this open?
|
||||||
|
|
||||||
|
if (!self->wl_buffer)
|
||||||
|
goto buffer_failure;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
|
||||||
|
buffer_failure:
|
||||||
fd_failure:
|
fd_failure:
|
||||||
params_failure:
|
params_failure:
|
||||||
gbm_bo_destroy(self->bo);
|
gbm_bo_destroy(self->bo);
|
||||||
|
|
Loading…
Reference in New Issue