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

sev- sev at scummvm.org
Mon Apr 12 16:38:49 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:
8fba77eefa BACKENDS: OPENGLSDL: Always use drawable size when resizing window
d6ba073055 BACKENDS: OPENGLSDL: Only scale mouse cursor on high-DPI platforms


Commit: 8fba77eefa96a274a3fc9b8cbb5d9f395db0316d
    https://github.com/scummvm/scummvm/commit/8fba77eefa96a274a3fc9b8cbb5d9f395db0316d
Author: SupSuper (supsuper at gmail.com)
Date: 2021-04-12T18:38:45+02:00

Commit Message:
BACKENDS: OPENGLSDL: Always use drawable size when resizing window

This corrects situations in SDL2 where the window size is not
the same as the drawable size, leading to incorrect rendering.

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 37be907289..496b4a6335 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -289,10 +289,10 @@ void OpenGLSdlGraphicsManager::updateScreen() {
 void OpenGLSdlGraphicsManager::notifyVideoExpose() {
 }
 
-void OpenGLSdlGraphicsManager::notifyResize(const int w, const int h) {
+void OpenGLSdlGraphicsManager::notifyResize(const int width, const int height) {
 #if SDL_VERSION_ATLEAST(2, 0, 0)
-	// We sometime get outdated resize events from SDL2. So check that the size we get
-	// is the actual current window size. If not ignore the resize.
+	// We sometime get inaccurate resize events from SDL2. So use the real drawable size
+	// we get from SDL2 and ignore the event data.
 	// The issue for example occurs when switching from fullscreen to windowed mode or
 	// when switching between different fullscreen resolutions because SDL_DestroyWindow
 	// for a fullscreen window that doesn't have the SDL_WINDOW_FULLSCREEN_DESKTOP flag
@@ -302,20 +302,16 @@ void OpenGLSdlGraphicsManager::notifyResize(const int w, const int h) {
 	getWindowSizeFromSdl(&currentWidth, &currentHeight);
 	uint scale;
 	getDpiScalingFactor(&scale);
-	int width = w * scale;
-	int height = h * scale;
 	debug(3, "req: %d x %d  cur: %d x %d, scale: %d", width, height, currentWidth, currentHeight, scale);
-	if (width != currentWidth || height != currentHeight)
-		return;
 
-	handleResize(width, height);
+	handleResize(currentWidth, currentHeight);
 #else
 	if (!_ignoreResizeEvents && _hwScreen && !(_hwScreen->flags & SDL_FULLSCREEN)) {
 		// We save that we handled a resize event here. We need to know this
 		// so we do not overwrite the users requested window size whenever we
 		// switch aspect ratio or similar.
 		_gotResize = true;
-		if (!setupMode(w, h)) {
+		if (!setupMode(width, height)) {
 			warning("OpenGLSdlGraphicsManager::notifyResize: Resize failed ('%s')", SDL_GetError());
 			g_system->quit();
 		}


Commit: d6ba073055d190aecf7a8ca14aeafe12c059f678
    https://github.com/scummvm/scummvm/commit/d6ba073055d190aecf7a8ca14aeafe12c059f678
Author: SupSuper (supsuper at gmail.com)
Date: 2021-04-12T18:38:45+02:00

Commit Message:
BACKENDS: OPENGLSDL: Only scale mouse cursor on high-DPI platforms

Some platforms send raw coordinates, others send scaled coordinates.
We try to determine this by comparing the window size and drawable size.

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


diff --git a/backends/graphics/openglsdl/openglsdl-graphics.h b/backends/graphics/openglsdl/openglsdl-graphics.h
index 0b4bad1438..87046ff8ea 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.h
+++ b/backends/graphics/openglsdl/openglsdl-graphics.h
@@ -61,9 +61,16 @@ protected:
 	virtual bool saveScreenshot(const Common::String &filename) const override;
 
 	virtual int getGraphicsModeScale(int mode) const override {
-		uint scale;
-		getDpiScalingFactor(&scale);
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+		int windowWidth, windowHeight;
+		SDL_GetWindowSize(_window->getSDLWindow(), &windowWidth, &windowHeight);
+		int realWidth, realHeight;
+		SDL_GL_GetDrawableSize(_window->getSDLWindow(), &realWidth, &realHeight);
+		int scale = realWidth / windowWidth;
 		return scale;
+#else
+		return 1;
+#endif
 	}
 
 private:
diff --git a/backends/graphics/sdl/sdl-graphics.h b/backends/graphics/sdl/sdl-graphics.h
index c845cf494a..4059afc564 100644
--- a/backends/graphics/sdl/sdl-graphics.h
+++ b/backends/graphics/sdl/sdl-graphics.h
@@ -164,7 +164,6 @@ protected:
 #if SDL_VERSION_ATLEAST(2, 0, 0)
 		assert(_window);
 		SDL_GL_GetDrawableSize(_window->getSDLWindow(), width, height);
-		// SDL_GetWindowSize(_window->getSDLWindow(), width, height);
 #else
 		assert(_hwScreen);
 




More information about the Scummvm-git-logs mailing list