render: track alpha directly, rather whether to use it or not

This commit is contained in:
Daniel Eklöf 2021-07-15 18:23:49 +02:00
parent 22651ed221
commit fcc2e62a7d
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -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);