From 39b68ea47a661b1f7562ce283652de08f222b2be Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 3 Mar 2022 15:38:26 +0100 Subject: [PATCH] buffer: extract interface to separate header Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3389 --- include/wlr/interfaces/wlr_buffer.h | 48 +++++++++++++++++++++++++++++ include/wlr/types/wlr_buffer.h | 32 ------------------- render/allocator/allocator.c | 1 + render/allocator/drm_dumb.c | 1 + render/allocator/gbm.c | 1 + render/allocator/shm.c | 1 + types/wlr_buffer.c | 1 + types/wlr_drm.c | 1 + types/wlr_linux_dmabuf_v1.c | 1 + 9 files changed, 55 insertions(+), 32 deletions(-) create mode 100644 include/wlr/interfaces/wlr_buffer.h diff --git a/include/wlr/interfaces/wlr_buffer.h b/include/wlr/interfaces/wlr_buffer.h new file mode 100644 index 00000000..05ccc1e7 --- /dev/null +++ b/include/wlr/interfaces/wlr_buffer.h @@ -0,0 +1,48 @@ +/* + * 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_INTERFACES_WLR_BUFFER_H +#define WLR_INTERFACES_WLR_BUFFER_H + +#include + +struct wlr_buffer_impl { + void (*destroy)(struct wlr_buffer *buffer); + bool (*get_dmabuf)(struct wlr_buffer *buffer, + struct wlr_dmabuf_attributes *attribs); + bool (*get_shm)(struct wlr_buffer *buffer, + struct wlr_shm_attributes *attribs); + bool (*begin_data_ptr_access)(struct wlr_buffer *buffer, uint32_t flags, + void **data, uint32_t *format, size_t *stride); + void (*end_data_ptr_access)(struct wlr_buffer *buffer); +}; + +struct wlr_buffer_resource_interface { + const char *name; + bool (*is_instance)(struct wl_resource *resource); + struct wlr_buffer *(*from_resource)(struct wl_resource *resource); +}; + +/** + * Initialize a buffer. This function should be called by producers. The + * initialized buffer is referenced: once the producer is done with the buffer + * they should call wlr_buffer_drop. + */ +void wlr_buffer_init(struct wlr_buffer *buffer, + const struct wlr_buffer_impl *impl, int width, int height); + +/** + * Allows the registration of a wl_resource implementation. + * + * The matching function will be called for the wl_resource when creating a + * wlr_buffer from a wl_resource. + */ +void wlr_buffer_register_resource_interface( + const struct wlr_buffer_resource_interface *iface); + +#endif diff --git a/include/wlr/types/wlr_buffer.h b/include/wlr/types/wlr_buffer.h index 60dbb5c3..604dc17a 100644 --- a/include/wlr/types/wlr_buffer.h +++ b/include/wlr/types/wlr_buffer.h @@ -24,17 +24,6 @@ struct wlr_shm_attributes { off_t offset; }; -struct wlr_buffer_impl { - void (*destroy)(struct wlr_buffer *buffer); - bool (*get_dmabuf)(struct wlr_buffer *buffer, - struct wlr_dmabuf_attributes *attribs); - bool (*get_shm)(struct wlr_buffer *buffer, - struct wlr_shm_attributes *attribs); - bool (*begin_data_ptr_access)(struct wlr_buffer *buffer, uint32_t flags, - void **data, uint32_t *format, size_t *stride); - void (*end_data_ptr_access)(struct wlr_buffer *buffer); -}; - /** * Buffer capabilities. * @@ -72,19 +61,6 @@ struct wlr_buffer { struct wlr_addon_set addons; }; -struct wlr_buffer_resource_interface { - const char *name; - bool (*is_instance)(struct wl_resource *resource); - struct wlr_buffer *(*from_resource)(struct wl_resource *resource); -}; - -/** - * Initialize a buffer. This function should be called by producers. The - * initialized buffer is referenced: once the producer is done with the buffer - * they should call wlr_buffer_drop. - */ -void wlr_buffer_init(struct wlr_buffer *buffer, - const struct wlr_buffer_impl *impl, int width, int height); /** * Unreference the buffer. This function should be called by producers when * they are done with the buffer. @@ -121,14 +97,6 @@ bool wlr_buffer_get_dmabuf(struct wlr_buffer *buffer, */ bool wlr_buffer_get_shm(struct wlr_buffer *buffer, struct wlr_shm_attributes *attribs); -/** - * Allows the registration of a wl_resource implementation. - * - * The matching function will be called for the wl_resource when creating a - * wlr_buffer from a wl_resource. - */ -void wlr_buffer_register_resource_interface( - const struct wlr_buffer_resource_interface *iface); /** * Transforms a wl_resource into a wlr_buffer and locks it. Once the caller is * done with the buffer, they must call wlr_buffer_unlock. diff --git a/render/allocator/allocator.c b/render/allocator/allocator.c index 5108ad04..0597cf25 100644 --- a/render/allocator/allocator.c +++ b/render/allocator/allocator.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include diff --git a/render/allocator/drm_dumb.c b/render/allocator/drm_dumb.c index 5b47462b..e2812ecb 100644 --- a/render/allocator/drm_dumb.c +++ b/render/allocator/drm_dumb.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/render/allocator/gbm.c b/render/allocator/gbm.c index 8f73862a..8c670774 100644 --- a/render/allocator/gbm.c +++ b/render/allocator/gbm.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include diff --git a/render/allocator/shm.c b/render/allocator/shm.c index 044d5eb1..9e49a144 100644 --- a/render/allocator/shm.c +++ b/render/allocator/shm.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include diff --git a/types/wlr_buffer.c b/types/wlr_buffer.c index fa281c68..0e091f56 100644 --- a/types/wlr_buffer.c +++ b/types/wlr_buffer.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include diff --git a/types/wlr_drm.c b/types/wlr_drm.c index a02fba84..0d50138c 100644 --- a/types/wlr_drm.c +++ b/types/wlr_drm.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include diff --git a/types/wlr_linux_dmabuf_v1.c b/types/wlr_linux_dmabuf_v1.c index 5138e469..69aa64b7 100644 --- a/types/wlr_linux_dmabuf_v1.c +++ b/types/wlr_linux_dmabuf_v1.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include