aboutsummaryrefslogtreecommitdiff
path: root/include/wlr/interfaces
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-03-03 15:38:26 +0100
committerSimon Ser <contact@emersion.fr>2022-03-03 15:39:05 +0100
commit39b68ea47a661b1f7562ce283652de08f222b2be (patch)
treeef00d4ccae8e112de3753c9e5203c34921d09090 /include/wlr/interfaces
parentd0718a9b32dc9d80b35eae269b60a22caa9c268f (diff)
buffer: extract interface to separate header
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3389
Diffstat (limited to 'include/wlr/interfaces')
-rw-r--r--include/wlr/interfaces/wlr_buffer.h48
1 files changed, 48 insertions, 0 deletions
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 <wlr/types/wlr_buffer.h>
+
+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