From 9b6461122e237a02a9cab6e7ee7a11b236f5d69f Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Fri, 26 Jul 2019 19:17:57 +0100 Subject: SDL: Move selecting the required ScalerProc into a separate function --- backends/graphics/surfacesdl/surfacesdl-graphics.cpp | 19 +++++++++++++------ backends/graphics/surfacesdl/surfacesdl-graphics.h | 1 + 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'backends/graphics/surfacesdl') diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp index 304848ed4c..e14471b067 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp @@ -674,12 +674,8 @@ bool SurfaceSdlGraphicsManager::setGraphicsMode(int mode) { return true; } -void SurfaceSdlGraphicsManager::setGraphicsModeIntern() { - Common::StackLock lock(_graphicsMutex); +ScalerProc *SurfaceSdlGraphicsManager::getGraphicsScalerProc(int mode) const { ScalerProc *newScalerProc = 0; - - updateShader(); - switch (_videoMode.mode) { case GFX_NORMAL: newScalerProc = Normal1x; @@ -722,8 +718,19 @@ void SurfaceSdlGraphicsManager::setGraphicsModeIntern() { newScalerProc = DotMatrix; break; #endif // USE_SCALERS + } - default: + return newScalerProc; +} + +void SurfaceSdlGraphicsManager::setGraphicsModeIntern() { + Common::StackLock lock(_graphicsMutex); + + updateShader(); + + ScalerProc *newScalerProc = getGraphicsScalerProc(_videoMode.mode); + + if (!newScalerProc) { error("Unknown gfx mode %d", _videoMode.mode); } diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h index 3db2ac6709..68d0cd2b07 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.h +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h @@ -189,6 +189,7 @@ protected: virtual void handleResizeImpl(const int width, const int height) override; virtual int getGraphicsModeScale(int mode) const override; + virtual ScalerProc *getGraphicsScalerProc(int mode) const override; #if SDL_VERSION_ATLEAST(2, 0, 0) /* SDL2 features a different API for 2D graphics. We create a wrapper -- cgit v1.2.3