Codechange: [SDL2/Win32] Be consistent how 0bpp blitters are not allowed

Sometimes it returned an usererror(), sometimes Start() failed.
Now it always fails on Start(), so nothing else has to check again
what blitter is used.

AfterBlitterChange() can never change to a 0bpp, so it is sufficient
to guard this with an assert().
pull/217/head
Patric Stout 3 years ago committed by Michael Lutz
parent 49df9c4155
commit 1eceee915e

@ -258,8 +258,6 @@ bool VideoDriver_SDL::CreateMainSurface(uint w, uint h, bool resize)
DEBUG(driver, 1, "SDL2: using mode %ux%ux%d", w, h, bpp); DEBUG(driver, 1, "SDL2: using mode %ux%ux%d", w, h, bpp);
if (bpp == 0) usererror("Can't use a blitter that blits 0 bpp for normal visuals");
/* Free any previously allocated shadow surface */ /* Free any previously allocated shadow surface */
if (_sdl_surface != nullptr && _sdl_surface != _sdl_realscreen) SDL_FreeSurface(_sdl_surface); if (_sdl_surface != nullptr && _sdl_surface != _sdl_realscreen) SDL_FreeSurface(_sdl_surface);
@ -664,6 +662,8 @@ int VideoDriver_SDL::PollEvent()
const char *VideoDriver_SDL::Start(const StringList &parm) const char *VideoDriver_SDL::Start(const StringList &parm)
{ {
if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 0) return "Only real blitters supported";
/* Explicitly disable hardware acceleration. Enabling this causes /* Explicitly disable hardware acceleration. Enabling this causes
* UpdateWindowSurface() to update the window's texture instead of * UpdateWindowSurface() to update the window's texture instead of
* its surface. */ * its surface. */
@ -939,6 +939,7 @@ bool VideoDriver_SDL::ToggleFullscreen(bool fullscreen)
bool VideoDriver_SDL::AfterBlitterChange() bool VideoDriver_SDL::AfterBlitterChange()
{ {
assert(BlitterFactory::GetCurrentBlitter()->GetScreenDepth() != 0);
int w, h; int w, h;
SDL_GetWindowSize(_sdl_window, &w, &h); SDL_GetWindowSize(_sdl_window, &w, &h);
return CreateMainSurface(w, h, false); return CreateMainSurface(w, h, false);

@ -1004,8 +1004,6 @@ static bool AllocateDibSection(int w, int h, bool force)
w = std::max(w, 64); w = std::max(w, 64);
h = std::max(h, 64); h = std::max(h, 64);
if (bpp == 0) usererror("Can't use a blitter that blits 0 bpp for normal visuals");
if (!force && w == _screen.width && h == _screen.height) return false; if (!force && w == _screen.width && h == _screen.height) return false;
bi = (BITMAPINFO*)alloca(sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 256); bi = (BITMAPINFO*)alloca(sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 256);
@ -1016,7 +1014,7 @@ static bool AllocateDibSection(int w, int h, bool force)
bi->bmiHeader.biHeight = -(_wnd.height = h); bi->bmiHeader.biHeight = -(_wnd.height = h);
bi->bmiHeader.biPlanes = 1; bi->bmiHeader.biPlanes = 1;
bi->bmiHeader.biBitCount = BlitterFactory::GetCurrentBlitter()->GetScreenDepth(); bi->bmiHeader.biBitCount = bpp;
bi->bmiHeader.biCompression = BI_RGB; bi->bmiHeader.biCompression = BI_RGB;
if (_wnd.dib_sect) DeleteObject(_wnd.dib_sect); if (_wnd.dib_sect) DeleteObject(_wnd.dib_sect);
@ -1079,6 +1077,8 @@ static FVideoDriver_Win32 iFVideoDriver_Win32;
const char *VideoDriver_Win32::Start(const StringList &parm) const char *VideoDriver_Win32::Start(const StringList &parm)
{ {
if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 0) return "Only real blitters supported";
this->UpdateAutoResolution(); this->UpdateAutoResolution();
memset(&_wnd, 0, sizeof(_wnd)); memset(&_wnd, 0, sizeof(_wnd));
@ -1288,6 +1288,7 @@ bool VideoDriver_Win32::ToggleFullscreen(bool full_screen)
bool VideoDriver_Win32::AfterBlitterChange() bool VideoDriver_Win32::AfterBlitterChange()
{ {
assert(BlitterFactory::GetCurrentBlitter()->GetScreenDepth() != 0);
return AllocateDibSection(_screen.width, _screen.height, true) && this->MakeWindow(_fullscreen); return AllocateDibSection(_screen.width, _screen.height, true) && this->MakeWindow(_fullscreen);
} }

Loading…
Cancel
Save