]> git.sesse.net Git - ccbs/blobdiff - bigscreen/ccbs_bigscreen.cpp
Optimization: If pitch == width, render directly into the framebuffer.
[ccbs] / bigscreen / ccbs_bigscreen.cpp
index e9a30110c5eb449ed67ca0a067f2d6dac4e4eb68..2694e3711850820c72904153a5ef762e298a3252 100644 (file)
@@ -144,14 +144,20 @@ void main_loop(pqxx::connection &conn)
        }
 
        if (mainscreen && mainscreen->check_invalidated()) {
-               mainscreen->draw(framebuf, SCREEN_WIDTH, SCREEN_HEIGHT);
-               SDL_LockSurface(screen);
-               for (unsigned y = 0; y < SCREEN_HEIGHT; ++y) {
-                       unsigned char *sptr = framebuf + y * SCREEN_WIDTH * 4;
-                       unsigned char *dptr = (unsigned char *)screen->pixels + y * screen->pitch;
-                       memcpy(dptr, sptr, SCREEN_WIDTH * 4);
+               if (screen->pitch == SCREEN_WIDTH) {
+                       SDL_LockSurface(screen);
+                       mainscreen->draw((unsigned char *)screen->pixels, SCREEN_WIDTH, SCREEN_HEIGHT);
+                       SDL_UnlockSurface(screen);
+               } else {
+                       mainscreen->draw(framebuf, SCREEN_WIDTH, SCREEN_HEIGHT);
+                       SDL_LockSurface(screen);
+                       for (unsigned y = 0; y < SCREEN_HEIGHT; ++y) {
+                               unsigned char *sptr = framebuf + y * SCREEN_WIDTH * 4;
+                               unsigned char *dptr = (unsigned char *)screen->pixels + y * screen->pitch;
+                               memcpy(dptr, sptr, SCREEN_WIDTH * 4);
+                       }
+                       SDL_UnlockSurface(screen);
                }
-               SDL_UnlockSurface(screen);
                SDL_Flip(screen);
                conn.await_notification(0, 10000);
        } else {