From 1046e65f7cca2b592fbb7e8f0d1392fb742a67b1 Mon Sep 17 00:00:00 2001 From: Vasyl Vavrychuk Date: Mon, 25 Apr 2022 10:59:48 +0300 Subject: [PATCH 09/17] psplash.c: Make psplash_draw_{msg,progress} independent of FB drm-backend backport from: https://patchwork.yoctoproject.org/project/yocto/cover/20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com/ Signed-off-by: Vasyl Vavrychuk --- psplash.c | 64 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/psplash.c b/psplash.c index 1a5e543..c234d46 100644 --- a/psplash.c +++ b/psplash.c @@ -21,11 +21,11 @@ #endif #include FONT_HEADER -#define SPLIT_LINE_POS(fb) \ - ( (fb)->canvas.height \ - - (( PSPLASH_IMG_SPLIT_DENOMINATOR \ - - PSPLASH_IMG_SPLIT_NUMERATOR) \ - * (fb)->canvas.height / PSPLASH_IMG_SPLIT_DENOMINATOR) \ +#define SPLIT_LINE_POS(canvas) \ + ( (canvas)->height \ + - (( PSPLASH_IMG_SPLIT_DENOMINATOR \ + - PSPLASH_IMG_SPLIT_NUMERATOR) \ + * (canvas)->height / PSPLASH_IMG_SPLIT_DENOMINATOR) \ ) void @@ -37,7 +37,7 @@ psplash_exit (int UNUSED(signum)) } void -psplash_draw_msg (PSplashFB *fb, const char *msg) +psplash_draw_msg(PSplashCanvas *canvas, const char *msg) { int w, h; @@ -47,16 +47,16 @@ psplash_draw_msg (PSplashFB *fb, const char *msg) /* Clear */ - psplash_draw_rect(&fb->canvas, + psplash_draw_rect(canvas, 0, - SPLIT_LINE_POS(fb) - h, - fb->canvas.width, + SPLIT_LINE_POS(canvas) - h, + canvas->width, h, PSPLASH_BACKGROUND_COLOR); - psplash_draw_text(&fb->canvas, - (fb->canvas.width-w)/2, - SPLIT_LINE_POS(fb) - h, + psplash_draw_text(canvas, + (canvas->width-w)/2, + SPLIT_LINE_POS(canvas) - h, PSPLASH_TEXT_COLOR, &FONT_DEF, msg); @@ -64,32 +64,32 @@ psplash_draw_msg (PSplashFB *fb, const char *msg) #ifdef PSPLASH_SHOW_PROGRESS_BAR void -psplash_draw_progress (PSplashFB *fb, int value) +psplash_draw_progress(PSplashCanvas *canvas, int value) { int x, y, width, height, barwidth; /* 4 pix border */ - x = ((fb->canvas.width - BAR_IMG_WIDTH)/2) + 4 ; - y = SPLIT_LINE_POS(fb) + 4; + x = ((canvas->width - BAR_IMG_WIDTH)/2) + 4 ; + y = SPLIT_LINE_POS(canvas) + 4; width = BAR_IMG_WIDTH - 8; height = BAR_IMG_HEIGHT - 8; if (value > 0) { barwidth = (CLAMP(value,0,100) * width) / 100; - psplash_draw_rect(&fb->canvas, x + barwidth, y, + psplash_draw_rect(canvas, x + barwidth, y, width - barwidth, height, PSPLASH_BAR_BACKGROUND_COLOR); - psplash_draw_rect(&fb->canvas, x, y, barwidth, + psplash_draw_rect(canvas, x, y, barwidth, height, PSPLASH_BAR_COLOR); } else { barwidth = (CLAMP(-value,0,100) * width) / 100; - psplash_draw_rect(&fb->canvas, x, y, + psplash_draw_rect(canvas, x, y, width - barwidth, height, PSPLASH_BAR_BACKGROUND_COLOR); - psplash_draw_rect(&fb->canvas, x + width - barwidth, + psplash_draw_rect(canvas, x + width - barwidth, y, barwidth, height, PSPLASH_BAR_COLOR); } @@ -116,7 +116,7 @@ parse_command (PSplashFB *fb, char *string) char *arg = strtok(NULL, "\0"); if (arg) - psplash_draw_msg (fb, arg); + psplash_draw_msg(&fb->canvas, arg); } #ifdef PSPLASH_SHOW_PROGRESS_BAR else if (!strcmp(command,"PROGRESS")) @@ -124,7 +124,7 @@ parse_command (PSplashFB *fb, char *string) char *arg = strtok(NULL, "\0"); if (arg) - psplash_draw_progress (fb, atoi(arg)); + psplash_draw_progress(&fb->canvas, atoi(arg)); } #endif else if (!strcmp(command,"QUIT")) @@ -226,6 +226,7 @@ main (int argc, char** argv) char *rundir; int pipe_fd, i = 0, angle = 0, fbdev_id = 0, ret = 0; PSplashFB *fb; + PSplashCanvas *canvas; bool disable_console_switch = FALSE; signal(SIGHUP, psplash_exit); @@ -295,22 +296,23 @@ main (int argc, char** argv) ret = -1; goto fb_fail; } + canvas = &fb->canvas; #ifdef HAVE_SYSTEMD sd_notify(0, "READY=1"); #endif /* Clear the background with #ecece1 */ - psplash_draw_rect(&fb->canvas, 0, 0, fb->canvas.width, fb->canvas.height, + psplash_draw_rect(canvas, 0, 0, canvas->width, canvas->height, PSPLASH_BACKGROUND_COLOR); /* Draw the Poky logo */ - psplash_draw_image(&fb->canvas, - (fb->canvas.width - POKY_IMG_WIDTH)/2, + psplash_draw_image(canvas, + (canvas->width - POKY_IMG_WIDTH)/2, #if PSPLASH_IMG_FULLSCREEN - (fb->canvas.height - POKY_IMG_HEIGHT)/2, + (canvas->height - POKY_IMG_HEIGHT)/2, #else - (fb->canvas.height * PSPLASH_IMG_SPLIT_NUMERATOR + (canvas->height * PSPLASH_IMG_SPLIT_NUMERATOR / PSPLASH_IMG_SPLIT_DENOMINATOR - POKY_IMG_HEIGHT)/2, #endif POKY_IMG_WIDTH, @@ -321,20 +323,20 @@ main (int argc, char** argv) #ifdef PSPLASH_SHOW_PROGRESS_BAR /* Draw progress bar border */ - psplash_draw_image(&fb->canvas, - (fb->canvas.width - BAR_IMG_WIDTH)/2, - SPLIT_LINE_POS(fb), + psplash_draw_image(canvas, + (canvas->width - BAR_IMG_WIDTH)/2, + SPLIT_LINE_POS(canvas), BAR_IMG_WIDTH, BAR_IMG_HEIGHT, BAR_IMG_BYTES_PER_PIXEL, BAR_IMG_ROWSTRIDE, BAR_IMG_RLE_PIXEL_DATA); - psplash_draw_progress (fb, 0); + psplash_draw_progress(canvas, 0); #endif #ifdef PSPLASH_STARTUP_MSG - psplash_draw_msg (fb, PSPLASH_STARTUP_MSG); + psplash_draw_msg(canvas, PSPLASH_STARTUP_MSG); #endif /* Scene set so let's flip the buffers. */ -- 2.25.1