Optionally don't clear the fbcon framebuffer on shutdown. SDL-1.2
authorRyan C. Gordon <icculus@icculus.org>
Sun, 21 Aug 2011 09:26:56 -0400
branchSDL-1.2
changeset 5617 36cbc5292592
parent 5616 cf80941225f5
child 5618 a427a0e16ca4
Optionally don't clear the fbcon framebuffer on shutdown. The new behavior is triggered by setting the environment variable SDL_FBCON_DONT_CLEAR. This is useful in certain circumstances (specifically: a game launcher on an embedded device can leave a "now loading!" screen on the framebuffer while another process is starting up). Fixes Bugzilla #1251. Thanks to Paul Cercueil for the patch!
src/video/fbcon/SDL_fbvideo.c
--- a/src/video/fbcon/SDL_fbvideo.c	Sun Aug 21 02:52:15 2011 -0400
+++ b/src/video/fbcon/SDL_fbvideo.c	Sun Aug 21 09:26:56 2011 -0400
@@ -1910,7 +1910,16 @@
 
 	if ( this->screen ) {
 		/* Clear screen and tell SDL not to free the pixels */
-		if ( this->screen->pixels && FB_InGraphicsMode(this) ) {
+
+		const char *dontClearPixels = SDL_getenv("SDL_FBCON_DONT_CLEAR");
+
+		/* If the framebuffer is not to be cleared, make sure that we won't
+		 * display the previous frame when disabling double buffering. */
+		if ( dontClearPixels && flip_page == 0 ) {
+			SDL_memcpy(flip_address[0], flip_address[1], this->screen->pitch * this->screen->h);
+		}
+
+		if ( !dontClearPixels && this->screen->pixels && FB_InGraphicsMode(this) ) {
 #if defined(__powerpc__) || defined(__ia64__)	/* SIGBUS when using SDL_memset() ?? */
 			Uint8 *rowp = (Uint8 *)this->screen->pixels;
 			int left = this->screen->pitch*this->screen->h;