From fcc2e62a7d9a38ab5818815e1f7c52267653f096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Thu, 15 Jul 2021 18:23:49 +0200 Subject: [PATCH] render: track alpha directly, rather whether to use it or not --- render.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/render.c b/render.c index c50988fd..7dcad297 100644 --- a/render.c +++ b/render.c @@ -458,7 +458,7 @@ render_cell(struct terminal *term, pixman_image_t *pix, uint32_t _fg = 0; uint32_t _bg = 0; - bool apply_alpha = false; + uint16_t alpha = 0xffff; if (is_selected && term->colors.use_custom_selection) { _fg = term->colors.selection_fg; @@ -472,14 +472,14 @@ render_cell(struct terminal *term, pixman_image_t *pix, uint32_t swap = _fg; _fg = _bg; _bg = swap; - } else - apply_alpha = !cell->attrs.have_bg; + } else if (!cell->attrs.have_bg) + alpha = term->colors.alpha; } if (unlikely(is_selected && _fg == _bg)) { /* Invert bg when selected/highlighted text has same fg/bg */ _bg = ~_bg; - apply_alpha = false; + alpha = 0xffff; } if (cell->attrs.dim) @@ -491,8 +491,7 @@ render_cell(struct terminal *term, pixman_image_t *pix, _fg = color_dim(_fg); pixman_color_t fg = color_hex_to_pixman(_fg); - pixman_color_t bg = color_hex_to_pixman_with_alpha( - _bg, apply_alpha ? term->colors.alpha : 0xffff); + pixman_color_t bg = color_hex_to_pixman_with_alpha(_bg, alpha); if (term->is_searching && !is_selected) { color_dim_for_search(&fg);