[Scummvm-git-logs] scummvm branch-2-3 -> 67dcd72463e974a0ee9b468b2263c47c3a931947

sev- sev at scummvm.org
Thu Sep 2 11:25:03 UTC 2021


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
df0357d3fa SDL: Set better default scaler for high-resolution games
67dcd72463 SDL: Check if hi-res scaler is available at desired factor


Commit: df0357d3faa2bd80dec4f7b54921686912ce5635
    https://github.com/scummvm/scummvm/commit/df0357d3faa2bd80dec4f7b54921686912ce5635
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2021-09-02T13:24:52+02:00

Commit Message:
SDL: Set better default scaler for high-resolution games

Now that we have higher scale factors than 3, it makes sense to try and
figure out a default scaler for high-resolution games that approximate
the window size of a low resolution game.

That also means that we are not necessarily restricted to the normal
scaler, since AdvMame has both 2x and 4x versions.

Changed paths:
    backends/graphics/surfacesdl/surfacesdl-graphics.cpp


diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index 7bb4393957..ad16c000a3 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -716,12 +716,20 @@ void SurfaceSdlGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFo
 
 	if ((int)w != _videoMode.screenWidth || (int)h != _videoMode.screenHeight) {
 		const bool useDefault = defaultGraphicsModeConfig();
+		int scaleFactor = ConfMan.getInt("scale_factor");
+		int mode = _videoMode.scalerIndex;
 		if (useDefault && w > 320) {
-			// Only the normal scaler has a 1x mode
-			setScaler(ScalerMan.findScalerPluginIndex("normal"), 1);
-		} else {
-			setScaler(_videoMode.scalerIndex, ConfMan.getInt("scale_factor"));
+			// The default scaler is assumed to be for low
+			// resolution games. For high resolution games, pick
+			// the largest scale factor that gives at most the
+			// same window width.
+			scaleFactor = MAX<uint>(1, (scaleFactor * 320) / w);
+
+			// Only the normal scaler has a 1x mode.
+			if (scaleFactor == 1)
+				mode = ScalerMan.findScalerPluginIndex("normal");
 		}
+		setScaler(mode, scaleFactor);
 	}
 
 	_videoMode.screenWidth = w;


Commit: 67dcd72463e974a0ee9b468b2263c47c3a931947
    https://github.com/scummvm/scummvm/commit/67dcd72463e974a0ee9b468b2263c47c3a931947
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2021-09-02T13:24:53+02:00

Commit Message:
SDL: Check if hi-res scaler is available at desired factor

Instead of falling back to the normal scaler if the new scale factor is
1, explicitly check if the desired scaler is available at the new scale
factor. Suggested by criezy, and I'm shamelessly copying his
implementation because this sort of C++ trickery is something I'm not
fluent in.

At the moment, this shouldn't make any difference. But I guess in the
future, there may be a scaler that's available at 3x and 4x, but not 2x,
or something like that.

Changed paths:
    backends/graphics/surfacesdl/surfacesdl-graphics.cpp


diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index ad16c000a3..36f0aa591c 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -716,7 +716,7 @@ void SurfaceSdlGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFo
 
 	if ((int)w != _videoMode.screenWidth || (int)h != _videoMode.screenHeight) {
 		const bool useDefault = defaultGraphicsModeConfig();
-		int scaleFactor = ConfMan.getInt("scale_factor");
+		uint scaleFactor = ConfMan.getInt("scale_factor");
 		int mode = _videoMode.scalerIndex;
 		if (useDefault && w > 320) {
 			// The default scaler is assumed to be for low
@@ -725,9 +725,14 @@ void SurfaceSdlGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFo
 			// same window width.
 			scaleFactor = MAX<uint>(1, (scaleFactor * 320) / w);
 
-			// Only the normal scaler has a 1x mode.
-			if (scaleFactor == 1)
+			// Check that the current scaler is available at the
+			// new scale factor. If not, the normal scaler is
+			// assumed to be available at any reasonable factor,
+			// and is - of course -the only one that has a 1x mode.
+			const Common::Array<uint> &factors = _scalerPlugins[mode]->get<ScalerPluginObject>().getFactors();
+			if (Common::find(factors.begin(), factors.end(), scaleFactor) == factors.end()) {
 				mode = ScalerMan.findScalerPluginIndex("normal");
+			}
 		}
 		setScaler(mode, scaleFactor);
 	}




More information about the Scummvm-git-logs mailing list