damage: remove 'scroll' sub struct

There is no other types of damage but scroll damage.
This commit is contained in:
Daniel Eklöf 2020-04-26 12:47:19 +02:00
parent ce280537de
commit e9ed3025a8
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
3 changed files with 32 additions and 34 deletions

View file

@ -521,11 +521,11 @@ static void
grid_render_scroll(struct terminal *term, struct buffer *buf, grid_render_scroll(struct terminal *term, struct buffer *buf,
const struct damage *dmg) const struct damage *dmg)
{ {
int height = (dmg->scroll.region.end - dmg->scroll.region.start - dmg->scroll.lines) * term->cell_height; int height = (dmg->region.end - dmg->region.start - dmg->lines) * term->cell_height;
LOG_DBG( LOG_DBG(
"damage: SCROLL: %d-%d by %d lines", "damage: SCROLL: %d-%d by %d lines",
dmg->scroll.region.start, dmg->scroll.region.end, dmg->scroll.lines); dmg->region.start, dmg->region.end, dmg->lines);
if (height <= 0) if (height <= 0)
return; return;
@ -535,8 +535,8 @@ grid_render_scroll(struct terminal *term, struct buffer *buf,
gettimeofday(&start_time, NULL); gettimeofday(&start_time, NULL);
#endif #endif
int dst_y = term->margins.top + (dmg->scroll.region.start + 0) * term->cell_height; int dst_y = term->margins.top + (dmg->region.start + 0) * term->cell_height;
int src_y = term->margins.top + (dmg->scroll.region.start + dmg->scroll.lines) * term->cell_height; int src_y = term->margins.top + (dmg->region.start + dmg->lines) * term->cell_height;
/* /*
* SHM scrolling can be *much* faster, but it depends on how many * SHM scrolling can be *much* faster, but it depends on how many
@ -565,7 +565,7 @@ grid_render_scroll(struct terminal *term, struct buffer *buf,
* simply count lines. * simply count lines.
* *
* SHM scrolling needs to first "move" (punch hole + allocate) * SHM scrolling needs to first "move" (punch hole + allocate)
* dmg->scroll.lines number of lines, and then we need to restore * dmg->lines number of lines, and then we need to restore
* the bottom scroll region. * the bottom scroll region.
* *
* If the total number of lines is less than half the screen - use * If the total number of lines is less than half the screen - use
@ -573,9 +573,9 @@ grid_render_scroll(struct terminal *term, struct buffer *buf,
*/ */
bool try_shm_scroll = bool try_shm_scroll =
shm_can_scroll(buf) && ( shm_can_scroll(buf) && (
dmg->scroll.lines + dmg->lines +
dmg->scroll.region.start + dmg->region.start +
(term->rows - dmg->scroll.region.end)) < term->rows / 2; (term->rows - dmg->region.end)) < term->rows / 2;
bool did_shm_scroll = false; bool did_shm_scroll = false;
@ -584,16 +584,16 @@ grid_render_scroll(struct terminal *term, struct buffer *buf,
if (try_shm_scroll) { if (try_shm_scroll) {
did_shm_scroll = shm_scroll( did_shm_scroll = shm_scroll(
term->wl->shm, buf, dmg->scroll.lines * term->cell_height, term->wl->shm, buf, dmg->lines * term->cell_height,
term->margins.top, dmg->scroll.region.start * term->cell_height, term->margins.top, dmg->region.start * term->cell_height,
term->margins.bottom, (term->rows - dmg->scroll.region.end) * term->cell_height); term->margins.bottom, (term->rows - dmg->region.end) * term->cell_height);
} }
if (did_shm_scroll) { if (did_shm_scroll) {
/* Restore margins */ /* Restore margins */
render_margin( render_margin(
term, buf, dmg->scroll.region.end - dmg->scroll.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 */
@ -610,7 +610,7 @@ grid_render_scroll(struct terminal *term, struct buffer *buf,
struct timeval memmove_time; struct timeval memmove_time;
timersub(&end_time, &start_time, &memmove_time); timersub(&end_time, &start_time, &memmove_time);
LOG_INFO("scrolled %dKB (%d lines) using %s in %lds %ldus", LOG_INFO("scrolled %dKB (%d lines) using %s in %lds %ldus",
height * buf->stride / 1024, dmg->scroll.lines, height * buf->stride / 1024, dmg->lines,
did_shm_scroll ? "SHM" : try_shm_scroll ? "memmove (SHM failed)" : "memmove", did_shm_scroll ? "SHM" : try_shm_scroll ? "memmove (SHM failed)" : "memmove",
memmove_time.tv_sec, memmove_time.tv_usec); memmove_time.tv_sec, memmove_time.tv_usec);
#endif #endif
@ -624,11 +624,11 @@ static void
grid_render_scroll_reverse(struct terminal *term, struct buffer *buf, grid_render_scroll_reverse(struct terminal *term, struct buffer *buf,
const struct damage *dmg) const struct damage *dmg)
{ {
int height = (dmg->scroll.region.end - dmg->scroll.region.start - dmg->scroll.lines) * term->cell_height; int height = (dmg->region.end - dmg->region.start - dmg->lines) * term->cell_height;
LOG_DBG( LOG_DBG(
"damage: SCROLL REVERSE: %d-%d by %d lines", "damage: SCROLL REVERSE: %d-%d by %d lines",
dmg->scroll.region.start, dmg->scroll.region.end, dmg->scroll.lines); dmg->region.start, dmg->region.end, dmg->lines);
if (height <= 0) if (height <= 0)
return; return;
@ -638,28 +638,28 @@ grid_render_scroll_reverse(struct terminal *term, struct buffer *buf,
gettimeofday(&start_time, NULL); gettimeofday(&start_time, NULL);
#endif #endif
int src_y = term->margins.top + (dmg->scroll.region.start + 0) * term->cell_height; int src_y = term->margins.top + (dmg->region.start + 0) * term->cell_height;
int dst_y = term->margins.top + (dmg->scroll.region.start + dmg->scroll.lines) * term->cell_height; int dst_y = term->margins.top + (dmg->region.start + dmg->lines) * term->cell_height;
bool try_shm_scroll = bool try_shm_scroll =
shm_can_scroll(buf) && ( shm_can_scroll(buf) && (
dmg->scroll.lines + dmg->lines +
dmg->scroll.region.start + dmg->region.start +
(term->rows - dmg->scroll.region.end)) < term->rows / 2; (term->rows - dmg->region.end)) < term->rows / 2;
bool did_shm_scroll = false; bool did_shm_scroll = false;
if (try_shm_scroll) { if (try_shm_scroll) {
did_shm_scroll = shm_scroll( did_shm_scroll = shm_scroll(
term->wl->shm, buf, -dmg->scroll.lines * term->cell_height, term->wl->shm, buf, -dmg->lines * term->cell_height,
term->margins.top, dmg->scroll.region.start * term->cell_height, term->margins.top, dmg->region.start * term->cell_height,
term->margins.bottom, (term->rows - dmg->scroll.region.end) * term->cell_height); term->margins.bottom, (term->rows - dmg->region.end) * term->cell_height);
} }
if (did_shm_scroll) { if (did_shm_scroll) {
/* Restore margins */ /* Restore margins */
render_margin( render_margin(
term, buf, dmg->scroll.region.start, dmg->scroll.region.start + dmg->scroll.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 */
@ -676,7 +676,7 @@ grid_render_scroll_reverse(struct terminal *term, struct buffer *buf,
struct timeval memmove_time; struct timeval memmove_time;
timersub(&end_time, &start_time, &memmove_time); timersub(&end_time, &start_time, &memmove_time);
LOG_INFO("scrolled REVERSE %dKB (%d lines) using %s in %lds %ldus", LOG_INFO("scrolled REVERSE %dKB (%d lines) using %s in %lds %ldus",
height * buf->stride / 1024, dmg->scroll.lines, height * buf->stride / 1024, dmg->lines,
did_shm_scroll ? "SHM" : try_shm_scroll ? "memmove (SHM failed)" : "memmove", did_shm_scroll ? "SHM" : try_shm_scroll ? "memmove (SHM failed)" : "memmove",
memmove_time.tv_sec, memmove_time.tv_usec); memmove_time.tv_sec, memmove_time.tv_usec);
#endif #endif

View file

@ -1449,16 +1449,17 @@ term_damage_scroll(struct terminal *term, enum damage_type damage_type,
struct damage *dmg = &tll_back(term->grid->scroll_damage); struct damage *dmg = &tll_back(term->grid->scroll_damage);
if (dmg->type == damage_type && if (dmg->type == damage_type &&
dmg->scroll.region.start == region.start && dmg->region.start == region.start &&
dmg->scroll.region.end == region.end) dmg->region.end == region.end)
{ {
dmg->scroll.lines += lines; dmg->lines += lines;
return; return;
} }
} }
struct damage dmg = { struct damage dmg = {
.type = damage_type, .type = damage_type,
.scroll = {.region = region, .lines = lines}, .region = region,
.lines = lines,
}; };
tll_push_back(term->grid->scroll_damage, dmg); tll_push_back(term->grid->scroll_damage, dmg);
} }

View file

@ -73,11 +73,8 @@ enum damage_type {DAMAGE_SCROLL, DAMAGE_SCROLL_REVERSE,
struct damage { struct damage {
enum damage_type type; enum damage_type type;
/* DAMAGE_SCROLL, DAMAGE_SCROLL_REVERSE */ struct scroll_region region;
struct { int lines;
struct scroll_region region;
int lines;
} scroll;
}; };
struct row { struct row {