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).
This commit is contained in:
parent
797ca3568d
commit
dc7a09fdd1
1 changed files with 9 additions and 14 deletions
|
@ -290,19 +290,15 @@ void OpenGLSdlGraphicsManager::notifyResize(const int width, const int height) {
|
||||||
// event is processed after recreating the window at the new resolution.
|
// event is processed after recreating the window at the new resolution.
|
||||||
int currentWidth, currentHeight;
|
int currentWidth, currentHeight;
|
||||||
getWindowSizeFromSdl(¤tWidth, ¤tHeight);
|
getWindowSizeFromSdl(¤tWidth, ¤tHeight);
|
||||||
float scale = _window->getDpiScalingFactor();
|
float dpiScale = _window->getSdlDpiScalingFactor();
|
||||||
debug(3, "req: %d x %d cur: %d x %d, scale: %f", width, height, currentWidth, currentHeight, scale);
|
debug(3, "req: %d x %d cur: %d x %d, scale: %f", width, height, currentWidth, currentHeight, dpiScale);
|
||||||
|
|
||||||
handleResize(currentWidth, currentHeight);
|
handleResize(currentWidth, currentHeight);
|
||||||
|
|
||||||
// Remember window size in windowed mode
|
// Remember window size in windowed mode
|
||||||
if (!_wantsFullScreen) {
|
if (!_wantsFullScreen) {
|
||||||
|
currentWidth = (int)(currentWidth / dpiScale + 0.5f);
|
||||||
// FIXME HACK. I don't like this at all, but macOS requires window size in LoDPI
|
currentHeight = (int)(currentHeight / dpiScale + 0.5f);
|
||||||
#ifdef __APPLE__
|
|
||||||
currentWidth = (int)(currentWidth / scale);
|
|
||||||
currentHeight = (int)(currentHeight / scale);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Check if the ScummVM window is maximized and store the current
|
// Check if the ScummVM window is maximized and store the current
|
||||||
// window dimensions.
|
// window dimensions.
|
||||||
|
@ -654,12 +650,11 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) {
|
||||||
// window. Then we apply the direction change.
|
// window. Then we apply the direction change.
|
||||||
int windowWidth = 0, windowHeight = 0;
|
int windowWidth = 0, windowHeight = 0;
|
||||||
getWindowSizeFromSdl(&windowWidth, &windowHeight);
|
getWindowSizeFromSdl(&windowWidth, &windowHeight);
|
||||||
// FIXME HACK. I don't like this at all, but macOS requires window size in LoDPI
|
|
||||||
#ifdef __APPLE__
|
float dpiScale = _window->getSdlDpiScalingFactor();
|
||||||
float scale = _window->getDpiScalingFactor();
|
windowWidth = (int)(windowWidth / dpiScale + 0.5f);
|
||||||
windowWidth /= scale;
|
windowHeight = (int)(windowHeight / dpiScale + 0.5f);
|
||||||
windowHeight /= scale;
|
|
||||||
#endif
|
|
||||||
if (direction > 0)
|
if (direction > 0)
|
||||||
_graphicsScale = MAX<int>(windowWidth / _lastRequestedWidth, windowHeight / _lastRequestedHeight);
|
_graphicsScale = MAX<int>(windowWidth / _lastRequestedWidth, windowHeight / _lastRequestedHeight);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue