aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/wlr/types/wlr_scene.h8
-rw-r--r--types/scene/wlr_scene.c21
2 files changed, 29 insertions, 0 deletions
diff --git a/include/wlr/types/wlr_scene.h b/include/wlr/types/wlr_scene.h
index 6cc842b4..eaa7b07c 100644
--- a/include/wlr/types/wlr_scene.h
+++ b/include/wlr/types/wlr_scene.h
@@ -276,6 +276,14 @@ struct wlr_scene_buffer *wlr_scene_buffer_create(struct wlr_scene_node *parent,
struct wlr_buffer *buffer);
/**
+ * Sets the buffer's backing buffer.
+ *
+ * If the buffer is NULL, the buffer node will not be displayed.
+ */
+void wlr_scene_buffer_set_buffer(struct wlr_scene_buffer *scene_buffer,
+ struct wlr_buffer *buffer);
+
+/**
* Set the source rectangle describing the region of the buffer which will be
* sampled to render this node. This allows cropping the buffer.
*
diff --git a/types/scene/wlr_scene.c b/types/scene/wlr_scene.c
index 777f8cb6..e1e381de 100644
--- a/types/scene/wlr_scene.c
+++ b/types/scene/wlr_scene.c
@@ -367,6 +367,27 @@ struct wlr_scene_buffer *wlr_scene_buffer_create(struct wlr_scene_node *parent,
return scene_buffer;
}
+void wlr_scene_buffer_set_buffer(struct wlr_scene_buffer *scene_buffer,
+ struct wlr_buffer *buffer) {
+ if (buffer == scene_buffer->buffer) {
+ return;
+ }
+
+ scene_node_damage_whole(&scene_buffer->node);
+
+ wlr_texture_destroy(scene_buffer->texture);
+ scene_buffer->texture = NULL;
+ wlr_buffer_unlock(scene_buffer->buffer);
+
+ if (buffer) {
+ scene_buffer->buffer = wlr_buffer_lock(buffer);
+ } else {
+ scene_buffer->buffer = NULL;
+ }
+
+ scene_node_damage_whole(&scene_buffer->node);
+}
+
void wlr_scene_buffer_set_source_box(struct wlr_scene_buffer *scene_buffer,
const struct wlr_fbox *box) {
struct wlr_fbox *cur = &scene_buffer->src_box;