mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-04 07:15:29 -04:00
term: optimize damage list after scroll
This optimizes the normal scrolling case; updates are done at the bottom of the screen and then scrolled up. In this case, the damage list will be a more or less sorted list of updates, oldest first. If we're scrolling a lot, the oldest updates will eventually scroll off screen. In this case, there's no need to keep them in the damage list. So, when scrolling, loop the damage list and adjust/remove updates that have scrolled off screen (either partially, or completely). Stop looping as soon as we see an update that has *not* scrolled off screen. Note that this means there may be update items in the damage list that *has* scrolled off screen. This is especially true for random screen writes (i.e. typical to some synthetic benchmarks).
This commit is contained in:
parent
0fef48c1fd
commit
e6c27645fa
1 changed files with 17 additions and 0 deletions
17
terminal.c
17
terminal.c
|
|
@ -119,6 +119,23 @@ term_damage_scroll(struct terminal *term, enum damage_type damage_type,
|
||||||
struct scroll_region region, int lines)
|
struct scroll_region region, int lines)
|
||||||
{
|
{
|
||||||
//damage_adjust_after_scroll(term, damage_type, region, lines);
|
//damage_adjust_after_scroll(term, damage_type, region, lines);
|
||||||
|
if (damage_type == DAMAGE_SCROLL) {
|
||||||
|
tll_foreach(term->grid->damage, it) {
|
||||||
|
int start = it->item.range.start;
|
||||||
|
int length = it->item.range.length;
|
||||||
|
|
||||||
|
if (start < term->grid->offset) {
|
||||||
|
int end = start + length;
|
||||||
|
if (end >= term->grid->offset) {
|
||||||
|
it->item.range.start = term->grid->offset;
|
||||||
|
it->item.range.length = end - it->item.range.start;
|
||||||
|
} else
|
||||||
|
tll_remove(term->grid->damage, it);
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
assert(false);
|
||||||
|
|
||||||
if (tll_length(term->grid->scroll_damage) > 0) {
|
if (tll_length(term->grid->scroll_damage) > 0) {
|
||||||
struct damage *dmg = &tll_back(term->grid->scroll_damage);
|
struct damage *dmg = &tll_back(term->grid->scroll_damage);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue