changeset 2328:91e601d9df8b

re: bug#563. checking in some commented out trace code and a fix so that the in testalpha.c the background only flashes when alpha == 255. The problem that is being fixed is caused by clearing SDL_COPY_RLE_COLORKEY without setting SDL_COPY_RLE_DESIRED in SDL_UnRELSurface.
author Bob Pendleton <bob@pendleton.com>
date Fri, 14 Mar 2008 18:17:49 +0000
parents 7b53a8401195
children c1a390f6a819
files include/SDL_compat.h src/SDL_compat.c src/video/SDL_RLEaccel.c src/video/SDL_blit.c src/video/SDL_renderer_gl.c src/video/SDL_surface.c src/video/SDL_video.c src/video/x11/SDL_x11events.c test/testgl2.c
diffstat 9 files changed, 66 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/include/SDL_compat.h	Fri Mar 07 23:57:15 2008 +0000
+++ b/include/SDL_compat.h	Fri Mar 14 18:17:49 2008 +0000
@@ -209,43 +209,58 @@
 #define SDL_AllocSurface    SDL_CreateRGBSurface
 
 extern DECLSPEC const SDL_version *SDLCALL SDL_Linked_Version(void);
-extern DECLSPEC char *SDLCALL SDL_AudioDriverName(char *namebuf, int maxlen);
-extern DECLSPEC char *SDLCALL SDL_VideoDriverName(char *namebuf, int maxlen);
+extern DECLSPEC char *SDLCALL SDL_AudioDriverName(char *namebuf,
+                                                  int maxlen);
+extern DECLSPEC char *SDLCALL SDL_VideoDriverName(char *namebuf,
+                                                  int maxlen);
 extern DECLSPEC const SDL_VideoInfo *SDLCALL SDL_GetVideoInfo(void);
-extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width, int height, int bpp,
+extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width,
+                                            int height,
+                                            int bpp,
                                             Uint32 flags);
 extern DECLSPEC SDL_Rect **SDLCALL SDL_ListModes(SDL_PixelFormat * format,
                                                  Uint32 flags);
-extern DECLSPEC SDL_Surface *SDLCALL SDL_SetVideoMode(int width, int height,
-                                                      int bpp, Uint32 flags);
+extern DECLSPEC SDL_Surface *SDLCALL SDL_SetVideoMode(int width,
+                                                      int height,
+                                                      int bpp,
+                                                      Uint32 flags);
 extern DECLSPEC SDL_Surface *SDLCALL SDL_GetVideoSurface(void);
 extern DECLSPEC void SDLCALL SDL_UpdateRects(SDL_Surface * screen,
-                                             int numrects, SDL_Rect * rects);
-extern DECLSPEC void SDLCALL SDL_UpdateRect(SDL_Surface * screen, Sint32 x,
-                                            Sint32 y, Uint32 w, Uint32 h);
+                                             int numrects,
+                                             SDL_Rect * rects);
+extern DECLSPEC void SDLCALL SDL_UpdateRect(SDL_Surface * screen,
+                                            Sint32 x,
+                                            Sint32 y,
+                                            Uint32 w,
+                                            Uint32 h);
 extern DECLSPEC int SDLCALL SDL_Flip(SDL_Surface * screen);
-extern DECLSPEC int SDLCALL SDL_SetAlpha(SDL_Surface * surface, Uint32 flag,
+extern DECLSPEC int SDLCALL SDL_SetAlpha(SDL_Surface * surface,
+                                         Uint32 flag,
                                          Uint8 alpha);
 extern DECLSPEC SDL_Surface *SDLCALL SDL_DisplayFormat(SDL_Surface * surface);
-extern DECLSPEC SDL_Surface *SDLCALL SDL_DisplayFormatAlpha(SDL_Surface *
-                                                            surface);
+extern DECLSPEC SDL_Surface *SDLCALL SDL_DisplayFormatAlpha(SDL_Surface * surface);
 extern DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title,
                                                const char *icon);
 extern DECLSPEC void SDLCALL SDL_WM_GetCaption(const char **title,
                                                const char **icon);
-extern DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask);
+extern DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface * icon,
+                                            Uint8 * mask);
 extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow(void);
 extern DECLSPEC int SDLCALL SDL_WM_ToggleFullScreen(SDL_Surface * surface);
 extern DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput(SDL_GrabMode mode);
