aboutsummaryrefslogtreecommitdiff
path: root/render.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-03-25 17:26:58 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-03-25 17:26:58 +0000
commit03319560f5c7c908b1c1d229b3ba53ed1ac6b692 (patch)
treecf1444183de31327fd6828b1e877b7e043c5f3c2 /render.c
parentapp synchronized updates: set is_armed=false when enabling (diff)
shm: scroll: keep shm pool around, and fix its size at max allowed
This lessens the burden on (primarily) the compositor, since we no longer tear down and re-create the SHM pool when scrolling. The SHM pool is setup once, and its size is fixed at the maximum allowed (512MB for now, 2GB would be possible). This also allows us to mmap() the memfd once. The exposed raw pointer is simply an offset from the memfd mmapping. Note that this means e.g. rouge rendering code will be able to write outside the buffer. Finally, only do this if the caller explicitly wants to enable scrolling. The memfd of other buffers are sized to the requested size.
Diffstat (limited to 'render.c')
-rw-r--r--render.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/render.c b/render.c
index 4238a4b8..f77b7b3d 100644
--- a/render.c
+++ b/render.c
@@ -588,9 +588,10 @@ grid_render_scroll(struct terminal *term, struct buffer *buf,
* SHM. Otherwise use memmove.
*/
bool try_shm_scroll =
- shm_can_scroll() && (dmg->scroll.lines +
- dmg->scroll.region.start +
- (term->rows - dmg->scroll.region.end)) < term->rows / 2;
+ shm_can_scroll(buf) && (
+ dmg->scroll.lines +
+ dmg->scroll.region.start +
+ (term->rows - dmg->scroll.region.end)) < term->rows / 2;
bool did_shm_scroll = false;
@@ -657,9 +658,10 @@ grid_render_scroll_reverse(struct terminal *term, struct buffer *buf,
int dst_y = term->margins.top + (dmg->scroll.region.start + dmg->scroll.lines) * term->cell_height;
bool try_shm_scroll =
- shm_can_scroll() && (dmg->scroll.lines +
- dmg->scroll.region.start +
- (term->rows - dmg->scroll.region.end)) < term->rows / 2;
+ shm_can_scroll(buf) && (
+ dmg->scroll.lines +
+ dmg->scroll.region.start +
+ (term->rows - dmg->scroll.region.end)) < term->rows / 2;
bool did_shm_scroll = false;
@@ -912,7 +914,7 @@ render_csd_title(struct terminal *term)
unsigned long cookie = shm_cookie_csd(term, CSD_SURF_TITLE);
struct buffer *buf = shm_get_buffer(
- term->wl->shm, info.width, info.height, cookie);
+ term->wl->shm, info.width, info.height, cookie, false);
uint32_t _color = term->colors.default_fg;
uint16_t alpha = 0xffff;
@@ -943,7 +945,7 @@ render_csd_border(struct terminal *term, enum csd_surface surf_idx)
unsigned long cookie = shm_cookie_csd(term, surf_idx);
struct buffer *buf = shm_get_buffer(
- term->wl->shm, info.width, info.height, cookie);
+ term->wl->shm, info.width, info.height, cookie, false);
pixman_color_t color = color_hex_to_pixman_with_alpha(0, 0);
render_csd_part(term, surf, buf, info.width, info.height, &color);
@@ -1112,7 +1114,7 @@ render_csd_button(struct terminal *term, enum csd_surface surf_idx)
unsigned long cookie = shm_cookie_csd(term, surf_idx);
struct buffer *buf = shm_get_buffer(
- term->wl->shm, info.width, info.height, cookie);
+ term->wl->shm, info.width, info.height, cookie, false);
uint32_t _color;
uint16_t alpha = 0xffff;
@@ -1239,7 +1241,7 @@ grid_render(struct terminal *term)
unsigned long cookie = shm_cookie_grid(term);
struct buffer *buf = shm_get_buffer(
- term->wl->shm, term->width, term->height, cookie);
+ term->wl->shm, term->width, term->height, cookie, true);
pixman_image_set_clip_region(buf->pix, NULL);
@@ -1526,7 +1528,7 @@ render_search_box(struct terminal *term)
size_t glyph_offset = term->render.search_glyph_offset;
unsigned long cookie = shm_cookie_search(term);
- struct buffer *buf = shm_get_buffer(term->wl->shm, width, height, cookie);
+ struct buffer *buf = shm_get_buffer(term->wl->shm, width, height, cookie, false);
/* Background - yellow on empty/match, red on mismatch */
pixman_color_t color = color_hex_to_pixman(