* [PATCH] commands: splash: optimize background fill
@ 2026-05-03 8:32 Ahmad Fatoum
2026-05-07 10:38 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2026-05-03 8:32 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] commands: splash: optimize background fill
2026-05-03 8:32 [PATCH] commands: splash: optimize background fill Ahmad Fatoum
@ 2026-05-07 10:38 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2026-05-07 10:38 UTC (permalink / raw)
To: barebox, Ahmad Fatoum
On Sun, 03 May 2026 10:32:54 +0200, Ahmad Fatoum wrote:
> 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.
>
> [...]
Applied, thanks!
[1/1] commands: splash: optimize background fill
https://git.pengutronix.de/cgit/barebox/commit/?id=2ebfe22faf64 (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-07 12:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-03 8:32 [PATCH] commands: splash: optimize background fill Ahmad Fatoum
2026-05-07 10:38 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox