aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorThierry Crozat2016-10-13 00:19:15 +0100
committerThierry Crozat2016-10-13 01:46:27 +0100
commitaa39a6ce4b2285d1308eb4607bdd53d317304661 (patch)
tree7f00680bd8909a2dad153b687863333f1d8a6369 /backends
parentd6c4f3544160f8d6c9d3649693eb5e77e76da3a1 (diff)
downloadscummvm-rg350-aa39a6ce4b2285d1308eb4607bdd53d317304661.tar.gz
scummvm-rg350-aa39a6ce4b2285d1308eb4607bdd53d317304661.tar.bz2
scummvm-rg350-aa39a6ce4b2285d1308eb4607bdd53d317304661.zip
SURFACESDL: Improve toggling filtering on/off
We don't need to recreate the window when turning filtering on or off. Only the texture needs to be recreated.
Diffstat (limited to 'backends')
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.cpp26
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.h4
2 files changed, 29 insertions, 1 deletions
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index 2b62cc2c6e..90d079d151 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -313,6 +313,9 @@ void SurfaceSdlGraphicsManager::beginGFXTransaction() {
_transactionDetails.needUpdatescreen = false;
_transactionDetails.normal1xScaler = false;
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ _transactionDetails.needTextureUpdate = false;
+#endif
#ifdef USE_RGB_COLOR
_transactionDetails.formatChanged = false;
#endif
@@ -420,6 +423,12 @@ OSystem::TransactionError SurfaceSdlGraphicsManager::endGFXTransaction() {
if (_transactionDetails.needUpdatescreen)
internUpdateScreen();
}
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ } else if (_transactionDetails.needTextureUpdate) {
+ setGraphicsModeIntern();
+ recreateScreenTexture();
+ internUpdateScreen();
+#endif
} else if (_transactionDetails.needUpdatescreen) {
setGraphicsModeIntern();
internUpdateScreen();
@@ -1301,7 +1310,7 @@ void SurfaceSdlGraphicsManager::setFilteringMode(bool enable) {
if (_transactionMode == kTransactionActive) {
_videoMode.filtering = enable;
- _transactionDetails.needHotswap = true;
+ _transactionDetails.needTextureUpdate = true;
}
}
#endif
@@ -2355,6 +2364,7 @@ bool SurfaceSdlGraphicsManager::handleScalerHotkeys(Common::KeyCode key) {
displayMessageOnOSD(_("Filtering disabled"));
}
#endif
+ _forceFull = true;
internUpdateScreen();
return true;
}
@@ -2580,6 +2590,20 @@ void SurfaceSdlGraphicsManager::setWindowResolution(int width, int height) {
_forceFull = true;
}
+void SurfaceSdlGraphicsManager::recreateScreenTexture() {
+ if (!_renderer)
+ return;
+
+ SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, _videoMode.filtering ? "linear" : "nearest");
+
+ SDL_Texture *oldTexture = _screenTexture;
+ _screenTexture = SDL_CreateTexture(_renderer, SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STREAMING, _videoMode.hardwareWidth, _videoMode.hardwareHeight);
+ if (_screenTexture)
+ SDL_DestroyTexture(oldTexture);
+ else
+ _screenTexture = oldTexture;
+}
+
SDL_Surface *SurfaceSdlGraphicsManager::SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) {
deinitializeRenderer();
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h
index bc2edc964c..975cbfe27b 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.h
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h
@@ -198,6 +198,7 @@ protected:
int _windowWidth, _windowHeight;
void deinitializeRenderer();
void setWindowResolution(int width, int height);
+ void recreateScreenTexture();
SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags);
void SDL_UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects);
@@ -237,6 +238,9 @@ protected:
bool needHotswap;
bool needUpdatescreen;
bool normal1xScaler;
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ bool needTextureUpdate;
+#endif
#ifdef USE_RGB_COLOR
bool formatChanged;
#endif