-extern DECLSPEC int SDLCALL SDL_SetPalette(SDL_Surface * surface, int flags,
+extern DECLSPEC int SDLCALL SDL_SetPalette(SDL_Surface * surface,
+                                           int flags,
                                            const SDL_Color * colors,
-                                           int firstcolor, int ncolors);
+                                           int firstcolor,
+                                           int ncolors);
 extern DECLSPEC int SDLCALL SDL_SetColors(SDL_Surface * surface,
                                           const SDL_Color * colors,
-                                          int firstcolor, int ncolors);
+                                          int firstcolor,
+                                          int ncolors);
 extern DECLSPEC int SDLCALL SDL_GetWMInfo(struct SDL_SysWMinfo *info);
 extern DECLSPEC Uint8 SDLCALL SDL_GetAppState(void);
-extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y);
+extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x,
+                                           Uint16 y);
 extern DECLSPEC SDL_Overlay *SDLCALL SDL_CreateYUVOverlay(int width,
                                                           int height,
                                                           Uint32 format,
@@ -257,8 +272,10 @@
                                                   SDL_Rect * dstrect);
 extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay * overlay);
 extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void);
-extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
-extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval);
+extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay,
+int interval);
+extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay,
+                                              int *interval);
 extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
 
 /* Ends C function definitions when using C++ */
--- a/src/SDL_compat.c	Fri Mar 07 23:57:15 2008 +0000
+++ b/src/SDL_compat.c	Fri Mar 14 18:17:49 2008 +0000
@@ -29,15 +29,14 @@
 #include "video/SDL_sysvideo.h"
 #include "video/SDL_pixels_c.h"
 
-
-static SDL_WindowID SDL_VideoWindow;
+static SDL_WindowID SDL_VideoWindow = 0;
 static SDL_RendererInfo SDL_VideoRendererInfo;
-static SDL_TextureID SDL_VideoTexture;
-static SDL_Surface *SDL_VideoSurface;
-static SDL_Surface *SDL_ShadowSurface;
-static SDL_Surface *SDL_PublicSurface;
-static SDL_GLContext *SDL_VideoContext;
-static char *wm_title;
+static SDL_TextureID SDL_VideoTexture = 0;
+static SDL_Surface *SDL_VideoSurface = NULL;
+static SDL_Surface *SDL_ShadowSurface = NULL;
+static SDL_Surface *SDL_PublicSurface = NULL;
+static SDL_GLContext *SDL_VideoContext = NULL;
+static char *wm_title = NULL;
 
 char *
 SDL_AudioDriverName(char *namebuf, int maxlen)
@@ -391,7 +390,7 @@
         SDL_VideoSurface = NULL;
     }
     if (SDL_VideoContext) {
-        SDL_GL_MakeCurrent(0, NULL);
+        /* SDL_GL_MakeCurrent(0, NULL); *//* Doesn't do anything */
         SDL_GL_DeleteContext(SDL_VideoContext);
         SDL_VideoContext = NULL;
     }
--- a/src/video/SDL_RLEaccel.c	Fri Mar 07 23:57:15 2008 +0000
+++ b/src/video/SDL_RLEaccel.c	Fri Mar 14 18:17:49 2008 +0000
@@ -1973,6 +1973,7 @@
         }
         surface->map->info.flags &=
             (SDL_COPY_RLE_COLORKEY | SDL_COPY_RLE_ALPHAKEY);
+        surface->map->info.flags |= SDL_COPY_RLE_DESIRED;
 
         if (surface->map->data) {
             SDL_free(surface->map->data);
--- a/src/video/SDL_blit.c	Fri Mar 07 23:57:15 2008 +0000
+++ b/src/video/SDL_blit.c	Fri Mar 14 18:17:49 2008 +0000
@@ -260,7 +260,8 @@
                                        surface->format->Amask);
         Uint32 dst_format =
             SDL_MasksToPixelFormatEnum(dst->format->BitsPerPixel,
-                                       dst->format->Rmask, dst->format->Gmask,
+                                       dst->format->Rmask, 
+                                       dst->format->Gmask,
                                        dst->format->Bmask,
                                        dst->format->Amask);
 
