aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'backends/graphics/surfacesdl/surfacesdl-graphics.cpp')
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.cpp69
1 files changed, 64 insertions, 5 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) {