From 08be576ff5e5344f17763cf4e0692effbb82cc2a Mon Sep 17 00:00:00 2001 From: Bob Pendleton Date: Fri, 14 Mar 2008 18:17:49 +0000 Subject: [PATCH] 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. --- include/SDL_compat.h | 53 +++++++++++++++++++++++------------ src/SDL_compat.c | 17 ++++++----- src/video/SDL_RLEaccel.c | 1 + src/video/SDL_blit.c | 3 +- src/video/SDL_renderer_gl.c | 2 +- src/video/SDL_surface.c | 5 ++++ src/video/SDL_video.c | 15 ++++++---- src/video/x11/SDL_x11events.c | 9 +++--- test/testgl2.c | 2 +- 9 files changed, 66 insertions(+), 41 deletions(-) diff --git a/include/SDL_compat.h b/include/SDL_compat.h index cfefa52cc..e7da5a159 100644 --- a/include/SDL_compat.h +++ b/include/SDL_compat.h @@ -209,43 +209,58 @@ struct SDL_SysWMinfo; #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 @@ extern DECLSPEC int SDLCALL SDL_DisplayYUVOverlay(SDL_Overlay * overlay, 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++ */ diff --git a/src/SDL_compat.c b/src/SDL_compat.c index 6f1282ac4..0d29b44d4 100644 --- a/src/SDL_compat.c +++ b/src/SDL_compat.c @@ -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_SetVideoMode(int width, int height, int bpp, Uint32 flags) 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; } diff --git a/src/video/SDL_RLEaccel.c b/src/video/SDL_RLEaccel.c index b5f9e3ab6..0998d3f93 100644 --- a/src/video/SDL_RLEaccel.c +++ b/src/video/SDL_RLEaccel.c @@ -1973,6 +1973,7 @@ SDL_UnRLESurface(SDL_Surface * surface, int recode) } 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); diff --git a/src/video/SDL_blit.c b/src/video/SDL_blit.c index 45504ab99..5caaeb6f8 100644 --- a/src/video/SDL_blit.c +++ b/src/video/SDL_blit.c @@ -260,7 +260,8 @@ SDL_CalculateBlit(SDL_Surface * surface) 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); diff --git a/src/video/SDL_renderer_gl.c b/src/video/SDL_renderer_gl.c index 28fca85ea..5df7b7ec7 100644 --- a/src/video/SDL_renderer_gl.c +++ b/src/video/SDL_renderer_gl.c @@ -947,7 +947,7 @@ GL_DestroyRenderer(SDL_Renderer * renderer) 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); diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index 581d8aaaf..bcb41d8b7 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -542,6 +542,11 @@ SDL_LowerBlit(SDL_Surface * src, SDL_Rect * srcrect, 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)); } diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 8ff62dd95..5a52f03b7 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -1329,15 +1329,17 @@ SDL_DestroyWindow(SDL_WindowID windowID) 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_CreateRenderer(SDL_WindowID windowID, int index, Uint32 flags) 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 @@ SDL_VideoQuit(void) } if (display->gamma) { SDL_free(display->gamma); + display->gamma = NULL; } if (display->driverdata) { SDL_free(display->driverdata); + display->driverdata = NULL; } } if (_this->displays) { diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index fa65815af..382c9373d 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -44,8 +44,8 @@ X11_DispatchEvent(_THIS) 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 @@ X11_DispatchEvent(_THIS) 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) { diff --git a/test/testgl2.c b/test/testgl2.c index c6467d602..2369b5659 100644 --- a/test/testgl2.c +++ b/test/testgl2.c @@ -24,7 +24,7 @@ static void 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);