|
|
|
@ -15,10 +15,6 @@ void wlr_damage_ring_init(struct wlr_damage_ring *ring) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
pixman_region32_init(&ring->current);
|
|
|
|
|
for (size_t i = 0; i < WLR_DAMAGE_RING_PREVIOUS_LEN; ++i) {
|
|
|
|
|
pixman_region32_init(&ring->previous[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wl_list_init(&ring->buffers);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -31,9 +27,6 @@ static void buffer_destroy(struct wlr_damage_ring_buffer *entry) {
|
|
|
|
|
|
|
|
|
|
void wlr_damage_ring_finish(struct wlr_damage_ring *ring) {
|
|
|
|
|
pixman_region32_fini(&ring->current);
|
|
|
|
|
for (size_t i = 0; i < WLR_DAMAGE_RING_PREVIOUS_LEN; ++i) {
|
|
|
|
|
pixman_region32_fini(&ring->previous[i]);
|
|
|
|
|
}
|
|
|
|
|
struct wlr_damage_ring_buffer *entry, *tmp_entry;
|
|
|
|
|
wl_list_for_each_safe(entry, tmp_entry, &ring->buffers, link) {
|
|
|
|
|
buffer_destroy(entry);
|
|
|
|
@ -92,43 +85,6 @@ void wlr_damage_ring_add_whole(struct wlr_damage_ring *ring) {
|
|
|
|
|
&ring->current, 0, 0, ring->width, ring->height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void wlr_damage_ring_rotate(struct wlr_damage_ring *ring) {
|
|
|
|
|
// modular decrement
|
|
|
|
|
ring->previous_idx = ring->previous_idx +
|
|
|
|
|
WLR_DAMAGE_RING_PREVIOUS_LEN - 1;
|
|
|
|
|
ring->previous_idx %= WLR_DAMAGE_RING_PREVIOUS_LEN;
|
|
|
|
|
|
|
|
|
|
pixman_region32_copy(&ring->previous[ring->previous_idx], &ring->current);
|
|
|
|
|
pixman_region32_clear(&ring->current);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void wlr_damage_ring_get_buffer_damage(struct wlr_damage_ring *ring,
|
|
|
|
|
int buffer_age, pixman_region32_t *damage) {
|
|
|
|
|
if (buffer_age <= 0 || buffer_age - 1 > WLR_DAMAGE_RING_PREVIOUS_LEN) {
|
|
|
|
|
pixman_region32_clear(damage);
|
|
|
|
|
pixman_region32_union_rect(damage, damage,
|
|
|
|
|
0, 0, ring->width, ring->height);
|
|
|
|
|
} else {
|
|
|
|
|
pixman_region32_copy(damage, &ring->current);
|
|
|
|
|
|
|
|
|
|
// Accumulate damage from old buffers
|
|
|
|
|
for (int i = 0; i < buffer_age - 1; ++i) {
|
|
|
|
|
int j = (ring->previous_idx + i) % WLR_DAMAGE_RING_PREVIOUS_LEN;
|
|
|
|
|
pixman_region32_union(damage, damage, &ring->previous[j]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check the number of rectangles
|
|
|
|
|
int n_rects = pixman_region32_n_rects(damage);
|
|
|
|
|
if (n_rects > WLR_DAMAGE_RING_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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void entry_squash_damage(struct wlr_damage_ring_buffer *entry) {
|
|
|
|
|
pixman_region32_t *prev;
|
|
|
|
|
if (entry->link.prev == &entry->ring->buffers) {
|
|
|
|
|