aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-03-06 18:52:01 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-03-11 16:32:55 +0000
commitf143efb99991df61b0c2edda3aef078f429ad1d4 (patch)
treef103d56567cb801620ac246c1b2ecc636df5c83c
parentsixel: pre-calculate color before calling sixel_add() (diff)
sixel: calculate alpha when updating the palette
Calculate color, with alpha, when updating the palette instead of every time we *use* the palette.
-rw-r--r--sixel.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/sixel.c b/sixel.c
index 6fd74a86..f51d7aa1 100644
--- a/sixel.c
+++ b/sixel.c
@@ -980,11 +980,7 @@ decsixel(struct terminal *term, uint8_t c)
case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v':
case 'w': case 'x': case 'y': case 'z': case '{': case '|': case '}':
case '~':
- sixel_add(
- term,
- color_with_alpha(
- term, term->sixel.palette[term->sixel.color_idx]),
- c - 63);
+ sixel_add(term, term->sixel.palette[term->sixel.color_idx], c - 63);
break;
case ' ':
@@ -1064,8 +1060,7 @@ decgri(struct terminal *term, uint8_t c)
case 'w': case 'x': case 'y': case 'z': case '{': case '|': case '}':
case '~': {
//LOG_DBG("repeating '%c' %u times", c, term->sixel.param);
- uint32_t color = color_with_alpha(
- term, term->sixel.palette[term->sixel.color_idx]);
+ uint32_t color = term->sixel.palette[term->sixel.color_idx];
for (unsigned i = 0; i < term->sixel.param; i++)
sixel_add(term, color, c - 63);
@@ -1131,7 +1126,8 @@ decgci(struct terminal *term, uint8_t c)
LOG_DBG("setting palette #%d = HLS %hhu/%hhu/%hhu (0x%06x)",
term->sixel.color_idx, hue, lum, sat, rgb);
- term->sixel.palette[term->sixel.color_idx] = rgb;
+ term->sixel.palette[term->sixel.color_idx] =
+ color_with_alpha(term, rgb);
break;
}
@@ -1143,7 +1139,8 @@ decgci(struct terminal *term, uint8_t c)
LOG_DBG("setting palette #%d = RGB %hhu/%hhu/%hhu",
term->sixel.color_idx, r, g, b);
- term->sixel.palette[term->sixel.color_idx] = r << 16 | g << 8 | b;
+ term->sixel.palette[term->sixel.color_idx] =
+ color_with_alpha(term, r << 16 | g << 8 | b);
break;
}
}