diff options
-rw-r--r-- | include/wlr/types/wlr_scene.h | 7 | ||||
-rw-r--r-- | types/scene/wlr_scene.c | 16 |
2 files changed, 23 insertions, 0 deletions
diff --git a/include/wlr/types/wlr_scene.h b/include/wlr/types/wlr_scene.h index 4e1dd17a..87cf4fc9 100644 --- a/include/wlr/types/wlr_scene.h +++ b/include/wlr/types/wlr_scene.h @@ -166,6 +166,7 @@ struct wlr_scene_buffer { // private state + float opacity; uint64_t active_outputs; struct wlr_texture *texture; struct wlr_fbox src_box; @@ -416,6 +417,12 @@ void wlr_scene_buffer_set_transform(struct wlr_scene_buffer *scene_buffer, enum wl_output_transform transform); /** +* Sets the opacity of this buffer +*/ +void wlr_scene_buffer_set_opacity(struct wlr_scene_buffer *scene_buffer, + float opacity); + +/** * Calls the buffer's frame_done signal. */ void wlr_scene_buffer_send_frame_done(struct wlr_scene_buffer *scene_buffer, diff --git a/types/scene/wlr_scene.c b/types/scene/wlr_scene.c index 4a1fc028..5e85ecf7 100644 --- a/types/scene/wlr_scene.c +++ b/types/scene/wlr_scene.c @@ -241,6 +241,10 @@ static void scene_node_opaque_region(struct wlr_scene_node *node, int x, int y, return; } + if (scene_buffer->opacity != 1) { + return; + } + if (!buffer_is_opaque(scene_buffer->buffer)) { pixman_region32_copy(opaque, &scene_buffer->opaque_region); pixman_region32_translate(opaque, x, y); @@ -604,6 +608,7 @@ struct wlr_scene_buffer *wlr_scene_buffer_create(struct wlr_scene_tree *parent, wl_signal_init(&scene_buffer->events.output_present); wl_signal_init(&scene_buffer->events.frame_done); pixman_region32_init(&scene_buffer->opaque_region); + scene_buffer->opacity = 1; scene_node_update(&scene_buffer->node, NULL); @@ -794,6 +799,16 @@ void wlr_scene_buffer_send_frame_done(struct wlr_scene_buffer *scene_buffer, } } +void wlr_scene_buffer_set_opacity(struct wlr_scene_buffer *scene_buffer, + float opacity) { + if (scene_buffer->opacity == opacity) { + return; + } + + scene_buffer->opacity = opacity; + scene_node_update(&scene_buffer->node, NULL); +} + static struct wlr_texture *scene_buffer_get_texture( struct wlr_scene_buffer *scene_buffer, struct wlr_renderer *renderer) { struct wlr_client_buffer *client_buffer = @@ -1127,6 +1142,7 @@ static void scene_node_render(struct wlr_scene_node *node, .dst_box = dst_box, .transform = transform, .clip = &render_region, + .alpha = &scene_buffer->opacity, }); wl_signal_emit_mutable(&scene_buffer->events.output_present, scene_output); |