[vte/wip/sixels: 47/82] sixel: Output premultiplied alpha
- From: Hans Petter Jansson <hansp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/wip/sixels: 47/82] sixel: Output premultiplied alpha
- Date: Fri, 26 Jun 2020 00:47:03 +0000 (UTC)
commit 494613be0df99acd663bf719286af814123ff981
Author: Hans Petter Jansson <hpj cl no>
Date: Fri Jun 12 12:27:04 2020 +0200
sixel: Output premultiplied alpha
src/sixel.cc | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
---
diff --git a/src/sixel.cc b/src/sixel.cc
index 94151398..035c8752 100644
--- a/src/sixel.cc
+++ b/src/sixel.cc
@@ -328,11 +328,26 @@ sixel_parser_finalize(sixel_state_t *st, unsigned char *pixels)
dst = pixels;
for (y = 0; y < st->image.height; ++y) {
for (x = 0; x < st->image.width; ++x) {
- color = st->image.palette[*src++];
- *dst++ = color >> 16 & 0xff; /* b */
- *dst++ = color >> 8 & 0xff; /* g */
- *dst++ = color >> 0 & 0xff; /* r */
- *dst++ = 0xff; /* a */
+ sixel_color_no_t pen = *src++;
+
+ /* FIXME-hpj: We may want to make this branch-free, among other
+ * performance improvements. */
+
+ if (pen == 0) {
+ /* Cairo wants premultiplied alpha: Transparent
+ * areas must be all zeroes. */
+
+ *dst++ = 0;
+ *dst++ = 0;
+ *dst++ = 0;
+ *dst++ = 0;
+ } else {
+ color = st->image.palette[pen];
+ *dst++ = color >> 16 & 0xff; /* b */
+ *dst++ = color >> 8 & 0xff; /* g */
+ *dst++ = color >> 0 & 0xff; /* r */
+ *dst++ = 0xff; /* a */
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]