diff options
Diffstat (limited to 'backends/graphics/surfacesdl')
-rw-r--r-- | backends/graphics/surfacesdl/surfacesdl-graphics.cpp | 69 | ||||
-rw-r--r-- | backends/graphics/surfacesdl/surfacesdl-graphics.h | 9 |
2 files changed, 72 insertions, 6 deletions
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp index 6cd5a47e1c..4eb63fd303 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp @@ -43,6 +43,11 @@ #include "graphics/surface.h" #include "gui/EventRecorder.h" +static const OSystem::GraphicsMode s_supportedShaders[] = { + {"NONE", "Normal (no shader)", 0}, + {0, 0, 0} +}; + static const OSystem::GraphicsMode s_supportedGraphicsModes[] = { {"1x", _s("Normal (no scaling)"), GFX_NORMAL}, #ifdef USE_SCALERS @@ -194,6 +199,23 @@ SurfaceSdlGraphicsManager::SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSou #if SDL_VERSION_ATLEAST(2, 0, 0) _videoMode.filtering = ConfMan.getBool("filtering"); #endif + + if (g_system->hasFeature(OSystem::kFeatureShader)) { + // shader number 0 is the entry NONE (no shader) + const OSystem::GraphicsMode *p = s_supportedShaders; + _numShaders = 0; + while (p->name) { + _numShaders++; + p++; + } + _currentShader = ConfMan.getInt("shader"); + if (_currentShader < 0 || _currentShader >= _numShaders) { + _currentShader = 0; + } + } else { + _numShaders = 1; + _currentShader = 0; + } } SurfaceSdlGraphicsManager::~SurfaceSdlGraphicsManager() { @@ -602,6 +624,8 @@ void SurfaceSdlGraphicsManager::setGraphicsModeIntern() { Common::StackLock lock(_graphicsMutex); ScalerProc *newScalerProc = 0; + updateShader(); + switch (_videoMode.mode) { case GFX_NORMAL: newScalerProc = Normal1x; @@ -676,6 +700,21 @@ int SurfaceSdlGraphicsManager::getGraphicsMode() const { return _videoMode.mode; } +const OSystem::GraphicsMode *SurfaceSdlGraphicsManager::getSupportedShaders() const { + return s_supportedShaders; +} + +int SurfaceSdlGraphicsManager::getShader() { + return _currentShader; +} + +bool SurfaceSdlGraphicsManager::setShader(int id) { + assert(id >= 0 && id < _numShaders); + _currentShader = id; + updateShader(); + return true; +} + void SurfaceSdlGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFormat *format) { assert(_transactionMode == kTransactionActive); @@ -996,10 +1035,18 @@ bool SurfaceSdlGraphicsManager::hotswapGFXMode() { _overlayscreen = NULL; // Release the HW screen surface - SDL_FreeSurface(_hwscreen); _hwscreen = NULL; - - SDL_FreeSurface(_tmpscreen); _tmpscreen = NULL; - SDL_FreeSurface(_tmpscreen2); _tmpscreen2 = NULL; + if (_hwscreen) { + SDL_FreeSurface(_hwscreen); + _hwscreen = NULL; + } + if (_tmpscreen) { + SDL_FreeSurface(_tmpscreen); + _tmpscreen = NULL; + } + if (_tmpscreen2) { + SDL_FreeSurface(_tmpscreen2); + _tmpscreen2 = NULL; + } // Setup the new GFX mode if (!loadGFXMode()) { @@ -1039,6 +1086,17 @@ void SurfaceSdlGraphicsManager::updateScreen() { internUpdateScreen(); } +void SurfaceSdlGraphicsManager::updateShader() { +// shader init code goes here +// currently only used on Vita port +// the user-selected shaderID should be obtained via ConfMan.getInt("shader") +// and the corresponding shader should then be activated here +// this way the user can combine any software scaling (scalers) +// with any hardware shading (shaders). The shaders could provide +// scanline masks, overlays, but could also serve for +// hardware-based up-scaling (sharp-bilinear-simple, etc.) +} + void SurfaceSdlGraphicsManager::internUpdateScreen() { SDL_Surface *srcSurf, *origSurf; int height, width; @@ -2554,7 +2612,8 @@ void SurfaceSdlGraphicsManager::deinitializeRenderer() { SDL_DestroyRenderer(_renderer); _renderer = nullptr; - _window->destroyWindow(); + if (_window) + _window->destroyWindow(); } void SurfaceSdlGraphicsManager::setWindowResolution(int width, int height) { diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h index 975cbfe27b..ef41b90f6c 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.h +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h @@ -105,6 +105,9 @@ public: virtual Graphics::PixelFormat getScreenFormat() const { return _screenFormat; } virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const; #endif + virtual const OSystem::GraphicsMode *getSupportedShaders() const; + virtual int getShader(); + virtual bool setShader(int id); virtual void initSize(uint w, uint h, const Graphics::PixelFormat *format = NULL); virtual int getScreenChangeID() const { return _screenChangeCount; } @@ -200,7 +203,7 @@ protected: void setWindowResolution(int width, int height); void recreateScreenTexture(); - SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags); + virtual SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags); void SDL_UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects); #endif @@ -302,6 +305,9 @@ protected: int _screenChangeCount; + int _currentShader; + int _numShaders; + enum { NUM_DIRTY_RECT = 100, MAX_SCALING = 3 @@ -384,6 +390,7 @@ protected: virtual void blitCursor(); virtual void internUpdateScreen(); + virtual void updateShader(); virtual bool loadGFXMode(); virtual void unloadGFXMode(); |