diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2021-03-06 21:07:39 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2021-03-11 16:32:57 +0000 |
| commit | ab70b4f16a59aedd170b6bdc01dca971c6358df1 (patch) | |
| tree | e7a890493f3270d54dcb2cf2d8b13072dff41f92 /sixel.c | |
| parent | sixel: get rid of an ‘imul’ in sixel_add() (diff) | |
sixel: add: use de-reference the term struct for each access to the backing image
Diffstat (limited to 'sixel.c')
| -rw-r--r-- | sixel.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -919,14 +919,17 @@ sixel_add(struct terminal *term, uint32_t color, uint8_t sixel) { //LOG_DBG("adding sixel %02hhx using color 0x%06x", sixel, color); - if (term->sixel.pos.col >= term->sixel.image.width || - term->sixel.pos.row >= term->sixel.image.height) + int height = term->sixel.image.height; + int width = term->sixel.image.width; + + if (term->sixel.pos.col >= width || + term->sixel.pos.row >= height) { - int width = max( + width = max( term->sixel.image.width, max(term->sixel.max_col, term->sixel.pos.col + 1)); - int height = max( + height = max( term->sixel.image.height, term->sixel.pos.row + 6); if (!resize(term, width, height)) @@ -934,11 +937,11 @@ sixel_add(struct terminal *term, uint32_t color, uint8_t sixel) } size_t ofs = term->sixel.row_byte_ofs + term->sixel.pos.col; + uint32_t *data = term->sixel.image.data; - for (int i = 0; i < 6; i++, sixel >>= 1) { + for (int i = 0; i < 6; i++, sixel >>= 1, ofs += width) { if (sixel & 1) - term->sixel.image.data[ofs] = color; - ofs += term->sixel.image.width; + data[ofs] = color; } xassert(sixel == 0); |
