From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH] commands: splash: optimize background fill
Date: Sun, 3 May 2026 10:32:54 +0200 [thread overview]
Message-ID: <20260503083304.2765131-1-a.fatoum@barebox.org> (raw)
The background color is specified to the command as 0xttrrggbb,
which is not necessarily the native color format of the framebuffer and
thus gu_memset_pixel() will do color conversion.
Instead of redoing the color conversion for every line, let's just
do it once in advance and then keep reusing it.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
commands/splash.c | 9 +++++----
include/gui/graphic_utils.h | 2 ++
lib/gui/graphic_utils.c | 17 ++++++++++-------
3 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/commands/splash.c b/commands/splash.c
index 74754392e264..dffe29f92328 100644
--- a/commands/splash.c
+++ b/commands/splash.c
@@ -63,10 +63,11 @@ static int do_splash(int argc, char *argv[])
buf = gui_screen_render_buffer(sc);
if (do_bg) {
- int y;
- for (y = 0; y < sc->s.height; y++) {
- gu_memset_pixel(sc->info, buf + sc->info->line_length * y,
- bg_color, sc->s.width);
+ u32 bg_color_native = gu_hex_to_pixel(sc->info, bg_color);
+
+ for (int y = 0; y < sc->s.height; y++) {
+ gu_memset_pixel_native(sc->info, buf + sc->info->line_length * y,
+ bg_color_native, sc->s.width);
}
}
diff --git a/include/gui/graphic_utils.h b/include/gui/graphic_utils.h
index 279fdf91d33c..2128222628d4 100644
--- a/include/gui/graphic_utils.h
+++ b/include/gui/graphic_utils.h
@@ -19,6 +19,8 @@ void gu_set_pixel(struct fb_info *info, void *adr, u32 px);
void gu_set_rgb_pixel(struct fb_info *info, void *adr, u8 r, u8 g, u8 b);
void gu_set_rgba_pixel(struct fb_info *info, void *adr, u8 r, u8 g, u8 b, u8 a);
void gu_memset_pixel(struct fb_info *info, void* buf, u32 color, size_t size);
+void gu_memset_pixel_native(struct fb_info *info, void* buf, u32 color_native,
+ size_t size);
struct screen *fb_create_screen(struct fb_info *info);
struct screen *fb_open(const char *fbdev);
void fb_close(struct screen *sc);
diff --git a/lib/gui/graphic_utils.c b/lib/gui/graphic_utils.c
index d9f90f3d2ea0..087eba382b93 100644
--- a/lib/gui/graphic_utils.c
+++ b/lib/gui/graphic_utils.c
@@ -78,27 +78,30 @@ static void memsetl(void *s, u32 c, size_t n)
*tmp++ = c;
}
-void gu_memset_pixel(struct fb_info *info, void* buf, u32 color, size_t size)
+void gu_memset_pixel_native(struct fb_info *info, void* buf, u32 color_native,
+ size_t size)
{
- u32 px;
u8 *screen = buf;
- px = gu_hex_to_pixel(info, color);
-
switch (info->bits_per_pixel) {
case 8:
- memset(screen, (uint8_t)px, size);
+ memset(screen, (uint8_t)color_native, size);
break;
case 16:
- memsetw(screen, (uint16_t)px, size);
+ memsetw(screen, (uint16_t)color_native, size);
break;
case 32:
case 24:
- memsetl(screen, px, size);
+ memsetl(screen, color_native, size);
break;
}
}
+void gu_memset_pixel(struct fb_info *info, void* buf, u32 color, size_t size)
+{
+ gu_memset_pixel_native(info, buf, gu_hex_to_pixel(info, color), size);
+}
+
static void get_rgb_pixel(struct fb_info *info, void *adr, u8 *r ,u8 *g, u8 *b)
{
u32 px;
--
2.47.3
next reply other threads:[~2026-05-03 8:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-03 8:32 Ahmad Fatoum [this message]
2026-05-07 10:38 ` 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=20260503083304.2765131-1-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--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