mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-13 08:55:58 +01:00
output-damage: limit the number of damaged rectangles
This commit is contained in:
parent
a3fd284876
commit
5087199d5d
2 changed files with 10 additions and 0 deletions
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
struct wlr_output_damage {
|
||||
struct wlr_output *output;
|
||||
int max_rects; // max number of damaged rectangles
|
||||
|
||||
pixman_region32_t current; // in output-local coordinates
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ struct wlr_output_damage *wlr_output_damage_create(struct wlr_output *output) {
|
|||
}
|
||||
|
||||
output_damage->output = output;
|
||||
output_damage->max_rects = 20;
|
||||
wl_signal_init(&output_damage->events.frame);
|
||||
wl_signal_init(&output_damage->events.destroy);
|
||||
|
||||
|
@ -125,6 +126,14 @@ bool wlr_output_damage_make_current(struct wlr_output_damage *output_damage,
|
|||
int j = (idx + i) % WLR_OUTPUT_DAMAGE_PREVIOUS_LEN;
|
||||
pixman_region32_union(damage, damage, &output_damage->previous[j]);
|
||||
}
|
||||
|
||||
// Check the number of rectangles
|
||||
int n_rects = pixman_region32_n_rects(damage);
|
||||
if (n_rects > output_damage->max_rects) {
|
||||
pixman_box32_t *extents = pixman_region32_extents(damage);
|
||||
pixman_region32_union_rect(damage, damage, extents->x1, extents->y1,
|
||||
extents->x2 - extents->x1, extents->y2 - extents->y1);
|
||||
}
|
||||
}
|
||||
|
||||
*needs_swap = output->needs_swap || pixman_region32_not_empty(damage);
|
||||
|
|
Loading…
Reference in a new issue