aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Orzechowski <orzechowski.alexander@gmail.com>2022-05-19 14:16:52 -0400
committerAlexander Orzechowski <orzechowski.alexander@gmail.com>2022-05-19 14:16:52 -0400
commit039a31df9a8708cdc0d054c105b4d078b3817dea (patch)
tree599de2e36419285351cac18a09c607422ae35e0e
parent8fe3aa29da56be16faa73aca947647bd60cd4a94 (diff)
wlr_scene: Allow buffer in wlr_scene_buffer to be NULL
This is useful to emulate an unmapped surface.
-rw-r--r--include/wlr/types/wlr_scene.h4
-rw-r--r--types/scene/wlr_scene.c9
2 files changed, 11 insertions, 2 deletions
diff --git a/include/wlr/types/wlr_scene.h b/include/wlr/types/wlr_scene.h
index 7c2238fb..6cc842b4 100644
--- a/include/wlr/types/wlr_scene.h
+++ b/include/wlr/types/wlr_scene.h
@@ -107,6 +107,8 @@ struct wlr_scene_rect {
/** A scene-graph node displaying a buffer */
struct wlr_scene_buffer {
struct wlr_scene_node node;
+
+ // May be NULL
struct wlr_buffer *buffer;
// private state
@@ -267,6 +269,8 @@ void wlr_scene_rect_set_color(struct wlr_scene_rect *rect, const float color[sta
/**
* Add a node displaying a buffer to the scene-graph.
+ *
+ * If the buffer is NULL, this node will not be displayed.
*/
struct wlr_scene_buffer *wlr_scene_buffer_create(struct wlr_scene_node *parent,
struct wlr_buffer *buffer);
diff --git a/types/scene/wlr_scene.c b/types/scene/wlr_scene.c
index d88dd55f..777f8cb6 100644
--- a/types/scene/wlr_scene.c
+++ b/types/scene/wlr_scene.c
@@ -358,7 +358,9 @@ struct wlr_scene_buffer *wlr_scene_buffer_create(struct wlr_scene_node *parent,
}
scene_node_init(&scene_buffer->node, WLR_SCENE_NODE_BUFFER, parent);
- scene_buffer->buffer = wlr_buffer_lock(buffer);
+ if (buffer) {
+ scene_buffer->buffer = wlr_buffer_lock(buffer);
+ }
scene_node_damage_whole(&scene_buffer->node);
@@ -447,7 +449,7 @@ static void scene_node_get_size(struct wlr_scene_node *node,
if (scene_buffer->dst_width > 0 && scene_buffer->dst_height > 0) {
*width = scene_buffer->dst_width;
*height = scene_buffer->dst_height;
- } else {
+ } else if (scene_buffer->buffer) {
if (scene_buffer->transform & WL_OUTPUT_TRANSFORM_90) {
*height = scene_buffer->buffer->width;
*width = scene_buffer->buffer->height;
@@ -838,6 +840,9 @@ static void render_node_iterator(struct wlr_scene_node *node,
break;
case WLR_SCENE_NODE_BUFFER:;
struct wlr_scene_buffer *scene_buffer = scene_buffer_from_node(node);
+ if (!scene_buffer->buffer) {
+ return;
+ }
struct wlr_renderer *renderer = output->renderer;
texture = scene_buffer_get_texture(scene_buffer, renderer);