render: render_margin: add 'damage_{top,bottom,left,right}' arguments

This commit is contained in:
Daniel Eklöf 2020-07-13 14:06:02 +02:00
parent 0336f47f05
commit ed620f1854
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -504,7 +504,9 @@ draw_cursor:
static void static void
render_margin(struct terminal *term, struct buffer *buf, render_margin(struct terminal *term, struct buffer *buf,
int start_line, int end_line) int start_line, int end_line,
bool damage_top, bool damage_bottom,
bool damage_left, bool damage_right)
{ {
/* Fill area outside the cell grid with the default background color */ /* Fill area outside the cell grid with the default background color */
const int rmargin = term->width - term->margins.right; const int rmargin = term->width - term->margins.right;
@ -535,25 +537,25 @@ render_margin(struct terminal *term, struct buffer *buf,
term->margins.right, line_count * term->cell_height}, term->margins.right, line_count * term->cell_height},
}); });
/* Top */ if (damage_top)
wl_surface_damage_buffer( wl_surface_damage_buffer(
term->window->surface, 0, 0, term->width, term->margins.top); term->window->surface, 0, 0, term->width, term->margins.top);
/* Bottom */ if (damage_bottom)
wl_surface_damage_buffer( wl_surface_damage_buffer(
term->window->surface, 0, bmargin, term->width, term->margins.bottom); term->window->surface, 0, bmargin, term->width, term->margins.bottom);
/* Left */ if (damage_left)
wl_surface_damage_buffer( wl_surface_damage_buffer(
term->window->surface, term->window->surface,
0, term->margins.top + start_line * term->cell_height, 0, term->margins.top + start_line * term->cell_height,
term->margins.left, line_count * term->cell_height); term->margins.left, line_count * term->cell_height);
/* Right */ if (damage_right)
wl_surface_damage_buffer( wl_surface_damage_buffer(
term->window->surface, term->window->surface,
rmargin, term->margins.top + start_line * term->cell_height, rmargin, term->margins.top + start_line * term->cell_height,
term->margins.right, line_count * term->cell_height); term->margins.right, line_count * term->cell_height);
} }
static void static void
@ -631,7 +633,8 @@ grid_render_scroll(struct terminal *term, struct buffer *buf,
if (did_shm_scroll) { if (did_shm_scroll) {
/* Restore margins */ /* Restore margins */
render_margin( render_margin(
term, buf, dmg->region.end - dmg->lines, term->rows); term, buf, dmg->region.end - dmg->lines, term->rows,
true, true, true, true);
} else { } else {
/* Fallback for when we either cannot do SHM scrolling, or it failed */ /* Fallback for when we either cannot do SHM scrolling, or it failed */
uint8_t *raw = buf->mmapped; uint8_t *raw = buf->mmapped;
@ -696,7 +699,8 @@ grid_render_scroll_reverse(struct terminal *term, struct buffer *buf,
if (did_shm_scroll) { if (did_shm_scroll) {
/* Restore margins */ /* Restore margins */
render_margin( render_margin(
term, buf, dmg->region.start, dmg->region.start + dmg->lines); term, buf, dmg->region.start, dmg->region.start + dmg->lines,
true, true, true, true);
} else { } else {
/* Fallback for when we either cannot do SHM scrolling, or it failed */ /* Fallback for when we either cannot do SHM scrolling, or it failed */
uint8_t *raw = buf->mmapped; uint8_t *raw = buf->mmapped;
@ -1337,7 +1341,7 @@ grid_render(struct terminal *term)
else { else {
tll_free(term->grid->scroll_damage); tll_free(term->grid->scroll_damage);
render_margin(term, buf, 0, term->rows); render_margin(term, buf, 0, term->rows, true, true, true, true);
term_damage_view(term); term_damage_view(term);
} }