aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Zeni <simon@bl4ckb0ne.ca>2021-02-16 20:22:28 -0500
committerSimon Ser <contact@emersion.fr>2021-04-17 09:54:39 +0200
commit0b9288ec0b8885ba0a76e54fc8949c563d39cabd (patch)
treeaf8841268849832ac6242bcb7a167e91a8017f81
parent9f33d8ad39c26c00ef129419ea1c69c6966e5606 (diff)
buffer: introduce wlr_buffer_get_data_ptr
The function has been place in an internal header for API stability reasons.
-rw-r--r--include/types/wlr_buffer.h15
-rw-r--r--include/wlr/types/wlr_buffer.h2
-rw-r--r--types/wlr_buffer.c8
3 files changed, 25 insertions, 0 deletions
diff --git a/include/types/wlr_buffer.h b/include/types/wlr_buffer.h
new file mode 100644
index 00000000..8f62179a
--- /dev/null
+++ b/include/types/wlr_buffer.h
@@ -0,0 +1,15 @@
+#ifndef TYPES_WLR_BUFFER
+#define TYPES_WLR_BUFFER
+
+#include <wlr/types/wlr_buffer.h>
+/**
+ * Access a pointer to the allocated data from the underlying implementation,
+ * and its stride.
+ *
+ * The returned pointer should be pointing to a valid memory location for read
+ * and write operations.
+ */
+bool buffer_get_data_ptr(struct wlr_buffer *buffer, void **data,
+ size_t *stride);
+
+#endif
diff --git a/include/wlr/types/wlr_buffer.h b/include/wlr/types/wlr_buffer.h
index 84555899..59996fce 100644
--- a/include/wlr/types/wlr_buffer.h
+++ b/include/wlr/types/wlr_buffer.h
@@ -19,6 +19,8 @@ struct wlr_buffer_impl {
void (*destroy)(struct wlr_buffer *buffer);
bool (*get_dmabuf)(struct wlr_buffer *buffer,
struct wlr_dmabuf_attributes *attribs);
+ bool (*get_data_ptr)(struct wlr_buffer *buffer, void **data,
+ size_t *stride);
};
/**
diff --git a/types/wlr_buffer.c b/types/wlr_buffer.c
index 0bc290ca..cc20af59 100644
--- a/types/wlr_buffer.c
+++ b/types/wlr_buffer.c
@@ -5,6 +5,7 @@
#include <wlr/types/wlr_linux_dmabuf_v1.h>
#include <wlr/util/log.h>
#include "render/pixel_format.h"
+#include "types/wlr_buffer.h"
#include "util/signal.h"
void wlr_buffer_init(struct wlr_buffer *buffer,
@@ -65,6 +66,13 @@ bool wlr_buffer_get_dmabuf(struct wlr_buffer *buffer,
return buffer->impl->get_dmabuf(buffer, attribs);
}
+bool buffer_get_data_ptr(struct wlr_buffer *buffer, void **data,
+ size_t *size) {
+ if (!buffer->impl->get_data_ptr) {
+ return false;
+ }
+ return buffer->impl->get_data_ptr(buffer, data, size);
+}
bool wlr_resource_is_buffer(struct wl_resource *resource) {
return strcmp(wl_resource_get_class(resource), wl_buffer_interface.name) == 0;