From fe5d8dd4bcbab4fed744782495a9fecdb5a5b1a7 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 18 Feb 2012 02:12:27 +0100 Subject: [PATCH] Optimization: If pitch == width, render directly into the framebuffer. --- bigscreen/ccbs_bigscreen.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/bigscreen/ccbs_bigscreen.cpp b/bigscreen/ccbs_bigscreen.cpp index e9a3011..2694e37 100644 --- a/bigscreen/ccbs_bigscreen.cpp +++ b/bigscreen/ccbs_bigscreen.cpp @@ -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 { -- 2.39.2