]> git.sesse.net Git - ccbs/commitdiff
Speed up the fades a bit.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 18 Feb 2012 01:29:08 +0000 (02:29 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 18 Feb 2012 01:29:08 +0000 (02:29 +0100)
bigscreen/rotatescreen.cpp

index e7d2bd47793e4c92717becc224e875321c917c2b..a8c9d6f83723f653180b289101ea25e89b26c4ac 100644 (file)
@@ -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;
                                }