shithub: choc

Download patch

ref: 74c2dc333a383f27ebddf479e3b666a9068d6d36
parent: ca81122db362eb01660598a4f3e980ed5274220d
author: Simon Howard <fraggle@gmail.com>
date: Fri Nov 26 13:56:45 EST 2010

In non-palettized boxed screen modes, don't update the border areas of
the screen. This is more CPU and memory efficient, and also fixes the
"flashing border" bug when palette flashes occur.

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 2170

--- a/src/i_video.c
+++ b/src/i_video.c
@@ -926,7 +926,14 @@
 
     if (screenbuffer != screen)
     {
-        SDL_BlitSurface(screenbuffer, NULL, screen, NULL);
+        SDL_Rect dst_rect;
+
+        // Center the buffer within the full screen space.
+
+        dst_rect.x = (screen->w - screenbuffer->w) / 2;
+        dst_rect.y = (screen->h - screenbuffer->h) / 2;
+
+        SDL_BlitSurface(screenbuffer, NULL, screen, &dst_rect);
     }
 
     SDL_Flip(screen);
@@ -1625,17 +1632,11 @@
                 w, h, screen_bpp, SDL_GetError());
     }
 
-    if (screen->format->BitsPerPixel == 8)
-    {
-        screenbuffer = screen;
-    }
-    else
-    {
-        screenbuffer = SDL_CreateRGBSurface(SDL_SWSURFACE,
-                                            screen->w, screen->h, 8,
-                                            0, 0, 0, 0);
-    }
+    // Blank out the full screen area in case there is any junk in
+    // the borders that won't otherwise be overwritten.
 
+    SDL_FillRect(screen, NULL, 0);
+
     // If mode was not set, it must be set now that we know the
     // screen size.
 
@@ -1657,6 +1658,22 @@
         }
     }
 
+    // Create the screenbuffer surface; if we have a real 8-bit palettized
+    // screen, then we can use the screen as the screenbuffer.
+
+    if (screen->format->BitsPerPixel == 8)
+    {
+        screenbuffer = screen;
+    }
+    else
+    {
+        screenbuffer = SDL_CreateRGBSurface(SDL_SWSURFACE,
+                                            mode->width, mode->height, 8,
+                                            0, 0, 0, 0);
+
+        SDL_FillRect(screenbuffer, NULL, 0);
+    }
+
     // Save screen mode.
 
     screen_mode = mode;
@@ -1781,12 +1798,6 @@
     doompal = W_CacheLumpName(DEH_String("PLAYPAL"), PU_CACHE);
     I_SetPalette(doompal);
     SDL_SetColors(screenbuffer, palette, 0, 256);
-
-    if (screen != screenbuffer)
-    {
-        SDL_BlitSurface(screenbuffer, NULL, screen, NULL);
-        SDL_Flip(screen);
-    }
 
     CreateCursors();