From e66c02751b47b84ba247dae33d36bf45cc8ae2bd Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Thu, 14 Sep 2023 16:30:37 -0400 Subject: [PATCH] wlr_scene: Use wlr_damage_ring_damage_for_buffer() Compositors who use _build_state are no longer required to call damage_ring_rotate themselves. This is a minor breaking change. --- types/scene/wlr_scene.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/types/scene/wlr_scene.c b/types/scene/wlr_scene.c index 75ea6bccd..53bb890d6 100644 --- a/types/scene/wlr_scene.c +++ b/types/scene/wlr_scene.c @@ -1631,8 +1631,6 @@ bool wlr_scene_output_commit(struct wlr_scene_output *scene_output, goto out; } - wlr_damage_ring_rotate(&scene_output->damage_ring); - out: wlr_output_state_finish(&state); return ok; @@ -1783,8 +1781,7 @@ bool wlr_scene_output_build_state(struct wlr_scene_output *scene_output, return false; } - int buffer_age; - struct wlr_buffer *buffer = wlr_swapchain_acquire(output->swapchain, &buffer_age); + struct wlr_buffer *buffer = wlr_swapchain_acquire(output->swapchain, NULL); if (buffer == NULL) { return false; } @@ -1808,9 +1805,11 @@ bool wlr_scene_output_build_state(struct wlr_scene_output *scene_output, } render_data.render_pass = render_pass; + + output_state_apply_damage(&render_data, state); pixman_region32_init(&render_data.damage); - wlr_damage_ring_get_buffer_damage(&scene_output->damage_ring, - buffer_age, &render_data.damage); + wlr_damage_ring_damage_for_buffer(&scene_output->damage_ring, buffer, + &render_data.damage); pixman_region32_t background; pixman_region32_init(&background); @@ -1896,12 +1895,15 @@ bool wlr_scene_output_build_state(struct wlr_scene_output *scene_output, if (!wlr_render_pass_submit(render_pass)) { wlr_buffer_unlock(buffer); + + // if we failed to render the buffer, it will have undefined contents + // Trash the damage ring + wlr_damage_ring_add_whole(&scene_output->damage_ring); return false; } wlr_output_state_set_buffer(state, buffer); wlr_buffer_unlock(buffer); - output_state_apply_damage(&render_data, state); if (debug_damage == WLR_SCENE_DEBUG_DAMAGE_HIGHLIGHT && !wl_list_empty(&scene_output->damage_highlight_regions)) {