wlr_scene: Introduce wlr_scene_buffer_set_opacity

master
Alexander Orzechowski 2 years ago committed by Simon Ser
parent 2346b90a9f
commit 95062904c7

@ -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;
@ -415,6 +416,12 @@ void wlr_scene_buffer_set_dest_size(struct wlr_scene_buffer *scene_buffer,
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.
*/

@ -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);

Loading…
Cancel
Save