[Scummvm-git-logs] scummvm master -> 68c293a00405259b5aef0f156bc20d9114cb6ce7

sev- noreply at scummvm.org
Sat Jun 17 18:21:33 UTC 2023


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:
38e88cde66 BACKENDS: GRAPHICS: Implement scaler scrolling for OpenGL
68c293a004 GUI: Ommit aspect ratio checkbox if this feature is missing


Commit: 38e88cde661a624ff1860ab38d776000494337c6
    https://github.com/scummvm/scummvm/commit/38e88cde661a624ff1860ab38d776000494337c6
Author: antoniou79 (a.antoniou79 at gmail.com)
Date: 2023-06-17T20:21:29+02:00

Commit Message:
BACKENDS: GRAPHICS: Implement scaler scrolling for OpenGL

Using the Ctrl+Alt+0 or 9 keymap

Also added a guard check for kFeatureScalers to allow the actions (kActionNextScaleFilter, kActionPreviousScaleFilter) to change scaler (but not scaler factor) in sdl/sdl-graphics.cpp

Changed paths:
    backends/graphics/openglsdl/openglsdl-graphics.cpp
    backends/graphics/sdl/sdl-graphics.cpp


diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index 19acd13ef70..9f7a30950f4 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -24,6 +24,9 @@
 #include "backends/events/sdl/sdl-events.h"
 #include "backends/platform/sdl/sdl.h"
 #include "graphics/scaler/aspect.h"
+#ifdef USE_SCALERS
+#include "graphics/scalerplugin.h"
+#endif
 
 #include "common/textconsole.h"
 #include "common/config-manager.h"
@@ -717,6 +720,56 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) {
 		return true;
 	}
 
+#ifdef USE_SCALERS
+	case kActionNextScaleFilter:
+	case kActionPreviousScaleFilter: {
+		if (_scalerPlugins.size() > 0) {
+			const int direction = event.customType == kActionNextScaleFilter ? 1 : -1;
+
+			uint scalerIndex = getScaler();
+			switch (direction) {
+			case 1:
+				if (scalerIndex >= _scalerPlugins.size() - 1) {
+					scalerIndex = 0;
+				} else {
+					++scalerIndex;
+				}
+				break;
+
+			case -1:
+			default:
+				if (scalerIndex == 0) {
+					scalerIndex = _scalerPlugins.size() - 1;
+				} else {
+					--scalerIndex;
+				}
+				break;
+			}
+
+			beginGFXTransaction();
+			setScaler(scalerIndex, getScaleFactor());
+			endGFXTransaction();
+
+#ifdef USE_OSD
+			int windowWidth = 0, windowHeight = 0;
+			getWindowSizeFromSdl(&windowWidth, &windowHeight);
+			const char *newScalerName = _scalerPlugins[scalerIndex]->get<ScalerPluginObject>().getPrettyName();
+			if (newScalerName) {
+				const Common::U32String message = Common::U32String::format(
+					"%S %s%d\n%d x %d",
+					_("Active graphics filter:").c_str(),
+					newScalerName,
+					getScaleFactor(),
+					windowWidth, windowHeight);
+				displayMessageOnOSD(message);
+			}
+#endif
+		}
+
+		return true;
+	}
+#endif // USE_SCALERS
+
 	case kActionToggleAspectRatioCorrection:
 		// Toggles the aspect ratio correction state.
 		beginGFXTransaction();
diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp
index 10fca20daf9..42587b367c3 100644
--- a/backends/graphics/sdl/sdl-graphics.cpp
+++ b/backends/graphics/sdl/sdl-graphics.cpp
@@ -464,27 +464,29 @@ Common::Keymap *SdlGraphicsManager::getKeymap() {
 		keymap->addAction(act);
 	}
 
-	act = new Action("SCL+", _("Increase the scale factor"));
-	act->addDefaultInputMapping("C+A+PLUS");
-	act->addDefaultInputMapping("C+A+KP_PLUS");
-	act->setCustomBackendActionEvent(kActionIncreaseScaleFactor);
-	keymap->addAction(act);
+		act = new Action("SCL+", _("Increase the scale factor"));
+		act->addDefaultInputMapping("C+A+PLUS");
+		act->addDefaultInputMapping("C+A+KP_PLUS");
+		act->setCustomBackendActionEvent(kActionIncreaseScaleFactor);
+		keymap->addAction(act);
 
