commands: splash: optimize background fill
PATCH 1/1 commands: splash: optimize background fill
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.
--- commands/splash.c | 9 +++++---- include/gui/graphic_utils.h | 2 ++ lib/gui/graphic_utils.c | 17 ++++++++++------- 3 files changed, 17 insertions(+), 11 deletions(-)
commands/splash.c +5 -4
@@ -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); } }
include/gui/graphic_utils.h +2 -0
@@ -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);
lib/gui/graphic_utils.c +10 -7
@@ -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;
Signature · 1 line
2.47.3
Sascha Hauer
AppliedQuoted 8 lines · 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.
[...]
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,
Signature · 1 line
Sascha Hauer <[email protected]>