Mercurial > hg > openttd
changeset 20069:e6633b64e49b draft
(svn r25003) -Fix (r24993): [SDL] Keep a flag to remember if a hardware palette was requested.
- Previously, the code would query the SDL_HWPALETTE flag, which doesn't always match the requested value.
- This would cause SDL to be restarted on every window resize event, effectively breaking resizing.
author | matthijs <matthijs@openttd.org> |
---|---|
date | Fri, 15 Feb 2013 11:01:45 +0000 |
parents | dba49df7bb69 |
children | 7283b3fbb839 |
files | src/video/sdl_v.cpp |
diffstat | 1 files changed, 7 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/video/sdl_v.cpp +++ b/src/video/sdl_v.cpp @@ -46,6 +46,7 @@ static SDL_Rect _dirty_rects[MAX_DIRTY_RECTS]; static int _num_dirty_rects; static int _use_hwpalette; +static int _requested_hwpalette; /* Did we request a HWPALETTE for the current video mode? */ void VideoDriver_SDL::MakeDirty(int left, int top, int width, int height) { @@ -326,8 +327,7 @@ if (_sdl_screen != NULL && _sdl_screen != _sdl_realscreen) SDL_CALL SDL_FreeSurface(_sdl_screen); if (_sdl_realscreen != NULL) { - bool have_hwpalette = ((_sdl_realscreen->flags & SDL_HWPALETTE) == SDL_HWPALETTE); - if (have_hwpalette != want_hwpalette) { + if (_requested_hwpalette != want_hwpalette) { /* SDL (at least the X11 driver), reuses the * same window and palette settings when the bpp * (and a few flags) are the same. Since we need @@ -335,11 +335,6 @@ * when switching between fullscreen and * windowed), we restart the entire video * subsystem to force creating a new window. - * - * Note that checking the SDL_HWPALETTE on the - * existing window might not be accurate when - * SDL is running with its own shadow surface, - * but this should not normally be a problem. */ DEBUG(driver, 0, "SDL: Restarting SDL video subsystem, to force hwpalette change"); SDL_CALL SDL_QuitSubSystem(SDL_INIT_VIDEO); @@ -347,6 +342,11 @@ ClaimMousePointer(); } } + /* Remember if we wanted a hwpalette. We can't reliably query + * SDL for the SDL_HWPALETTE flag, since it might get set even + * though we didn't ask for it (when SDL creates a shadow + * surface, for example). */ + _requested_hwpalette = want_hwpalette; /* DO NOT CHANGE TO HWSURFACE, IT DOES NOT WORK */ newscreen = SDL_CALL SDL_SetVideoMode(w, h, bpp, SDL_SWSURFACE | (want_hwpalette ? SDL_HWPALETTE : 0) | (_fullscreen ? SDL_FULLSCREEN : SDL_RESIZABLE));