diff options
| author | Alexander Orzechowski <alex@ozal.ski> | 2023-11-19 16:23:19 -0500 | 
|---|---|---|
| committer | Alexander Orzechowski <alex@ozal.ski> | 2023-12-03 05:29:05 +0000 | 
| commit | 06d301bf1a15826fb6ab89b9c40d40ecb86060cc (patch) | |
| tree | 6eba9bd93a96b350d2cbdccdeee531b9fea2d7b4 | |
| parent | 6e03d3015e1668bd70266b0ee4b0720b86ca59c7 (diff) | |
| download | wlroots-06d301bf1a15826fb6ab89b9c40d40ecb86060cc.tar.xz | |
wlr_scene: Track output damage separately
The damage ring is only supposed to keep track of damage within
the swapchain
| -rw-r--r-- | include/wlr/types/wlr_scene.h | 2 | ||||
| -rw-r--r-- | types/scene/wlr_scene.c | 25 | 
2 files changed, 25 insertions, 2 deletions
| diff --git a/include/wlr/types/wlr_scene.h b/include/wlr/types/wlr_scene.h index dc8d6fef..2811e95b 100644 --- a/include/wlr/types/wlr_scene.h +++ b/include/wlr/types/wlr_scene.h @@ -206,6 +206,8 @@ struct wlr_scene_output {  	// private state +	pixman_region32_t pending_commit_damage; +  	uint8_t index;  	bool prev_scanout; diff --git a/types/scene/wlr_scene.c b/types/scene/wlr_scene.c index c4470dc9..ebf806ed 100644 --- a/types/scene/wlr_scene.c +++ b/types/scene/wlr_scene.c @@ -1277,6 +1277,19 @@ static void scene_output_handle_commit(struct wl_listener *listener, void *data)  			WLR_OUTPUT_STATE_ENABLED)) {  		scene_output_update_geometry(scene_output, force_update);  	} + +	// if the output has been committed with a certain damage, we know that region +	// will be acknowledged by the backend so we don't need to keep track of it +	// anymore +	if (state->committed & WLR_OUTPUT_STATE_DAMAGE) { +		if (wlr_swapchain_has_buffer(scene_output->output->swapchain, state->buffer)) { +			pixman_region32_subtract(&scene_output->pending_commit_damage, +				&scene_output->pending_commit_damage, &state->damage); +		} else { +			pixman_region32_union(&scene_output->pending_commit_damage, +				&scene_output->pending_commit_damage, &state->damage); +		} +	}  }  static void scene_output_handle_damage(struct wl_listener *listener, void *data) { @@ -1306,6 +1319,7 @@ struct wlr_scene_output *wlr_scene_output_create(struct wlr_scene *scene,  	wlr_addon_init(&scene_output->addon, &output->addons, scene, &output_addon_impl);  	wlr_damage_ring_init(&scene_output->damage_ring); +	pixman_region32_init(&scene_output->pending_commit_damage);  	wl_list_init(&scene_output->damage_highlight_regions);  	int prev_output_index = -1; @@ -1364,6 +1378,7 @@ void wlr_scene_output_destroy(struct wlr_scene_output *scene_output) {  	wlr_addon_finish(&scene_output->addon);  	wlr_damage_ring_finish(&scene_output->damage_ring); +	pixman_region32_fini(&scene_output->pending_commit_damage);  	wl_list_remove(&scene_output->link);  	wl_list_remove(&scene_output->output_commit.link);  	wl_list_remove(&scene_output->output_damage.link); @@ -1467,9 +1482,15 @@ static bool construct_render_list_iterator(struct wlr_scene_node *node,  static void output_state_apply_damage(const struct render_data *data,  		struct wlr_output_state *state) { +	struct wlr_scene_output *output = data->output; +	pixman_region32_union(&output->pending_commit_damage, +		&output->pending_commit_damage, &output->damage_ring.current); +	pixman_region32_intersect_rect(&output->pending_commit_damage, +		&output->pending_commit_damage, 0, 0, data->trans_width, data->trans_height); +  	pixman_region32_t frame_damage;  	pixman_region32_init(&frame_damage); -	pixman_region32_copy(&frame_damage, &data->output->damage_ring.current); +	pixman_region32_copy(&frame_damage, &output->pending_commit_damage);  	transform_output_damage(&frame_damage, data);  	wlr_output_state_set_damage(state, &frame_damage);  	pixman_region32_fini(&frame_damage); @@ -1601,7 +1622,7 @@ static bool scene_entry_try_direct_scanout(struct render_list_entry *entry,  bool wlr_scene_output_commit(struct wlr_scene_output *scene_output,  		const struct wlr_scene_output_state_options *options) {  	if (!scene_output->output->needs_frame && !pixman_region32_not_empty( -			&scene_output->damage_ring.current)) { +			&scene_output->pending_commit_damage)) {  		return true;  	} | 
