[Scummvm-git-logs] scummvm master -> dc7a09fdd1a4f9e01b1719f94f62b73b114c106d

sev- sev at scummvm.org
Fri Aug 20 20:10:29 UTC 2021


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

Summary:
dc7a09fdd1 SDL: Cleanup HiDPI macOS hacks


Commit: dc7a09fdd1a4f9e01b1719f94f62b73b114c106d
    https://github.com/scummvm/scummvm/commit/dc7a09fdd1a4f9e01b1719f94f62b73b114c106d
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-08-20T22:10:26+02:00

Commit Message:
SDL: Cleanup HiDPI macOS hacks

The SDL library handles HiDPI differently depending on the system.
On some systems, such as macOS, the drawable area and the SDL window
have a different size (the window is on low-dpi size) while on
other systems such as Windows they have the same size. Because of
that we sometimes need to scale sizes or coordinates between the
two, and sometimes we don't.

This was handled in two different ways. This commit change the code
to handle it consistently everywhere, and also should be more future
proof should SDL change the way it handles HiDPI in the future (as
we now query the size from SDL itself to find out if the scaling is
needed).

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


diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index cb30bc0ca8..870892d666 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -290,19 +290,15 @@ 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 = _window->getDpiScalingFactor();
-	debug(3, "req: %d x %d  cur: %d x %d, scale: %f", width, height, currentWidth, currentHeight, scale);
+	float dpiScale = _window->getSdlDpiScalingFactor();
+	debug(3, "req: %d x %d  cur: %d x %d, scale: %f", width, height, currentWidth, currentHeight, dpiScale);
 
 	handleResize(currentWidth, currentHeight);
 
 	// Remember window size in windowed mode
 	if (!_wantsFullScreen) {
-
-		// FIXME HACK. I don't like this at all, but macOS requires window size in LoDPI
-#ifdef __APPLE__
-		currentWidth = (int)(currentWidth / scale);
-		currentHeight = (int)(currentHeight / scale);
-#endif
+		currentWidth = (int)(currentWidth / dpiScale + 0.5f);
+		currentHeight = (int)(currentHeight / dpiScale + 0.5f);
 
 		// Check if the ScummVM window is maximized and store the current
 		// window dimensions.
@@ -654,12 +650,11 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) {
 			// window. Then we apply the direction change.
 			int windowWidth = 0, windowHeight = 0;
 			getWindowSizeFromSdl(&windowWidth, &windowHeight);
-			// FIXME HACK. I don't like this at all, but macOS requires window size in LoDPI
-	#ifdef __APPLE__
-			float scale = _window->getDpiScalingFactor();
-			windowWidth /= scale;
-			windowHeight /= scale;
-	#endif
+
+			float dpiScale = _window->getSdlDpiScalingFactor();
+			windowWidth = (int)(windowWidth / dpiScale + 0.5f);
+			windowHeight = (int)(windowHeight / dpiScale + 0.5f);
+
 			if (direction > 0)
 				_graphicsScale = MAX<int>(windowWidth / _lastRequestedWidth, windowHeight / _lastRequestedHeight);
 			else




More information about the Scummvm-git-logs mailing list