diff options
author | Simon Ser <contact@emersion.fr> | 2021-05-31 20:16:32 +0200 |
---|---|---|
committer | Simon Zeni <simon@bl4ckb0ne.ca> | 2021-05-31 15:50:13 -0400 |
commit | 766a24fa7791d115fa36aded57d7cde87b20d4da (patch) | |
tree | a6d86ae0bf50772ed03746fcd6b90c97947d8807 /render/allocator.c | |
parent | 5c30cf3d9441f7121acadd834ac610bff610eca1 (diff) |
render/allocator: add wlr_allocator.buffer_caps
This allows users to know the capabilities of the buffers that
will be allocated. The buffer capability is important to
know when negotiating buffer formats.
Diffstat (limited to 'render/allocator.c')
-rw-r--r-- | render/allocator.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/render/allocator.c b/render/allocator.c index f06049ab..4f87d95a 100644 --- a/render/allocator.c +++ b/render/allocator.c @@ -11,9 +11,10 @@ #include "types/wlr_buffer.h" void wlr_allocator_init(struct wlr_allocator *alloc, - const struct wlr_allocator_interface *impl) { + const struct wlr_allocator_interface *impl, uint32_t buffer_caps) { assert(impl && impl->destroy && impl->create_buffer); alloc->impl = impl; + alloc->buffer_caps = buffer_caps; wl_signal_init(&alloc->events.destroy); } @@ -74,5 +75,19 @@ void wlr_allocator_destroy(struct wlr_allocator *alloc) { struct wlr_buffer *wlr_allocator_create_buffer(struct wlr_allocator *alloc, int width, int height, const struct wlr_drm_format *format) { - return alloc->impl->create_buffer(alloc, width, height, format); + struct wlr_buffer *buffer = + alloc->impl->create_buffer(alloc, width, height, format); + if (buffer == NULL) { + return NULL; + } + if (alloc->buffer_caps & WLR_BUFFER_CAP_DATA_PTR) { + assert(buffer->impl->get_data_ptr); + } + if (alloc->buffer_caps & WLR_BUFFER_CAP_DMABUF) { + assert(buffer->impl->get_dmabuf); + } + if (alloc->buffer_caps & WLR_BUFFER_CAP_SHM) { + assert(buffer->impl->get_shm); + } + return buffer; } |