diff --git a/sixel.c b/sixel.c index 18a9c146..170ef4e4 100644 --- a/sixel.c +++ b/sixel.c @@ -15,16 +15,6 @@ static size_t count; -static uint32_t -get_bg(const struct terminal *term) -{ - return term->sixel.transparent_bg - ? 0x00000000u - : 0xffu << 24 | (term->vt.attrs.have_bg - ? term->vt.attrs.bg - : term->colors.bg); -} - void sixel_fini(struct terminal *term) { @@ -78,9 +68,14 @@ sixel_init(struct terminal *term, int p1, int p2, int p3) term->sixel.palette = term->sixel.shared_palette; } - uint32_t bg = get_bg(term); + term->sixel.default_bg = term->sixel.transparent_bg + ? 0x00000000u + : 0xffu << 24 | (term->vt.attrs.have_bg + ? term->vt.attrs.bg + : term->colors.bg); + for (size_t i = 0; i < 1 * 6; i++) - term->sixel.image.data[i] = bg; + term->sixel.image.data[i] = term->sixel.default_bg; count = 0; } @@ -1118,7 +1113,7 @@ resize_horizontally(struct terminal *term, int new_width) /* Width (and thus stride) change - need to allocate a new buffer */ uint32_t *new_data = xmalloc(new_width * alloc_height * sizeof(uint32_t)); - uint32_t bg = get_bg(term); + uint32_t bg = term->sixel.default_bg; /* Copy old rows, and initialize new columns to background color */ for (int r = 0; r < height; r++) { @@ -1167,7 +1162,7 @@ resize_vertically(struct terminal *term, int new_height) return false; } - uint32_t bg = get_bg(term); + uint32_t bg = term->sixel.default_bg; /* Initialize new rows to background color */ for (int r = old_height; r < new_height; r++) { @@ -1204,7 +1199,7 @@ resize(struct terminal *term, int new_width, int new_height) xassert(alloc_new_height - new_height < 6); uint32_t *new_data = NULL; - uint32_t bg = get_bg(term); + uint32_t bg = term->sixel.default_bg; if (new_width == old_width) { /* Width (and thus stride) is the same, so we can simply diff --git a/terminal.h b/terminal.h index df253434..26dcd847 100644 --- a/terminal.h +++ b/terminal.h @@ -576,6 +576,7 @@ struct terminal { unsigned param_idx; /* Parameters seen */ bool transparent_bg; + uint32_t default_bg; /* Application configurable */ unsigned palette_size; /* Number of colors in palette */