-	act = new Action("SCL-", _("Decrease the scale factor"));
-	act->addDefaultInputMapping("C+A+MINUS");
-	act->addDefaultInputMapping("C+A+KP_MINUS");
-	act->setCustomBackendActionEvent(kActionDecreaseScaleFactor);
-	keymap->addAction(act);
+		act = new Action("SCL-", _("Decrease the scale factor"));
+		act->addDefaultInputMapping("C+A+MINUS");
+		act->addDefaultInputMapping("C+A+KP_MINUS");
+		act->setCustomBackendActionEvent(kActionDecreaseScaleFactor);
+		keymap->addAction(act);
 
-	act = new Action("FLTN", _("Switch to the next scaler"));
-	act->addDefaultInputMapping("C+A+0");
-	act->setCustomBackendActionEvent(kActionNextScaleFilter);
-	keymap->addAction(act);
+	if (hasFeature(OSystem::kFeatureScalers)) {
+		act = new Action("FLTN", _("Switch to the next scaler"));
+		act->addDefaultInputMapping("C+A+0");
+		act->setCustomBackendActionEvent(kActionNextScaleFilter);
+		keymap->addAction(act);
 
-	act = new Action("FLTP", _("Switch to the previous scaler"));
-	act->addDefaultInputMapping("C+A+9");
-	act->setCustomBackendActionEvent(kActionPreviousScaleFilter);
-	keymap->addAction(act);
+		act = new Action("FLTP", _("Switch to the previous scaler"));
+		act->addDefaultInputMapping("C+A+9");
+		act->setCustomBackendActionEvent(kActionPreviousScaleFilter);
+		keymap->addAction(act);
+	}
 
 	return keymap;
 }


Commit: 68c293a00405259b5aef0f156bc20d9114cb6ce7
    https://github.com/scummvm/scummvm/commit/68c293a00405259b5aef0f156bc20d9114cb6ce7
Author: antoniou79 (a.antoniou79 at gmail.com)
Date: 2023-06-17T20:21:29+02:00

Commit Message:
GUI: Ommit aspect ratio checkbox if this feature is missing

Also fix compilation when building for --disable-aspect (buggy end bracket in backends/graphics/surfacesdl/surfacesdl-graphics.cpp)

Changed paths:
    backends/graphics/opengl/opengl-graphics.cpp
    backends/graphics/surfacesdl/surfacesdl-graphics.cpp
    gui/options.cpp


diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index 7e4177ce221..72686a2c0e5 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -109,7 +109,9 @@ OpenGLGraphicsManager::~OpenGLGraphicsManager() {
 
 bool OpenGLGraphicsManager::hasFeature(OSystem::Feature f) const {
 	switch (f) {
+#ifdef USE_ASPECT
 	case OSystem::kFeatureAspectRatioCorrection:
+#endif
 	case OSystem::kFeatureCursorPalette:
 	case OSystem::kFeatureFilteringMode:
 	case OSystem::kFeatureStretchMode:
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index 17fac57b551..919df8be5f2 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -1383,8 +1383,8 @@ void SurfaceSdlGraphicsManager::internUpdateScreen() {
 #ifdef USE_ASPECT
 				if (_videoMode.aspectRatioCorrection && orig_dst_y < height && !_overlayInGUI)
 					r->h = stretch200To240((uint8 *) _hwScreen->pixels, dstPitch, r->w, r->h, r->x, r->y, orig_dst_y * scale1, _videoMode.filtering, 	convertSDLPixelFormat(_hwScreen->format));
-			}
 #endif
+			}
 		}
 		SDL_UnlockSurface(srcSurf);
 		SDL_UnlockSurface(_hwScreen);
diff --git a/gui/options.cpp b/gui/options.cpp
index c0121623699..c1145db58c5 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -366,12 +366,14 @@ void OptionsDialog::build() {
 		}
 
 		// Aspect ratio setting
-		if (_guioptions.contains(GUIO_NOASPECT)) {
-			_aspectCheckbox->setState(false);
-			_aspectCheckbox->setEnabled(false);
-		} else {
-			_aspectCheckbox->setEnabled(true);
-			_aspectCheckbox->setState(ConfMan.getBool("aspect_ratio", _domain));
+		if (g_system->hasFeature(OSystem::kFeatureAspectRatioCorrection)) {
+			if (_guioptions.contains(GUIO_NOASPECT)) {
+				_aspectCheckbox->setState(false);
+				_aspectCheckbox->setEnabled(false);
+			} else {
+				_aspectCheckbox->setEnabled(true);
+				_aspectCheckbox->setState(ConfMan.getBool("aspect_ratio", _domain));
+			}
 		}
 
 		if (g_system->hasFeature(OSystem::kFeatureVSync)) {
@@ -612,8 +614,10 @@ void OptionsDialog::apply() {
 				ConfMan.setBool("fullscreen", _fullscreenCheckbox->getState(), _domain);
 				_fullscreenCheckbox->setOverride(false);
 			}
-			if (ConfMan.getBool("aspect_ratio", _domain) != _aspectCheckbox->getState())
-				graphicsModeChanged = true;
+			if (g_system->hasFeature(OSystem::kFeatureAspectRatioCorrection)) {
+				if (ConfMan.getBool("aspect_ratio", _domain) != _aspectCheckbox->getState())
+					graphicsModeChanged = true;
+			}
 			if (g_system->hasFeature(OSystem::kFeatureVSync)) {
 				if (ConfMan.getBool("vsync", _domain) != _vsyncCheckbox->getState()) {
 					graphicsModeChanged = true;
@@ -622,7 +626,9 @@ void OptionsDialog::apply() {
 				}
 			}
 
-			ConfMan.setBool("aspect_ratio", _aspectCheckbox->getState(), _domain);
+			if (g_system->hasFeature(OSystem::kFeatureAspectRatioCorrection)) {
+				ConfMan.setBool("aspect_ratio", _aspectCheckbox->getState(), _domain);
+			}
 
 			bool isSet = false;
 
@@ -1285,10 +1291,12 @@ void OptionsDialog::setGraphicSettingsState(bool enabled) {
 	else
 		_fullscreenCheckbox->setEnabled(false);
 
-	if (_guioptions.contains(GUIO_NOASPECT))
-		_aspectCheckbox->setEnabled(false);
-	else
-		_aspectCheckbox->setEnabled(enabled);
+	if (g_system->hasFeature(OSystem::kFeatureAspectRatioCorrection)) {
+		if (_guioptions.contains(GUIO_NOASPECT))
+			_aspectCheckbox->setEnabled(false);
+		else
+			_aspectCheckbox->setEnabled(enabled);
+	}
 
 	if (g_system->hasFeature(OSystem::kFeatureVSync))
 		_vsyncCheckbox->setEnabled(enabled);
@@ -1693,7 +1701,8 @@ void OptionsDialog::addGraphicControls(GuiObject *boss, const Common::String &pr
 		_filteringCheckbox = new CheckboxWidget(boss, prefix + "grFilteringCheckbox", _("Filter graphics"), _("Use linear filtering when scaling graphics"));
 
 	// Aspect ratio checkbox
-	_aspectCheckbox = new CheckboxWidget(boss, prefix + "grAspectCheckbox", _("Aspect ratio correction"), _("Correct aspect ratio for games"));
+	if (g_system->hasFeature(OSystem::kFeatureAspectRatioCorrection))
+		_aspectCheckbox = new CheckboxWidget(boss, prefix + "grAspectCheckbox", _("Aspect ratio correction"), _("Correct aspect ratio for games"));
 
 	_enableGraphicSettings = true;
 }
@@ -2041,7 +2050,9 @@ void OptionsDialog::setupGraphicsTab() {
 	if (g_system->hasFeature(OSystem::kFeatureFilteringMode))
 		_filteringCheckbox->setVisible(true);
 
-	_aspectCheckbox->setVisible(true);
+	if (g_system->hasFeature(OSystem::kFeatureAspectRatioCorrection))
+		_aspectCheckbox->setVisible(true);
+
 	_renderModePopUpDesc->setVisible(true);
 	_renderModePopUp->setVisible(true);
 




More information about the Scummvm-git-logs mailing list