--- a/src/video/SDL_renderer_gl.c	Fri Mar 07 23:57:15 2008 +0000
+++ b/src/video/SDL_renderer_gl.c	Fri Mar 14 18:17:49 2008 +0000
@@ -947,7 +947,7 @@
 
     if (data) {
         if (data->context) {
-            SDL_GL_MakeCurrent(0, NULL);
+            /* SDL_GL_MakeCurrent(0, NULL); *//* doesn't do anything */
             SDL_GL_DeleteContext(data->context);
         }
         SDL_free(data);
--- a/src/video/SDL_surface.c	Fri Mar 07 23:57:15 2008 +0000
+++ b/src/video/SDL_surface.c	Fri Mar 14 18:17:49 2008 +0000
@@ -542,6 +542,11 @@
         if (SDL_MapSurface(src, dst) < 0) {
             return (-1);
         }
+        /* just here for debugging */
+/*         printf("src = 0x%08X src->flags = %08X src->map->info.flags = %08x\ndst = 0x%08X dst->flags = %08X dst->map->info.flags = %08X\nsrc->map->blit = 0x%08x\n",  */
+/*                src, dst->flags, src->map->info.flags, */
+/*                dst, dst->flags, dst->map->info.flags, */
+/*                src->map->blit); */
     }
     return (src->map->blit(src, srcrect, dst, dstrect));
 }
--- a/src/video/SDL_video.c	Fri Mar 07 23:57:15 2008 +0000
+++ b/src/video/SDL_video.c	Fri Mar 14 18:17:49 2008 +0000
@@ -1329,15 +1329,17 @@
             if (window->id != windowID) {
                 continue;
             }
+            if (window->title) {
+                SDL_free(window->title);
+                window->title = NULL;
+            }
             if (window->renderer) {
                 SDL_DestroyRenderer(window->id);
+                window->renderer = NULL;
             }
             if (_this->DestroyWindow) {
                 _this->DestroyWindow(_this, window);
             }
-            if (window->title) {
-                SDL_free(window->title);
-            }
             if (j != display->num_windows - 1) {
                 SDL_memcpy(&display->windows[i],
                            &display->windows[i + 1],
@@ -1439,9 +1441,8 @@
     SDL_DestroyRenderer(windowID);
 
     /* Create a new renderer instance */
-    window->renderer =
-        SDL_CurrentDisplay.render_drivers[index].CreateRenderer(window,
-                                                                flags);
+    window->renderer = SDL_CurrentDisplay.render_drivers[index]
+        .CreateRenderer(window, flags);
     SDL_SelectRenderer(window->id);
 
     return 0;
@@ -2220,9 +2221,11 @@
         }
         if (display->gamma) {
             SDL_free(display->gamma);
+            display->gamma = NULL;
         }
         if (display->driverdata) {
             SDL_free(display->driverdata);
+            display->driverdata = NULL;
         }
     }
     if (_this->displays) {
--- a/src/video/x11/SDL_x11events.c	Fri Mar 07 23:57:15 2008 +0000
+++ b/src/video/x11/SDL_x11events.c	Fri Mar 14 18:17:49 2008 +0000
@@ -44,8 +44,8 @@
        handler */
     if (XFilterEvent(&xevent, None) == True) {
 #if 0
-      printf("Filtered event type = %d display = %d window = %d\n", 
-             xevent.type, xevent.xany.display, xevent.xany.window);
+        printf("Filtered event type = %d display = %d window = %d\n",
+               xevent.type, xevent.xany.display, xevent.xany.window);
 #endif
         return;
     }
@@ -73,10 +73,9 @@
     if (!data) {
         return;
     }
-
 #if 0
-      printf("type = %d display = %d window = %d\n", 
-             xevent.type, xevent.xany.display, xevent.xany.window);
+    printf("type = %d display = %d window = %d\n",
+           xevent.type, xevent.xany.display, xevent.xany.window);
 #endif
     switch (xevent.type) {
 
--- a/test/testgl2.c	Fri Mar 07 23:57:15 2008 +0000
+++ b/test/testgl2.c	Fri Mar 14 18:17:49 2008 +0000
@@ -24,7 +24,7 @@
 quit(int rc)
 {
     if (context) {
-        SDL_GL_MakeCurrent(0, NULL);
+        /* SDL_GL_MakeCurrent(0, NULL); *//* doesn't do anything */
         SDL_GL_DeleteContext(context);
     }
     CommonQuit(state);