diff options
author | Simon Ser <contact@emersion.fr> | 2021-06-29 20:11:38 +0200 |
---|---|---|
committer | Simon Zeni <simon@bl4ckb0ne.ca> | 2021-07-01 14:57:52 -0400 |
commit | 7ec66a9990cfe1a932fb28d0f65e5d142db04e26 (patch) | |
tree | 360d14dc442a5b4bec06a08d05a0bfe820147c1d /include | |
parent | ea585dba0f69ab2c5010e60646465df56202ee4b (diff) | |
download | wlroots-7ec66a9990cfe1a932fb28d0f65e5d142db04e26.tar.xz |
buffer: introduce wlr_readonly_data_buffer
Diffstat (limited to 'include')
-rw-r--r-- | include/types/wlr_buffer.h | 28 |
1 files changed, 28 insertions, 0 deletions
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 @@ -26,6 +26,34 @@ 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. * * These bits indicate the features supported by a wlr_buffer. There is one bit |