From 7ec66a9990cfe1a932fb28d0f65e5d142db04e26 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 29 Jun 2021 20:11:38 +0200 Subject: buffer: introduce wlr_readonly_data_buffer --- include/types/wlr_buffer.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'include') diff --git a/include/types/wlr_buffer.h b/include/types/wlr_buffer.h index 8abb68d6..85a8d8b4 100644 --- a/include/types/wlr_buffer.h +++ b/include/types/wlr_buffer.h @@ -25,6 +25,34 @@ struct wlr_shm_client_buffer { struct wlr_shm_client_buffer *shm_client_buffer_create( struct wl_resource *resource); +/** + * A read-only buffer that holds a data pointer. + * + * This is suitable for passing raw pixel data to a function that accepts a + * wlr_buffer. + */ +struct wlr_readonly_data_buffer { + struct wlr_buffer base; + + const void *data; + uint32_t format; + size_t stride; + + void *saved_data; +}; + +/** + * Wraps a read-only data pointer into a wlr_buffer. The data pointer may be + * accessed until readonly_data_buffer_drop() is called. + */ +struct wlr_readonly_data_buffer *readonly_data_buffer_create(uint32_t format, + size_t stride, uint32_t width, uint32_t height, const void *data); +/** + * Drops ownership of the buffer (see wlr_buffer_drop() for more details) and + * perform a copy of the data pointer if a consumer still has the buffer locked. + */ +bool readonly_data_buffer_drop(struct wlr_readonly_data_buffer *buffer); + /** * Buffer capabilities. * -- cgit v1.2.3