[Scummvm-git-logs] scummvm master -> 5caacb763b7071339a7a2d4b4cd2d902129cd222

criezy criezy at scummvm.org
Fri Aug 13 20:41:39 UTC 2021


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

Summary:
6d8462674f COMMON: Add getHiDPIScreenFactor to OSystem
63dd44a81d SDL: Implement getHiDPIScreenFactor
2649f022de IOS7: Implement getHiDPIScreenFactor
fe377775d6 ANDROID: Implement getHiDPIScreenFactor
4ad54446f8 SDL: Get accurate HiDPI scaling on macOS
abf782c670 COMMON: Remove kFeatureHiDPI from OSystem and use getHiDPIScreenFactor instead
ad31dfc8d5 GUI: Handle the GUI Scale option as a scaling rather than base resolution
5caacb763b SDL: Change signature of getDpiScalingFactor to return the result


Commit: 6d8462674f765dfbcc357ff50c57f5459aa1d64c
    https://github.com/scummvm/scummvm/commit/6d8462674f765dfbcc357ff50c57f5459aa1d64c
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-08-13T21:41:33+01:00

Commit Message:
COMMON: Add getHiDPIScreenFactor to OSystem

Changed paths:
    backends/graphics/graphics.h
    backends/modular-backend.cpp
    backends/modular-backend.h
    common/system.h


diff --git a/backends/graphics/graphics.h b/backends/graphics/graphics.h
index 3b56f5138d..3533a8bafe 100644
--- a/backends/graphics/graphics.h
+++ b/backends/graphics/graphics.h
@@ -101,6 +101,7 @@ public:
 	virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) = 0;
 	virtual int16 getOverlayHeight() const = 0;
 	virtual int16 getOverlayWidth() const = 0;
+	virtual float getHiDPIScreenFactor() const { return 1.0f; }
 
 	virtual bool showMouse(bool visible) = 0;
 	virtual void warpMouse(int x, int y) = 0;
diff --git a/backends/modular-backend.cpp b/backends/modular-backend.cpp
index 21992de2d0..7950018d57 100644
--- a/backends/modular-backend.cpp
+++ b/backends/modular-backend.cpp
@@ -243,6 +243,10 @@ int16 ModularGraphicsBackend::getOverlayWidth() {
 	return _graphicsManager->getOverlayWidth();
 }
 
+float ModularGraphicsBackend::getHiDPIScreenFactor() const {
+	return _graphicsManager->getHiDPIScreenFactor();
+}
+
 bool ModularGraphicsBackend::showMouse(bool visible) {
 	return _graphicsManager->showMouse(visible);
 }
diff --git a/backends/modular-backend.h b/backends/modular-backend.h
index 0bde48e189..2318bfc0eb 100644
--- a/backends/modular-backend.h
+++ b/backends/modular-backend.h
@@ -114,6 +114,8 @@ public:
 	virtual int16 getOverlayHeight() override final;
 	virtual int16 getOverlayWidth() override final;
 
+	virtual float getHiDPIScreenFactor() const override final;
+
 	virtual bool showMouse(bool visible) override final;
 	virtual void warpMouse(int x, int y) override final;
 	virtual void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale = false, const Graphics::PixelFormat *format = NULL) override final;
diff --git a/common/system.h b/common/system.h
index 4ef6825d09..e040ba1a64 100644
--- a/common/system.h
+++ b/common/system.h
@@ -1052,6 +1052,12 @@ public:
 	 */
 	virtual PaletteManager *getPaletteManager() = 0;
 
