nanogui: Two SDL-on-MW fbcon fixes
Subject:
Two SDL-on-MW fbcon fixes
From:
Jesper Skov ####@####.####
Date:
13 May 2002 11:15:46 -0000
Message-Id: <1021287963.5686.37.camel@thinktwice.zoftcorp.dk>
Jesper Skov ####@####.####
* src/video/fbcon/SDL_fbvideo.c (FB_VideoInit): Don't call
FB_VideoQuit - caller does that.
Bart Veer ####@####.####
* src/src/video/fbcon/SDL_fbvideo.c (FB_SetVideoMode):
When running in a window (FORCEGRAREA) and the requested surface
was wider than the screen, the code would allocate space as per
the screen width but manipulate it as per the requested width.
This led to memory corruption.
Index: SDL_fbvideo.c
===================================================================
RCS file: /local/cvsfiles/ecc/ecc/services/gfx/sdl/current/src/src/video/fbcon/SDL_fbvideo.c,v
retrieving revision 1.1.1.2
diff -u -p -u -5 -p -r1.1.1.2 SDL_fbvideo.c
--- SDL_fbvideo.c 20 Mar 2002 14:48:30 -0000 1.1.1.2
+++ SDL_fbvideo.c 13 May 2002 11:00:22 -0000
@@ -197,11 +197,10 @@ static int FB_VideoInit(_THIS, SDL_Pixel
/* Create the hardware surface lock mutex */
hw_lock = SDL_CreateMutex();
if ( hw_lock == NULL ) {
SDL_SetError("Unable to create lock mutex");
- FB_VideoQuit(this);
return(-1);
}
#if !FORCEGRAREA
hasfb = (GrOpenClientFramebuffer() != NULL);
@@ -509,11 +508,27 @@ if (bpp != BPP) fprintf(stderr, "SetVide
/* FIXME Restore the original palette */
//FB_RestorePalette(this);
//cache_vinfo = vinfo;
BPP = bpp; // may not work FIXME
- PITCH = XRES*(BPP/8);
+ /* bartv: the original code was just */
+ /* PITCH = XRES*(BPP/8); */
+ /* This is not right for windowed operation (FORCEGRAREA) */
+ /* where it is legal to have a window larger than the */
+ /* screen size, and let microwindows do clipping. If direct */
+ /* framebuffer access is used then the pitch must be based */
+ /* on the screen size, and any attempt to allocate a */
+ /* surface larger than the screen size must be rejected. */
+#if FORCEGRAREA
+ PITCH = width * (BPP / 8);
+#else
+ if ((width > XRES) || (height > YRES)) {
+ return NULL;
+ }
+ PITCH = XRES*(BPP/8);
+#endif
+
GrGetScreenInfo(&sinfo);
Rmask = sinfo.rmask;
Gmask = sinfo.gmask;
Bmask = sinfo.bmask;