mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-29 07:58:01 -04:00
render: last_buf may point to a free:d buffer
So, store last buf's width/height separately
This commit is contained in:
parent
5812242405
commit
4d3251a93b
2 changed files with 23 additions and 9 deletions
26
render.c
26
render.c
|
|
@ -451,25 +451,33 @@ grid_render(struct terminal *term)
|
||||||
bool all_clean = tll_length(term->grid->scroll_damage) == 0;
|
bool all_clean = tll_length(term->grid->scroll_damage) == 0;
|
||||||
|
|
||||||
/* If we resized the window, or is flashing, or just stopped flashing */
|
/* If we resized the window, or is flashing, or just stopped flashing */
|
||||||
if (term->render.last_buf != buf ||
|
if (term->render.last_shm.buf != buf ||
|
||||||
term->flash.active || term->render.was_flashing ||
|
term->flash.active || term->render.was_flashing ||
|
||||||
term->is_searching != term->render.was_searching)
|
term->is_searching != term->render.was_searching)
|
||||||
{
|
{
|
||||||
if (term->render.last_buf != NULL &&
|
/*
|
||||||
term->render.last_buf->width == buf->width &&
|
* TODO: shm buffers may be purged, meaning our last_buf (when
|
||||||
term->render.last_buf->height == buf->height &&
|
* != buf) may point to a free:d buffer.
|
||||||
|
*
|
||||||
|
* It *shouldn't*, as long as the sizes match... but would
|
||||||
|
* still be good to find a better solution for this.
|
||||||
|
*/
|
||||||
|
if (term->render.last_shm.buf != NULL &&
|
||||||
|
term->render.last_shm.width == buf->width &&
|
||||||
|
term->render.last_shm.height == buf->height &&
|
||||||
!term->flash.active &&
|
!term->flash.active &&
|
||||||
!term->render.was_flashing &&
|
!term->render.was_flashing &&
|
||||||
term->is_searching == term->render.was_searching)
|
term->is_searching == term->render.was_searching)
|
||||||
{
|
{
|
||||||
static bool has_warned = false;
|
static bool has_warned = false;
|
||||||
if (!has_warned) {
|
if (!has_warned) {
|
||||||
LOG_WARN("it appears your Wayland compositor does not support buffer re-use for SHM clients; expect lower performance.");
|
LOG_WARN(
|
||||||
|
"it appears your Wayland compositor does not support "
|
||||||
|
"buffer re-use for SHM clients; expect lower performance.");
|
||||||
has_warned = true;
|
has_warned = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(term->render.last_buf->size == buf->size);
|
memcpy(buf->mmapped, term->render.last_shm.buf->mmapped, buf->size);
|
||||||
memcpy(buf->mmapped, term->render.last_buf->mmapped, buf->size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
|
@ -505,7 +513,9 @@ grid_render(struct terminal *term)
|
||||||
term_damage_view(term);
|
term_damage_view(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
term->render.last_buf = buf;
|
term->render.last_shm.buf = buf;
|
||||||
|
term->render.last_shm.width = buf->width;
|
||||||
|
term->render.last_shm.height = buf->height;
|
||||||
term->render.was_flashing = term->flash.active;
|
term->render.was_flashing = term->flash.active;
|
||||||
term->render.was_searching = term->is_searching;
|
term->render.was_searching = term->is_searching;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -276,7 +276,11 @@ struct terminal {
|
||||||
struct cell *cell; /* For easy access to content */
|
struct cell *cell; /* For easy access to content */
|
||||||
} last_cursor;
|
} last_cursor;
|
||||||
|
|
||||||
struct buffer *last_buf; /* Buffer we rendered to last time */
|
struct {
|
||||||
|
struct buffer *buf; /* Buffer we rendered to last time */
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
} last_shm;
|
||||||
bool was_flashing; /* Flash was active last time we rendered */
|
bool was_flashing; /* Flash was active last time we rendered */
|
||||||
bool was_searching;
|
bool was_searching;
|
||||||
} render;
|
} render;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue