aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-02-28 15:25:35 +0100
committerSimon Ser <contact@emersion.fr>2020-04-02 15:03:43 +0200
commit1fa9e0203b4192659a36ddd259c174569bc227d5 (patch)
treee85fa5803bdc8c90c0877c8f00235f13e59df52a
parent6595db64099fa95ec1b43dd2f137e0de58da9e41 (diff)
buffer: add width and height
-rw-r--r--include/wlr/types/wlr_buffer.h4
-rw-r--r--types/wlr_buffer.c9
2 files changed, 10 insertions, 3 deletions
diff --git a/include/wlr/types/wlr_buffer.h b/include/wlr/types/wlr_buffer.h
index fb308e61..454c5ba0 100644
--- a/include/wlr/types/wlr_buffer.h
+++ b/include/wlr/types/wlr_buffer.h
@@ -32,6 +32,8 @@ struct wlr_buffer_impl {
struct wlr_buffer {
const struct wlr_buffer_impl *impl;
+ int width, height;
+
bool dropped;
size_t n_locks;
@@ -47,7 +49,7 @@ struct wlr_buffer {
* they should call wlr_buffer_drop.
*/
void wlr_buffer_init(struct wlr_buffer *buffer,
- const struct wlr_buffer_impl *impl);
+ 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.
diff --git a/types/wlr_buffer.c b/types/wlr_buffer.c
index 1b0f53d8..2f914c12 100644
--- a/types/wlr_buffer.c
+++ b/types/wlr_buffer.c
@@ -7,9 +7,11 @@
#include "util/signal.h"
void wlr_buffer_init(struct wlr_buffer *buffer,
- const struct wlr_buffer_impl *impl) {
+ const struct wlr_buffer_impl *impl, int width, int height) {
assert(impl->destroy);
buffer->impl = impl;
+ buffer->width = width;
+ buffer->height = height;
wl_signal_init(&buffer->events.destroy);
wl_signal_init(&buffer->events.release);
}
@@ -212,6 +214,9 @@ struct wlr_client_buffer *wlr_client_buffer_import(
return NULL;
}
+ int width, height;
+ wlr_resource_get_buffer_size(resource, renderer, &width, &height);
+
struct wlr_client_buffer *buffer =
calloc(1, sizeof(struct wlr_client_buffer));
if (buffer == NULL) {
@@ -219,7 +224,7 @@ struct wlr_client_buffer *wlr_client_buffer_import(
wl_resource_post_no_memory(resource);
return NULL;
}
- wlr_buffer_init(&buffer->base, &client_buffer_impl);
+ wlr_buffer_init(&buffer->base, &client_buffer_impl, width, height);
buffer->resource = resource;
buffer->texture = texture;
buffer->resource_released = resource_released;