From: Steinar H. Gunderson Date: Sat, 18 Feb 2012 01:29:08 +0000 (+0100) Subject: Speed up the fades a bit. X-Git-Url: https://git.sesse.net/?p=ccbs;a=commitdiff_plain;h=be31a75be370526c5124b881da7603e2de346082 Speed up the fades a bit. --- diff --git a/bigscreen/rotatescreen.cpp b/bigscreen/rotatescreen.cpp index e7d2bd4..a8c9d6f 100644 --- a/bigscreen/rotatescreen.cpp +++ b/bigscreen/rotatescreen.cpp @@ -76,16 +76,16 @@ void RotateScreen::draw(unsigned char *buf, unsigned width, unsigned height) memcpy(buf, subscreens[current_screen].buf, width * height * 4); } else { - // find the fade factors - int fr, fg, fb, fa; + // find the fade f + int f; if (fade_to_new_info) { if (elapsed_fade < 0.5) { - fr = fg = fb = fa = unsigned(elapsed_fade/0.5 * 256.0); + f = unsigned(elapsed_fade/0.5 * 256.0); } else { - fr = fg = fb = fa = unsigned((elapsed_fade-0.5)/5.0 * 256.0); + f = unsigned((elapsed_fade-0.5)/5.0 * 256.0); } } else { - fr = fg = fb = fa = unsigned(elapsed_fade/0.5 * 256.0); + f = unsigned(elapsed_fade/0.5 * 256.0); } unsigned char *sptr1 = fadefrom_buf; @@ -95,8 +95,8 @@ void RotateScreen::draw(unsigned char *buf, unsigned width, unsigned height) if (fade_to_new_info && elapsed_fade >= 0.5) { // fade G&B to be = R for (unsigned i = 0; i < width * height; ++i) { - dptr[0] = sptr2[0] + (((int(sptr2[2]) - int(sptr2[0])) * fb) >> 8); - dptr[1] = sptr2[1] + (((int(sptr2[2]) - int(sptr2[1])) * fg) >> 8); + dptr[0] = sptr2[0] + (((int(sptr2[2]) - int(sptr2[0])) * f) >> 8); + dptr[1] = dptr[0]; dptr[2] = sptr2[2]; dptr[3] = sptr2[3]; @@ -104,10 +104,10 @@ void RotateScreen::draw(unsigned char *buf, unsigned width, unsigned height) } } else { for (unsigned i = 0; i < width * height; ++i) { - dptr[0] = sptr1[0] + (((int(sptr2[0]) - int(sptr1[0])) * fb) >> 8); - dptr[1] = sptr1[1] + (((int(sptr2[1]) - int(sptr1[1])) * fg) >> 8); - dptr[2] = sptr1[2] + (((int(sptr2[2]) - int(sptr1[2])) * fr) >> 8); - dptr[3] = sptr1[3] + (((int(sptr2[3]) - int(sptr1[3])) * fa) >> 8); + dptr[0] = sptr1[0] + (((int(sptr2[0]) - int(sptr1[0])) * f) >> 8); + dptr[1] = dptr[0]; + dptr[2] = dptr[0]; + dptr[3] = dptr[0]; sptr1 += 4, sptr2 += 4, dptr += 4; }