+	/**
+	 * Return the scale factor for HiDPI screens.
+	 * Returns 1 for non-HiDPI screens, or if HiDPI display is not supported by the backend.
+	 */
+	virtual float getHiDPIScreenFactor() const { return 1.0f; }
+
 	/**
 	 * Blit a bitmap to the virtual screen.
 	 *


Commit: 63dd44a81d0a82133263f88e089102b2cce48a1d
    https://github.com/scummvm/scummvm/commit/63dd44a81d0a82133263f88e089102b2cce48a1d
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-08-13T21:41:33+01:00

Commit Message:
SDL: Implement getHiDPIScreenFactor

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


diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index 79d02c3afa..31d2d2881e 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -251,6 +251,12 @@ bool OpenGLSdlGraphicsManager::getFeatureState(OSystem::Feature f) const {
 	}
 }
 
+float OpenGLSdlGraphicsManager::getHiDPIScreenFactor() const {
+	float scale;
+	getDpiScalingFactor(&scale);
+	return scale;
+}
+
 void OpenGLSdlGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFormat *format) {
 	// HACK: This is stupid but the SurfaceSDL backend defaults to 2x. This
 	// assures that the launcher (which requests 320x200) has a reasonable
@@ -288,9 +294,9 @@ void OpenGLSdlGraphicsManager::notifyResize(const int width, const int height) {
 	// event is processed after recreating the window at the new resolution.
 	int currentWidth, currentHeight;
 	getWindowSizeFromSdl(&currentWidth, &currentHeight);
-	uint scale;
+	float scale;
 	getDpiScalingFactor(&scale);
-	debug(3, "req: %d x %d  cur: %d x %d, scale: %d", width, height, currentWidth, currentHeight, scale);
+	debug(3, "req: %d x %d  cur: %d x %d, scale: %f", width, height, currentWidth, currentHeight, scale);
 
 	handleResize(currentWidth, currentHeight);
 
@@ -299,8 +305,8 @@ void OpenGLSdlGraphicsManager::notifyResize(const int width, const int height) {
 
 		// FIXME HACK. I don't like this at all, but macOS requires window size in LoDPI
 #ifdef __APPLE__
-		currentWidth /= scale;
-		currentHeight /= scale;
+		currentWidth = (int)(currentWidth / scale);
+		currentHeight = (int)(currentHeight / scale);
 #endif
 		// Reset maximized flag
 		_windowIsMaximized = false;
@@ -643,7 +649,7 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) {
 			getWindowSizeFromSdl(&windowWidth, &windowHeight);
 			// FIXME HACK. I don't like this at all, but macOS requires window size in LoDPI
 	#ifdef __APPLE__
-			uint scale;
+			float scale;
 			getDpiScalingFactor(&scale);
 			windowWidth /= scale;
 			windowHeight /= scale;
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.h b/backends/graphics/openglsdl/openglsdl-graphics.h
index a7dc7abff5..98fdd8b926 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.h
+++ b/backends/graphics/openglsdl/openglsdl-graphics.h
@@ -42,6 +42,8 @@ public:
 	virtual void initSize(uint w, uint h, const Graphics::PixelFormat *format) override;
 	virtual void updateScreen() override;
 
+	virtual float getHiDPIScreenFactor() const override;
+
 	// EventObserver API
 	virtual bool notifyEvent(const Common::Event &event) override;
 
diff --git a/backends/graphics/sdl/sdl-graphics.h b/backends/graphics/sdl/sdl-graphics.h
index acac7ffb74..ac6e81a10e 100644
--- a/backends/graphics/sdl/sdl-graphics.h
+++ b/backends/graphics/sdl/sdl-graphics.h
@@ -206,16 +206,16 @@ protected:
 	/**
 	 * Returns the scaling mode based on the display DPI
 	 */
-	void getDpiScalingFactor(uint *scale) const {
+	void getDpiScalingFactor(float *scale) const {
 		float dpi, defaultDpi, ratio;
 
 		getDisplayDpiFromSdl(&dpi, &defaultDpi);
 		debug(4, "dpi: %g default: %g", dpi, defaultDpi);
 		ratio = dpi / defaultDpi;
 		if (ratio >= 1.5f) {
-			*scale = 2;
+			*scale = 2.f;
 		} else {
-			*scale = 1;
+			*scale = 1.f;
 		}
 	}
 


Commit: 2649f022defaab86ee0ffb2660910995e11fbc15
    https://github.com/scummvm/scummvm/commit/2649f022defaab86ee0ffb2660910995e11fbc15
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-08-13T21:41:33+01:00

Commit Message:
IOS7: Implement getHiDPIScreenFactor

Changed paths:
    backends/platform/ios7/ios7_osys_main.h
    backends/platform/ios7/ios7_osys_video.mm


diff --git a/backends/platform/ios7/ios7_osys_main.h b/backends/platform/ios7/ios7_osys_main.h
index a9c1713e58..ba627c5509 100644
--- a/backends/platform/ios7/ios7_osys_main.h
+++ b/backends/platform/ios7/ios7_osys_main.h
@@ -146,6 +146,9 @@ public:
 #endif
 
 	virtual PaletteManager *getPaletteManager() override { return this; }
+
+	virtual float getHiDPIScreenFactor() const override;
+
 protected:
 	// PaletteManager API
 	virtual void setPalette(const byte *colors, uint start, uint num) override;
diff --git a/backends/platform/ios7/ios7_osys_video.mm b/backends/platform/ios7/ios7_osys_video.mm
index 4b4841b826..d304a249b9 100644
--- a/backends/platform/ios7/ios7_osys_video.mm
+++ b/backends/platform/ios7/ios7_osys_video.mm
@@ -119,6 +119,10 @@ static inline void execute_on_main_thread(void (^block)(void)) {
 	}
 }
 
