X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=bigscreen%2Frotatescreen.cpp;h=64e7269f6a09ddd27b71a80074998b0c5c228f29;hb=b6fa823a82184618370341eb414b50f1ac459a2f;hp=c2285ae787d3beb2dc85d480ed15df37e931eb7c;hpb=0ee900117e1e95256f4518703e54bdf2a9a99b91;p=ccbs diff --git a/bigscreen/rotatescreen.cpp b/bigscreen/rotatescreen.cpp index c2285ae..64e7269 100644 --- a/bigscreen/rotatescreen.cpp +++ b/bigscreen/rotatescreen.cpp @@ -11,7 +11,7 @@ RotateScreen::RotateScreen() RotateScreen::~RotateScreen() { - delete fadefrom_buf; + delete[] fadefrom_buf; } bool RotateScreen::check_invalidated() @@ -71,21 +71,25 @@ void RotateScreen::draw(unsigned char *buf, unsigned width, unsigned height) if (elapsed_fade > 5.5 || (!fade_to_new_info && elapsed_fade > 0.5)) { in_fade = false; - // ugly hack here? :-) - subscreens[current_screen].screen->draw(subscreens[current_screen].buf, width, height); + // set G&B to be = R + unsigned char *ptr = subscreens[current_screen].buf; + for (unsigned i = 0; i < width * height; ++i) { + ptr[1] = ptr[2] = ptr[3] = ptr[0]; + ptr += 4; + } 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 +99,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 +108,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; }