From 0ae3c7b1a2d4da0c32092782ff19a1662151d874 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sat, 17 Sep 2022 14:38:44 +0200 Subject: Introduce wlr_shm This is a re-implementation of wl_shm. The motivations for using this over the one shipped in libwayland are: - Properly handle SIGBUS when accessing a wl_buffer's underlying data after the wl_buffer protocol object has been destroyed. With the current code, we just crash if the client does that and then shrinks the backing file. - No need to fight the wl_shm_buffer API anymore. This was awkward because we weren't notified when clients created a wl_shm buffer, and this doesn't play well with our wlr_buffer abstraction. - Access to the underlying FD. This makes it possible to forward the wl_shm buffer to a parent compositor with the Wayland/X11 backends. - Better stride checks. We can use our format table to ensure that the stride is consistent with the bpp and width. --- include/wlr/types/wlr_shm.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 include/wlr/types/wlr_shm.h (limited to 'include') diff --git a/include/wlr/types/wlr_shm.h b/include/wlr/types/wlr_shm.h new file mode 100644 index 00000000..ebf4015e --- /dev/null +++ b/include/wlr/types/wlr_shm.h @@ -0,0 +1,31 @@ +/* + * This an unstable interface of wlroots. No guarantees are made regarding the + * future consistency of this API. + */ +#ifndef WLR_USE_UNSTABLE +#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" +#endif + +#ifndef WLR_TYPES_WLR_SHM_H +#define WLR_TYPES_WLR_SHM_H + +#include + +/** + * Shared memory buffer interface. + * + * The buffers created via this interface are not safe to use from different + * threads. + * + * Currently, accessing two buffers concurrently via + * wlr_buffer_begin_data_ptr_access() will return an error. + */ +struct wlr_shm; + +/** + * Create the wl_shm global. + */ +struct wlr_shm *wlr_shm_create_with_renderer(struct wl_display *display, + uint32_t version, struct wlr_renderer *renderer); + +#endif -- cgit v1.2.3