[PATCH 3/5] gui: fix alpha blend
Sascha Hauer
s.hauer at pengutronix.de
Wed Sep 25 07:34:51 PDT 2024
gu_set_rgba_pixel() can work in two modes. When the plane does have an
alpha channel then it just sets the RGBA values. When the plane doesn't
have an alpha channel then it does pseudo alpha blending of the previous
pixel value.
At least this was the intention. The function sets the alpha value
correctly only when it's not fully opaque. Fix this by always setting
the alpha channel when it exists.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
lib/gui/graphic_utils.c | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/lib/gui/graphic_utils.c b/lib/gui/graphic_utils.c
index 93ef1214f9..d9f90f3d2e 100644
--- a/lib/gui/graphic_utils.c
+++ b/lib/gui/graphic_utils.c
@@ -187,24 +187,22 @@ void gu_set_rgba_pixel(struct fb_info *info, void *adr, u8 r, u8 g, u8 b, u8 a)
if (!a)
return;
- if (a != 0xff) {
- if (info->transp.length) {
- px |= (a >> (8 - info->transp.length)) << info->transp.offset;
- } else {
- u8 sr = 0;
- u8 sg = 0;
- u8 sb = 0;
+ if (info->transp.length) {
+ px |= (a >> (8 - info->transp.length)) << info->transp.offset;
+ } else if (a != 0xff) {
+ u8 sr = 0;
+ u8 sg = 0;
+ u8 sb = 0;
- get_rgb_pixel(info, adr, &sr, &sg, &sb);
+ get_rgb_pixel(info, adr, &sr, &sg, &sb);
- r = alpha_mux(sr, r, a);
- g = alpha_mux(sg, g, a);
- b = alpha_mux(sb, b, a);
+ r = alpha_mux(sr, r, a);
+ g = alpha_mux(sg, g, a);
+ b = alpha_mux(sb, b, a);
- gu_set_rgb_pixel(info, adr, r, g, b);
+ gu_set_rgb_pixel(info, adr, r, g, b);
- return;
- }
+ return;
}
px |= (r >> (8 - info->red.length)) << info->red.offset |
--
2.39.5
More information about the barebox
mailing list