From 1df0f375a8a29ea57505fd16adf707b619ad7ef4 Mon Sep 17 00:00:00 2001 From: Peter Korsgaard Date: Fri, 14 Oct 2011 10:13:49 +0200 Subject: [PATCH 1/2] fbsplash: limit progress bar flicker Progress bar updates flicker quite a bit on slow hw / high resolutions as the background is completely cleared before the new progress bar position is drawn on top. Improve it by first drawing the progress bar and then only fill the remaining rows with the background. function old new delta fb_drawprogressbar 492 516 +24 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 24/0) Total: 24 bytes Signed-off-by: Peter Korsgaard --- miscutils/fbsplash.c | 20 ++++++++++++-------- 1 files changed, 12 insertions(+), 8 deletions(-) diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c index 51ba472..937c6a4 100644 --- a/miscutils/fbsplash.c +++ b/miscutils/fbsplash.c @@ -213,7 +213,7 @@ static void fb_drawfullrectangle(int nx1pos, int ny1pos, int nx2pos, int ny2pos, */ static void fb_drawprogressbar(unsigned percent) { - int i, left_x, top_y, width, height; + int i, y, left_x, top_y, pos, width, height; // outer box left_x = G.nbar_posx; @@ -232,14 +232,13 @@ static void fb_drawprogressbar(unsigned percent) height -= 2; if ((height | width) < 0) return; - fb_drawfullrectangle( - left_x, top_y, - left_x + width, top_y + height, - G.nbar_colr, G.nbar_colg, G.nbar_colb); + pos = left_x; if (percent > 0) { // actual progress bar - width = width * percent / 100; + pos += width * percent / 100; + + y = top_y; i = height; if (height == 0) height++; // divide by 0 is bad @@ -248,12 +247,17 @@ static void fb_drawprogressbar(unsigned percent) // top line will have gray lvl 200, bottom one 100 unsigned gray_level = 100 + i*100/height; fb_drawfullrectangle( - left_x, top_y, left_x + width, top_y, + left_x, y, pos, y, gray_level, gray_level, gray_level); - top_y++; + y++; i--; } } + + fb_drawfullrectangle( + pos, top_y, + left_x + width, top_y + height, + G.nbar_colr, G.nbar_colg, G.nbar_colb); } -- 1.7.6.3