+float OSystem_iOS7::getHiDPIScreenFactor() const {
+	return [UIScreen mainScreen].scale;
+}
+
 void OSystem_iOS7::initSize(uint width, uint height, const Graphics::PixelFormat *format) {
 	//printf("initSize(%u, %u, %p)\n", width, height, (const void *)format);
 


Commit: fe377775d6a29021e410a8034917859b11834c05
    https://github.com/scummvm/scummvm/commit/fe377775d6a29021e410a8034917859b11834c05
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-08-13T21:41:33+01:00

Commit Message:
ANDROID: Implement getHiDPIScreenFactor

This is a placeholder implementation that preserves the current
behaviour (asusmes a scaling of 2). But since the Android API
provides a way to get an accurare device-dependent scaling, this
should probably be used.

Changed paths:
    backends/platform/android/graphics.cpp
    backends/platform/android/graphics.h


diff --git a/backends/platform/android/graphics.cpp b/backends/platform/android/graphics.cpp
index d673dafd7f..5611e1dc3e 100644
--- a/backends/platform/android/graphics.cpp
+++ b/backends/platform/android/graphics.cpp
@@ -101,6 +101,17 @@ void AndroidGraphicsManager::displayMessageOnOSD(const Common::U32String &msg) {
 	JNI::displayMessageOnOSD(msg);
 }
 
+float AndroidGraphicsManager::getHiDPIScreenFactor() const {
+	// TODO: Use JNI to get DisplayMetrics.density, which according to the documentation
+	// seems to be what we want.
+	// "On a medium-density screen, DisplayMetrics.density equals 1.0; on a high-density
+	//  screen it equals 1.5; on an extra-high-density screen, it equals 2.0; and on a
+	//  low-density screen, it equals 0.75. This figure is the factor by which you should
+	//  multiply the dp units in order to get the actual pixel count for the current screen."
+
+	return 2.f;
+}
+
 bool AndroidGraphicsManager::loadVideoMode(uint requestedWidth, uint requestedHeight, const Graphics::PixelFormat &format) {
 	ENTER("%d, %d, %s", requestedWidth, requestedHeight, format.toString().c_str());
 
diff --git a/backends/platform/android/graphics.h b/backends/platform/android/graphics.h
index dcfe880111..7d35e98766 100644
--- a/backends/platform/android/graphics.h
+++ b/backends/platform/android/graphics.h
@@ -41,6 +41,8 @@ public:
 	bool notifyMousePosition(Common::Point &mouse);
 	Common::Point getMousePosition() { return Common::Point(_cursorX, _cursorY); }
 
+	virtual float getHiDPIScreenFactor() const override;
+
 protected:
 	virtual void setSystemMousePosition(const int x, const int y) override {}
 


Commit: 4ad54446f8948e5fd67cda9bfafdf0361532d116
    https://github.com/scummvm/scummvm/commit/4ad54446f8948e5fd67cda9bfafdf0361532d116
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-08-13T21:41:33+01:00

Commit Message:
SDL: Get accurate HiDPI scaling on macOS

This fixes incorrect scaling on some non-retina screens that were
detected as HiDPI.

Changed paths:
  A backends/graphics/sdl/sdl-graphics-osx.mm
    backends/graphics/sdl/sdl-graphics.h
    backends/module.mk


diff --git a/backends/graphics/sdl/sdl-graphics-osx.mm b/backends/graphics/sdl/sdl-graphics-osx.mm
new file mode 100644
index 0000000000..780d84830a
--- /dev/null
+++ b/backends/graphics/sdl/sdl-graphics-osx.mm
@@ -0,0 +1,45 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+// Disable symbol overrides so that we can use system headers.
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
+#include "SDL_syswm.h"
+#include "backends/graphics/sdl/sdl-graphics.h"
+#include <AppKit/NSWindow.h>
+
+bool SdlGraphicsManager::getMacWindowScaling(float *scale) const {
+#if SDL_VERSION_ATLEAST(2, 0, 0) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
+	SDL_SysWMinfo wmInfo;
+	SDL_VERSION(&wmInfo.version); /* initialize info structure with SDL version info */
+	if (!SDL_GetWindowWMInfo(_window->getSDLWindow(), &wmInfo))
+		return false;
+
+	NSWindow *nswindow = wmInfo.info.cocoa.window;
+	if (!nswindow)
+		return false;
+	*scale = [nswindow backingScaleFactor];
+	return true;
+#else
+	return false;
+#endif
+}
diff --git a/backends/graphics/sdl/sdl-graphics.h b/backends/graphics/sdl/sdl-graphics.h
index ac6e81a10e..d4700a7363 100644
--- a/backends/graphics/sdl/sdl-graphics.h
+++ b/backends/graphics/sdl/sdl-graphics.h
@@ -207,6 +207,13 @@ protected:
 	 * Returns the scaling mode based on the display DPI
 	 */
 	void getDpiScalingFactor(float *scale) const {
+#ifdef MACOSX
+		if (getMacWindowScaling(scale)) {
+			debug(4, "NSWindow HiDPI scaling: %f", *scale);
+			return;
+		}
+#endif
+
 		float dpi, defaultDpi, ratio;
 
 		getDisplayDpiFromSdl(&dpi, &defaultDpi);
@@ -245,6 +252,10 @@ protected:
 
 private:
 	void toggleFullScreen();
+
+#ifdef MACOSX
+	bool getMacWindowScaling(float *) const;
+#endif
 };
 
 #endif
diff --git a/backends/module.mk b/backends/module.mk
index 02082f30c7..c26cfdb8e2 100644
--- a/backends/module.mk
+++ b/backends/module.mk
@@ -149,6 +149,11 @@ MODULE_OBJS += \
 	plugins/sdl/sdl-provider.o \
 	timer/sdl/sdl-timer.o
 
+ifdef MACOSX
+MODULE_OBJS += \
+	graphics/sdl/sdl-graphics-osx.o
+endif
+
 # SDL 2 removed audio CD support
 ifndef USE_SDL2
 MODULE_OBJS += \


Commit: abf782c670f62d3b74ee487b8334151706762464
    https://github.com/scummvm/scummvm/commit/abf782c670f62d3b74ee487b8334151706762464
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-08-13T21:41:33+01:00

Commit Message:
COMMON: Remove kFeatureHiDPI from OSystem and use getHiDPIScreenFactor instead

Changed paths:
    backends/graphics/openglsdl/openglsdl-graphics.cpp
    backends/graphics/sdl/sdl-graphics.cpp
    backends/platform/android/android.cpp
    backends/platform/ios7/ios7_osys_main.cpp
    common/system.h
    gui/gui-manager.cpp


diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index 31d2d2881e..d0da96c0a1 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -243,8 +243,6 @@ bool OpenGLSdlGraphicsManager::getFeatureState(OSystem::Feature f) const {
 			return _wantsFullScreen;
 		}
 #endif
-	case OSystem::kFeatureHiDPI:
-		return getGraphicsModeScale(0) == 2;
 
 	default:
 		return OpenGLGraphicsManager::getFeatureState(f);
diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp
index 44464242f6..f6870a3c47 100644
--- a/backends/graphics/sdl/sdl-graphics.cpp
+++ b/backends/graphics/sdl/sdl-graphics.cpp
@@ -228,9 +228,9 @@ bool SdlGraphicsManager::notifyMousePosition(Common::Point &mouse) {
 
 	int showCursor = SDL_DISABLE;
 	// DPI aware scaling to mouse position
-	uint scale = getFeatureState(BaseBackend::kFeatureHiDPI) ? 2 : 1;
-	mouse.x *= scale;
-	mouse.y *= scale;
+	float scale = getHiDPIScreenFactor();
+	mouse.x = (int)(mouse.x * scale + 0.5f);
+	mouse.y = (int)(mouse.y * scale + 0.5f);
 	bool valid = true;
 	if (_activeArea.drawRect.contains(mouse)) {
 		_cursorLastInActiveArea = true;
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index 6f471fffb4..950e666e54 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -452,8 +452,7 @@ bool OSystem_Android::hasFeature(Feature f) {
 		return false;
 	if (f == kFeatureVirtualKeyboard ||
 			f == kFeatureOpenUrl ||
-			f == kFeatureClipboardSupport ||
-	                f == OSystem::kFeatureHiDPI) {
+			f == kFeatureClipboardSupport) {
 		return true;
 	}
 	return ModularGraphicsBackend::hasFeature(f);
diff --git a/backends/platform/ios7/ios7_osys_main.cpp b/backends/platform/ios7/ios7_osys_main.cpp
index 016db083a6..ff275f3549 100644
--- a/backends/platform/ios7/ios7_osys_main.cpp
+++ b/backends/platform/ios7/ios7_osys_main.cpp
@@ -199,8 +199,6 @@ bool OSystem_iOS7::getFeatureState(Feature f) {
 		return _videoContext->asprectRatioCorrection;
 	case kFeatureVirtualKeyboard:
 		return isKeyboardShown();
-	case kFeatureHiDPI:
-		return true;
 
 	default:
 		return false;
diff --git a/common/system.h b/common/system.h
index e040ba1a64..bbbf4378a8 100644
--- a/common/system.h
+++ b/common/system.h
@@ -362,11 +362,6 @@ public:
 		 */
 		kFeatureFilteringMode,
 
-		/**
-		 * Indicates that GUI runs in HiDPI mode
-		 */
-		kFeatureHiDPI,
-
 		/**
 		 * Indicate if stretch modes are supported by the backend.
 		 */
diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp
index a518f83ea3..3325005771 100644
--- a/gui/gui-manager.cpp
+++ b/gui/gui-manager.cpp
@@ -109,7 +109,7 @@ GuiManager::~GuiManager() {
 void GuiManager::computeScaleFactor() {
 	uint16 w = g_system->getOverlayWidth();
 	uint16 h = g_system->getOverlayHeight();
-	uint scale = g_system->getFeatureState(OSystem::kFeatureHiDPI) ? 2 : 1;
+	float scale = g_system->getHiDPIScreenFactor();
 
 	_baseHeight = 0;	// Clean up from previous iteration
 


Commit: ad31dfc8d5e35e7449587ccca4d81835beb16872
    https://github.com/scummvm/scummvm/commit/ad31dfc8d5e35e7449587ccca4d81835beb16872
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-08-13T21:41:33+01:00

Commit Message:
GUI: Handle the GUI Scale option as a scaling rather than base resolution

Now that we can get an accurate HiDPI screen scaling from OSystem,
defaulting to using that seems to make sense. But we may still want
to use a slightly different scaling. The GUI scale option allows
that by providing a scaling (in percentage) with which to multiply
the HiDPI scaling.

I think it works better than a base resolution as it avoids having
the GUI getting bigger or smaller when we resize the window.

This commit keeps a popup widget, but this could be changed with
 a slider if we want more fine grain control.

Changed paths:
    gui/gui-manager.cpp
    gui/options.cpp


diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp
index 3325005771..d1808e48db 100644
--- a/gui/gui-manager.cpp
+++ b/gui/gui-manager.cpp
@@ -109,33 +109,12 @@ GuiManager::~GuiManager() {
 void GuiManager::computeScaleFactor() {
 	uint16 w = g_system->getOverlayWidth();
 	uint16 h = g_system->getOverlayHeight();
-	float scale = g_system->getHiDPIScreenFactor();
 
-	_baseHeight = 0;	// Clean up from previous iteration
-
-	if (ConfMan.hasKey("gui_base")) {
-		_baseHeight = ConfMan.getInt("gui_base");
-
-		if (h < _baseHeight)
-			_baseHeight = 0; // Switch to auto for lower resolutions
-	}
-
-	if (_baseHeight == 0) {	// auto
-		if (h < 240 * scale) {	// 320 x 200
-			_baseHeight = MIN<int16>(200, h);
-		} else if (h < 400 * scale) {	// 320 x 240
-			_baseHeight = 240;
-		} else if (h < 480 * scale) {	// 640 x 400
-			_baseHeight = 400;
-		} else if (h < 720 * scale) {	// 640 x 480
-			_baseHeight = 480;
-		} else {				// 960 x 720
-			_baseHeight = 720;
-		}
-	}
-
-	_scaleFactor = (float)h / (float)_baseHeight;
+	_scaleFactor = g_system->getHiDPIScreenFactor();
+	if (ConfMan.hasKey("gui_scale"))
+		_scaleFactor *= ConfMan.getInt("gui_scale") / 100.f;
 
+	_baseHeight = (int16)((float)h / _scaleFactor);
 	_baseWidth = (int16)((float)w / _scaleFactor);
 
 	if (_theme)
diff --git a/gui/options.cpp b/gui/options.cpp
index 27c3a2fa06..2dd7cc7628 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -134,8 +134,8 @@ static const char *savePeriodLabels[] = { _s("Never"), _s("Every 5 mins"), _s("E
 static const int savePeriodValues[] = { 0, 5 * 60, 10 * 60, 15 * 60, 30 * 60, -1 };
 
 static const char *guiBaseLabels[] = {
-	// I18N: Automatic GUI scaling
-	_s("Auto"),
+	// I18N: Very large GUI scale
+	_s("Very large"),
 	// I18N: Large GUI scale
 	_s("Large"),
 	// I18N: Medium GUI scale
@@ -144,7 +144,7 @@ static const char *guiBaseLabels[] = {
 	_s("Small"),
 	nullptr
 };
-static const int guiBaseValues[] = { 0, 240, 480, 720, -1 };
+static const int guiBaseValues[] = { 150, 125, 100, 75, -1 };
 
 // The keyboard mouse speed values range from 0 to 7 and correspond to speeds shown in the label
 // "10" (value 3) is the default speed corresponding to the speed before introduction of this control
@@ -2134,8 +2134,8 @@ void GlobalOptionsDialog::build() {
 #endif
 
 	// Misc Tab
-	_guiBasePopUp->setSelected(1);
-	int value = ConfMan.getInt("gui_base");
+	_guiBasePopUp->setSelected(2);
+	int value = ConfMan.getInt("gui_scale");
 	for (int i = 0; guiBaseLabels[i]; i++) {
 		if (value == guiBaseValues[i])
 			_guiBasePopUp->setSelected(i);
@@ -2517,9 +2517,9 @@ void GlobalOptionsDialog::apply() {
 #endif // USE_SDL_NET
 #endif // USE_CLOUD
 
-	int oldGuiBase = ConfMan.getInt("gui_base");
-	ConfMan.setInt("gui_base", _guiBasePopUp->getSelectedTag(), _domain);
-	if (oldGuiBase != (int)_guiBasePopUp->getSelectedTag())
+	int oldGuiScale = ConfMan.getInt("gui_scale");
+	ConfMan.setInt("gui_scale", _guiBasePopUp->getSelectedTag(), _domain);
+	if (oldGuiScale != (int)_guiBasePopUp->getSelectedTag())
 		g_gui.computeScaleFactor();
 
 	ConfMan.setInt("autosave_period", _autosavePeriodPopUp->getSelectedTag(), _domain);


Commit: 5caacb763b7071339a7a2d4b4cd2d902129cd222
    https://github.com/scummvm/scummvm/commit/5caacb763b7071339a7a2d4b4cd2d902129cd222
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-08-13T21:41:33+01:00

Commit Message:
SDL: Change signature of getDpiScalingFactor to return the result

Changed paths:
    backends/graphics/openglsdl/openglsdl-graphics.cpp
    backends/graphics/sdl/sdl-graphics-osx.mm
    backends/graphics/sdl/sdl-graphics.h


diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index d0da96c0a1..b7b5726172 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -250,9 +250,7 @@ bool OpenGLSdlGraphicsManager::getFeatureState(OSystem::Feature f) const {
 }
 
 float OpenGLSdlGraphicsManager::getHiDPIScreenFactor() const {
-	float scale;
-	getDpiScalingFactor(&scale);
-	return scale;
+	return getDpiScalingFactor();
 }
 
 void OpenGLSdlGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFormat *format) {
@@ -292,8 +290,7 @@ void OpenGLSdlGraphicsManager::notifyResize(const int width, const int height) {
 	// event is processed after recreating the window at the new resolution.
 	int currentWidth, currentHeight;
 	getWindowSizeFromSdl(&currentWidth, &currentHeight);
-	float scale;
-	getDpiScalingFactor(&scale);
+	float scale = getDpiScalingFactor();
 	debug(3, "req: %d x %d  cur: %d x %d, scale: %f", width, height, currentWidth, currentHeight, scale);
 
 	handleResize(currentWidth, currentHeight);
@@ -647,8 +644,7 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) {
 			getWindowSizeFromSdl(&windowWidth, &windowHeight);
 			// FIXME HACK. I don't like this at all, but macOS requires window size in LoDPI
 	#ifdef __APPLE__
-			float scale;
-			getDpiScalingFactor(&scale);
+			float scale = getDpiScalingFactor();
 			windowWidth /= scale;
 			windowHeight /= scale;
 	#endif
diff --git a/backends/graphics/sdl/sdl-graphics-osx.mm b/backends/graphics/sdl/sdl-graphics-osx.mm
index 780d84830a..baac2238e3 100644
--- a/backends/graphics/sdl/sdl-graphics-osx.mm
+++ b/backends/graphics/sdl/sdl-graphics-osx.mm
@@ -27,7 +27,7 @@
 #include "backends/graphics/sdl/sdl-graphics.h"
 #include <AppKit/NSWindow.h>
 
-bool SdlGraphicsManager::getMacWindowScaling(float *scale) const {
+bool SdlGraphicsManager::getMacWindowScaling(float &scale) const {
 #if SDL_VERSION_ATLEAST(2, 0, 0) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
 	SDL_SysWMinfo wmInfo;
 	SDL_VERSION(&wmInfo.version); /* initialize info structure with SDL version info */
@@ -37,7 +37,7 @@ bool SdlGraphicsManager::getMacWindowScaling(float *scale) const {
 	NSWindow *nswindow = wmInfo.info.cocoa.window;
 	if (!nswindow)
 		return false;
-	*scale = [nswindow backingScaleFactor];
+	scale = [nswindow backingScaleFactor];
 	return true;
 #else
 	return false;
diff --git a/backends/graphics/sdl/sdl-graphics.h b/backends/graphics/sdl/sdl-graphics.h
index d4700a7363..1df94ad534 100644
--- a/backends/graphics/sdl/sdl-graphics.h
+++ b/backends/graphics/sdl/sdl-graphics.h
@@ -206,24 +206,23 @@ protected:
 	/**
 	 * Returns the scaling mode based on the display DPI
 	 */
-	void getDpiScalingFactor(float *scale) const {
+	float getDpiScalingFactor() const {
 #ifdef MACOSX
+		float scale;
 		if (getMacWindowScaling(scale)) {
-			debug(4, "NSWindow HiDPI scaling: %f", *scale);
-			return;
+			debug(4, "NSWindow HiDPI scaling: %f", scale);
+			return scale;
 		}
 #endif
 
-		float dpi, defaultDpi, ratio;
-
+		float dpi, defaultDpi;
 		getDisplayDpiFromSdl(&dpi, &defaultDpi);
 		debug(4, "dpi: %g default: %g", dpi, defaultDpi);
-		ratio = dpi / defaultDpi;
-		if (ratio >= 1.5f) {
-			*scale = 2.f;
-		} else {
-			*scale = 1.f;
-		}
+		float ratio = dpi / defaultDpi;
+		if (ratio >= 1.5f)
+			return 2.f;
+		else
+			return 1.f;
 	}
 
 	virtual void setSystemMousePosition(const int x, const int y) override;
@@ -254,7 +253,7 @@ private:
 	void toggleFullScreen();
 
 #ifdef MACOSX
-	bool getMacWindowScaling(float *) const;
+	bool getMacWindowScaling(float &) const;
 #endif
 };
 




More information about the Scummvm-git-logs mailing list