aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics
diff options
context:
space:
mode:
authorThierry Crozat2016-10-12 22:38:07 +0100
committerThierry Crozat2016-10-13 01:45:01 +0100
commit3a69898729b5d08aabcb53e6382284d1df818c9b (patch)
tree61e9c4efd5ccdbb25ee3b4a48a93924a1b0256d0 /backends/graphics
parentc6ce1c800296d5a0f18bc101d34c25dc638a6714 (diff)
downloadscummvm-rg350-3a69898729b5d08aabcb53e6382284d1df818c9b.tar.gz
scummvm-rg350-3a69898729b5d08aabcb53e6382284d1df818c9b.tar.bz2
scummvm-rg350-3a69898729b5d08aabcb53e6382284d1df818c9b.zip
SURFACESDL: Add support for filtering feature when using SDL2
This implements the request from ticket #9573: SDL1/2: Different rendering/filtering?
Diffstat (limited to 'backends/graphics')
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.cpp41
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.h7
2 files changed, 48 insertions, 0 deletions
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index 46e243c945..cc1d8dbafa 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -190,6 +190,10 @@ SurfaceSdlGraphicsManager::SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSou
#else
_videoMode.fullscreen = true;
#endif
+
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ _videoMode.filtering = ConfMan.getBool("filtering");
+#endif
}
SurfaceSdlGraphicsManager::~SurfaceSdlGraphicsManager() {
@@ -227,6 +231,9 @@ bool SurfaceSdlGraphicsManager::hasFeature(OSystem::Feature f) {
return
(f == OSystem::kFeatureFullscreenMode) ||
(f == OSystem::kFeatureAspectRatioCorrection) ||
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ (f == OSystem::kFeatureFilteringMode) ||
+#endif
(f == OSystem::kFeatureCursorPalette) ||
(f == OSystem::kFeatureIconifyWindow);
}
@@ -239,6 +246,11 @@ void SurfaceSdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable)
case OSystem::kFeatureAspectRatioCorrection:
setAspectRatioCorrection(enable);
break;
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ case OSystem::kFeatureFilteringMode:
+ setFilteringMode(enable);
+ break;
+#endif
case OSystem::kFeatureCursorPalette:
_cursorPaletteDisabled = !enable;
blitCursor();
@@ -263,6 +275,10 @@ bool SurfaceSdlGraphicsManager::getFeatureState(OSystem::Feature f) {
return _videoMode.fullscreen;
case OSystem::kFeatureAspectRatioCorrection:
return _videoMode.aspectRatioCorrection;
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ case OSystem::kFeatureFilteringMode:
+ return _videoMode.filtering;
+#endif
case OSystem::kFeatureCursorPalette:
return !_cursorPaletteDisabled;
default:
@@ -323,6 +339,12 @@ OSystem::TransactionError SurfaceSdlGraphicsManager::endGFXTransaction() {
_videoMode.mode = _oldVideoMode.mode;
_videoMode.scaleFactor = _oldVideoMode.scaleFactor;
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ } else if (_videoMode.filtering != _oldVideoMode.filtering) {
+ errors |= OSystem::kTransactionFilteringFailed;
+
+ _videoMode.filtering = _oldVideoMode.filtering;
+#endif
#ifdef USE_RGB_COLOR
} else if (_videoMode.format != _oldVideoMode.format) {
errors |= OSystem::kTransactionFormatNotSupported;
@@ -342,6 +364,9 @@ OSystem::TransactionError SurfaceSdlGraphicsManager::endGFXTransaction() {
if (_videoMode.fullscreen == _oldVideoMode.fullscreen &&
_videoMode.aspectRatioCorrection == _oldVideoMode.aspectRatioCorrection &&
_videoMode.mode == _oldVideoMode.mode &&
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ _videoMode.filtering == _oldVideoMode.filtering &&
+#endif
_videoMode.screenWidth == _oldVideoMode.screenWidth &&
_videoMode.screenHeight == _oldVideoMode.screenHeight) {
@@ -1267,6 +1292,20 @@ void SurfaceSdlGraphicsManager::setAspectRatioCorrection(bool enable) {
}
}
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+void SurfaceSdlGraphicsManager::setFilteringMode(bool enable) {
+ Common::StackLock lock(_graphicsMutex);
+
+ if (_oldVideoMode.setup && _oldVideoMode.filtering == enable)
+ return;
+
+ if (_transactionMode == kTransactionActive) {
+ _videoMode.filtering = enable;
+ _transactionDetails.needHotswap = true;
+ }
+}
+#endif
+
void SurfaceSdlGraphicsManager::copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) {
assert(_transactionMode == kTransactionNone);
assert(buf);
@@ -2542,6 +2581,8 @@ SDL_Surface *SurfaceSdlGraphicsManager::SDL_SetVideoMode(int width, int height,
SDL_GetWindowSize(_window->getSDLWindow(), &_windowWidth, &_windowHeight);
setWindowResolution(_windowWidth, _windowHeight);
+
+ SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, _videoMode.filtering ? "linear" : "nearest");
_screenTexture = SDL_CreateTexture(_renderer, SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STREAMING, width, height);
if (!_screenTexture) {
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h
index 82f4a33d8e..bc2edc964c 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.h
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h
@@ -250,6 +250,10 @@ protected:
bool aspectRatioCorrection;
AspectRatio desiredAspectRatio;
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ bool filtering;
+#endif
+
int mode;
int scaleFactor;
@@ -383,6 +387,9 @@ protected:
virtual void setFullscreenMode(bool enable);
virtual void setAspectRatioCorrection(bool enable);
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ virtual void setFilteringMode(bool enable);
+#endif
virtual int effectiveScreenHeight() const;