diff options
author | Bastien Bouclet | 2017-11-11 06:46:48 +0100 |
---|---|---|
committer | Bastien Bouclet | 2017-11-11 13:26:22 +0100 |
commit | 1dbe3ad18ea235debd29192f79537264cd247bab (patch) | |
tree | e7e82541fcd57d457eddac8c7c112d8d9ef4762c | |
parent | be0e1371e810b474813bf57c2627fcf7799649c3 (diff) | |
download | scummvm-rg350-1dbe3ad18ea235debd29192f79537264cd247bab.tar.gz scummvm-rg350-1dbe3ad18ea235debd29192f79537264cd247bab.tar.bz2 scummvm-rg350-1dbe3ad18ea235debd29192f79537264cd247bab.zip |
SDL: Fix assertion when using 4bpp cursors with a key color
Myst ME uses such cursors.
-rw-r--r-- | backends/graphics/surfacesdl/surfacesdl-graphics.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp index 4a6061c428..6d3b3c4750 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp @@ -1843,9 +1843,7 @@ void SurfaceSdlGraphicsManager::setMouseCursor(const void *buf, uint w, uint h, _cursorFormat = Graphics::PixelFormat::createFormatCLUT8(); } - if (_cursorFormat.bytesPerPixel == 4) { - assert(keyColor == 0); - } else { + if (_cursorFormat.bytesPerPixel < 4) { assert(keyColor < 1U << (_cursorFormat.bytesPerPixel * 8)); } @@ -1898,7 +1896,9 @@ void SurfaceSdlGraphicsManager::setMouseCursor(const void *buf, uint w, uint h, error("Allocating _mouseOrigSurface failed"); } - if (_cursorFormat.bytesPerPixel < 4) { + if (_cursorFormat.bytesPerPixel == 4) { + SDL_SetColorKey(_mouseOrigSurface, SDL_SRCCOLORKEY | SDL_SRCALPHA, _mouseKeyColor); + } else { SDL_SetColorKey(_mouseOrigSurface, SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, kMouseColorKey); } } @@ -1979,7 +1979,7 @@ void SurfaceSdlGraphicsManager::blitCursor() { } SDL_PixelFormat *format = _mouseOrigSurface->format; - _mouseSurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA, + _mouseSurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCCOLORKEY | SDL_SRCALPHA, rW, rH, format->BitsPerPixel, format->Rmask, @@ -1987,6 +1987,8 @@ void SurfaceSdlGraphicsManager::blitCursor() { format->Bmask, format->Amask); + SDL_SetColorKey(_mouseSurface, SDL_SRCCOLORKEY | SDL_SRCALPHA, _mouseKeyColor); + // At least SDL 2.0.4 on Windows apparently has a broken SDL_BlitScaled // implementation, and SDL 1 has no such API at all, and our other // scalers operate exclusively at 16bpp, so here is a scrappy 32bpp |