sixel: remove ‘max_col’

The image width *is* the maximum number of columns we’ve seen.
This commit is contained in:
Daniel Eklöf 2021-03-07 11:49:15 +01:00
parent 1c9c1aafc8
commit 4b0e9a6bee
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 3 additions and 13 deletions

15
sixel.c
View file

@ -39,7 +39,6 @@ sixel_init(struct terminal *term)
term->sixel.pos = (struct coord){0, 0};
term->sixel.row_byte_ofs = 0;
term->sixel.color_idx = 0;
term->sixel.max_col = 0;
term->sixel.param = 0;
term->sixel.param_idx = 0;
memset(term->sixel.params, 0, sizeof(term->sixel.params));
@ -830,7 +829,6 @@ sixel_unhook(struct terminal *term)
term->sixel.image.data = NULL;
term->sixel.image.width = 0;
term->sixel.image.height = 0;
term->sixel.max_col = 0;
term->sixel.pos = (struct coord){0, 0};
free(term->sixel.private_palette);
@ -923,12 +921,9 @@ sixel_add(struct terminal *term, uint32_t color, uint8_t sixel)
int width = term->sixel.image.width;
if (term->sixel.pos.col >= width) {
width = max(
term->sixel.image.width,
max(term->sixel.max_col, term->sixel.pos.col + 1));
if (!resize(term, width, term->sixel.image.height))
if (unlikely(term->sixel.pos.col >= width)) {
width = term->sixel.pos.col + 1;
if (unlikely(!resize(term, width, term->sixel.image.height)))
return;
}
@ -971,14 +966,10 @@ decsixel(struct terminal *term, uint8_t c)
break;
case '$':
if (term->sixel.pos.col > term->sixel.max_col)
term->sixel.max_col = term->sixel.pos.col;
term->sixel.pos.col = 0;
break;
case '-':
if (term->sixel.pos.col > term->sixel.max_col)
term->sixel.max_col = term->sixel.pos.col;
term->sixel.pos.row += 6;
term->sixel.pos.col = 0;
term->sixel.row_byte_ofs += term->sixel.image.width * 6;

View file

@ -523,7 +523,6 @@ struct terminal {
struct coord pos; /* Current sixel coordinate */
size_t row_byte_ofs; /* Byte position into image, for current row */
int color_idx; /* Current palette index */
int max_col; /* Largest column index we've seen (aka the image width) */
uint32_t *private_palette; /* Private palette, used when private mode 1070 is enabled */
uint32_t *shared_palette; /* Shared palette, used when private mode 1070 is disabled */
uint32_t *palette; /* Points to either private_palette or shared_palette */