aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-05-07 08:08:38 -0400
committerGitHub <noreply@github.com>2018-05-07 08:08:38 -0400
commit7c2241a55658468fbbeec5cc544e377ad0bccb58 (patch)
tree0833c1ebaa573152c9a86ea654c30369cdac7a8d
parenta3fd284876b2d2e12101fc912c012936a04df198 (diff)
parent5087199d5d2e7c2768ac4610a7721bac8071f0fd (diff)
Merge pull request #957 from emersion/output-damage-max-rects
output-damage: limit the number of damaged rectangles
-rw-r--r--include/wlr/types/wlr_output_damage.h1
-rw-r--r--types/wlr_output_damage.c9
2 files changed, 10 insertions, 0 deletions
diff --git a/include/wlr/types/wlr_output_damage.h b/include/wlr/types/wlr_output_damage.h
index beba2f6c..a4333c1a 100644
--- a/include/wlr/types/wlr_output_damage.h
+++ b/include/wlr/types/wlr_output_damage.h
@@ -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
diff --git a/types/wlr_output_damage.c b/types/wlr_output_damage.c
index b3636c37..bf3a671d 100644
--- a/types/wlr_output_damage.c
+++ b/types/wlr_output_damage.c
@@ -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);