aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-11-26 10:06:56 +0100
committerSimon Ser <contact@emersion.fr>2022-11-26 10:06:56 +0100
commit35a0d9c85d63344c41a4b2fd5ec9ed4636889b8a (patch)
tree70965028b0ed967908d22277b571b2ae0d2229a6
parentce089498cc70ab726695e8b19ba994a00cd3beb9 (diff)
scene: set output damage during direct scan-out
This allows the backend to have access to the frame damage, as reported by the scanned-out client. Some KMS drivers can make use of it (e.g. for PSR, or optimized USB transfers in the GUD driver), and the Wayland/X11 backends forward it to the parent compositor.
-rw-r--r--types/scene/wlr_scene.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/types/scene/wlr_scene.c b/types/scene/wlr_scene.c
index cf6eb81c..6b98b65b 100644
--- a/types/scene/wlr_scene.c
+++ b/types/scene/wlr_scene.c
@@ -1378,6 +1378,21 @@ static bool construct_render_list_iterator(struct wlr_scene_node *node,
return false;
}
+static void get_frame_damage(struct wlr_scene_output *scene_output, pixman_region32_t *frame_damage) {
+ struct wlr_output *output = scene_output->output;
+
+ int tr_width, tr_height;
+ wlr_output_transformed_resolution(output, &tr_width, &tr_height);
+
+ enum wl_output_transform transform =
+ wlr_output_transform_invert(output->transform);
+
+ pixman_region32_init(frame_damage);
+ wlr_region_transform(frame_damage,
+ &scene_output->damage_ring.current,
+ transform, tr_width, tr_height);
+}
+
static bool scene_node_try_direct_scanout(struct wlr_scene_node *node,
struct wlr_scene_output *scene_output, struct wlr_box *box) {
if (!scene_output->scene->direct_scanout) {
@@ -1433,7 +1448,17 @@ static bool scene_node_try_direct_scanout(struct wlr_scene_node *node,
return false;
}
- return wlr_output_commit_state(output, &state);
+ state.committed |= WLR_OUTPUT_STATE_DAMAGE;
+ get_frame_damage(scene_output, &state.damage);
+ bool ok = wlr_output_commit_state(output, &state);
+ pixman_region32_fini(&state.damage);
+ if (!ok) {
+ return false;
+ }
+
+ wlr_damage_ring_rotate(&scene_output->damage_ring);
+
+ return true;
}
bool wlr_scene_output_commit(struct wlr_scene_output *scene_output) {
@@ -1634,17 +1659,8 @@ bool wlr_scene_output_commit(struct wlr_scene_output *scene_output) {
wlr_renderer_end(renderer);
pixman_region32_fini(&damage);
- int tr_width, tr_height;
- wlr_output_transformed_resolution(output, &tr_width, &tr_height);
-
- enum wl_output_transform transform =
- wlr_output_transform_invert(output->transform);
-
pixman_region32_t frame_damage;
- pixman_region32_init(&frame_damage);
- wlr_region_transform(&frame_damage,
- &scene_output->damage_ring.current,
- transform, tr_width, tr_height);
+ get_frame_damage(scene_output, &frame_damage);
wlr_output_set_damage(output, &frame_damage);
pixman_region32_fini(&frame_damage);