mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: "open list:BAREBOX" <barebox@lists.infradead.org>
Subject: [PATCH 3/5] gui: fix alpha blend
Date: Wed, 25 Sep 2024 16:34:51 +0200	[thread overview]
Message-ID: <20240925-graphics-v1-3-f1fe5d2cceec@pengutronix.de> (raw)
In-Reply-To: <20240925-graphics-v1-0-f1fe5d2cceec@pengutronix.de>

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




  parent reply	other threads:[~2024-09-25 14:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-25 14:34 [PATCH 0/5] graphics updates Sascha Hauer
2024-09-25 14:34 ` [PATCH 1/5] graphic_utils: Clip to screen boundaries Sascha Hauer
2024-09-26  5:26   ` Ahmad Fatoum
2024-09-25 14:34 ` [PATCH 2/5] commands: splash: honour line_length Sascha Hauer
2024-09-26  5:31   ` Ahmad Fatoum
2024-09-26  6:48     ` Sascha Hauer
2024-09-25 14:34 ` Sascha Hauer [this message]
2024-09-26  5:33   ` [PATCH 3/5] gui: fix alpha blend Ahmad Fatoum
2024-09-25 14:34 ` [PATCH 4/5] fbconsole: make background pixels transparent Sascha Hauer
2024-09-26  5:38   ` Ahmad Fatoum
2024-09-26  7:02     ` Sascha Hauer
2024-09-25 14:34 ` [PATCH 5/5] fbconsole: actually store rows/cols Sascha Hauer
2024-09-26  5:39   ` Ahmad Fatoum
2024-09-27 10:38 ` [PATCH 0/5] graphics updates Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240925-graphics-v1-3-f1fe5d2cceec@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox