From a1d2044d75050e72b8150d2f11147cf58a533c7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 8 May 2021 09:18:45 +0200 Subject: [PATCH] =?UTF-8?q?render:=20subtract=20current=20frame=E2=80=99s?= =?UTF-8?q?=20damage=20when=20there=E2=80=99s=20no=20scroll=20damage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When re-applying the previous frame’s damage (due to us being forced to double buffer), subtract the current frame’s damage from the region-to-copy when there’s no scroll damage on the current frame. When the current frame doesn’t have any scroll damage, the current frame’s damage is in the same coordinate system as the previous frame’s damage, and we can safely remove it from the region we copy from. --- render.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/render.c b/render.c index 3c97df97..42b2f9ea 100644 --- a/render.c +++ b/render.c @@ -2099,7 +2099,6 @@ grid_render(struct terminal *term) tll_free(term->render.last_buf->scroll_damage); #else -#if 0 /* * TODO: remove this frame’s damage from the region we * copy from the old frame. @@ -2138,7 +2137,7 @@ grid_render(struct terminal *term) term->cell_height); } } -#endif + tll_foreach(term->render.last_buf->scroll_damage, it) { switch (it->item.type) { case DAMAGE_SCROLL: @@ -2163,21 +2162,18 @@ grid_render(struct terminal *term) tll_remove(term->render.last_buf->scroll_damage, it); } -#if 0 - pixman_region32_subtract(&dirty, &term->render.last_buf->dirty, &dirty); - pixman_image_set_clip_region32(buf->pix[0], &dirty); -#else - pixman_image_set_clip_region32(buf->pix[0], &term->render.last_buf->dirty); -#endif + if (tll_length(term->grid->scroll_damage) == 0) { + pixman_region32_subtract(&dirty, &term->render.last_buf->dirty, &dirty); + pixman_image_set_clip_region32(buf->pix[0], &dirty); + } else + pixman_image_set_clip_region32(buf->pix[0], &term->render.last_buf->dirty); pixman_image_composite32( PIXMAN_OP_SRC, term->render.last_buf->pix[0], NULL, buf->pix[0], 0, 0, 0, 0, 0, 0, term->width, term->height); pixman_image_set_clip_region32(buf->pix[0], NULL); -#if 0 pixman_region32_fini(&dirty); -#endif #endif }