aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics/opengl
diff options
context:
space:
mode:
authorCameron Cawley2019-11-01 11:39:46 +0000
committerAntoniou Athanasios2019-11-01 13:39:46 +0200
commit177d709909808313eee720ce76465cf99f909c5e (patch)
tree6d11f166342ddea46deb1634b106d010b4ab5181 /backends/graphics/opengl
parent5d0206b9c297837fddb038601bdfb42b0fcb8016 (diff)
downloadscummvm-rg350-177d709909808313eee720ce76465cf99f909c5e.tar.gz
scummvm-rg350-177d709909808313eee720ce76465cf99f909c5e.tar.bz2
scummvm-rg350-177d709909808313eee720ce76465cf99f909c5e.zip
OPENGL: Implement high DPI support on Android (#1895)
* OPENGL: Implement high DPI support on Android * PSP2: Fix build
Diffstat (limited to 'backends/graphics/opengl')
-rw-r--r--backends/graphics/opengl/opengl-graphics.cpp18
-rw-r--r--backends/graphics/opengl/opengl-graphics.h2
2 files changed, 17 insertions, 3 deletions
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index 06a0109476..9d11925613 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -909,7 +909,7 @@ void OpenGLGraphicsManager::grabPalette(byte *colors, uint start, uint num) cons
memcpy(colors, _gamePalette + start * 3, num * 3);
}
-void OpenGLGraphicsManager::handleResizeImpl(const int width, const int height) {
+void OpenGLGraphicsManager::handleResizeImpl(const int width, const int height, const int xdpi, const int ydpi) {
// Setup backbuffer size.
_backBuffer.setDimensions(width, height);
@@ -942,6 +942,10 @@ void OpenGLGraphicsManager::handleResizeImpl(const int width, const int height)
overlayWidth = MAX<uint>(overlayWidth, 256);
overlayHeight = MAX<uint>(overlayHeight, 200);
+ // HACK: Reduce the size of the overlay on high DPI screens.
+ overlayWidth = fracToInt(overlayWidth * (intToFrac(90) / xdpi));
+ overlayHeight = fracToInt(overlayHeight * (intToFrac(90) / ydpi));
+
if (!_overlay || _overlay->getFormat() != _defaultFormatAlpha) {
delete _overlay;
_overlay = nullptr;
@@ -1008,7 +1012,7 @@ void OpenGLGraphicsManager::notifyContextCreate(const Graphics::PixelFormat &def
// Refresh the output screen dimensions if some are set up.
if (_windowWidth != 0 && _windowHeight != 0) {
- handleResize(_windowWidth, _windowHeight);
+ handleResize(_windowWidth, _windowHeight, _xdpi, _ydpi);
}
// TODO: Should we try to convert textures into one of those formats if
@@ -1275,6 +1279,16 @@ void OpenGLGraphicsManager::recalculateCursorScaling() {
_cursorHotspotYScaled = fracToInt(_cursorHotspotYScaled * screenScaleFactorY);
_cursorHeightScaled = fracToInt(_cursorHeightScaled * screenScaleFactorY);
+ } else {
+ const frac_t screenScaleFactorX = intToFrac(90) / _xdpi;
+ const frac_t screenScaleFactorY = intToFrac(90) / _ydpi;
+
+ // FIXME: Replace this with integer maths
+ _cursorHotspotXScaled /= fracToDouble(screenScaleFactorX);
+ _cursorWidthScaled /= fracToDouble(screenScaleFactorX);
+
+ _cursorHotspotYScaled /= fracToDouble(screenScaleFactorY);
+ _cursorHeightScaled /= fracToDouble(screenScaleFactorY);
}
}
diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h
index f88315bf30..322f1d8017 100644
--- a/backends/graphics/opengl/opengl-graphics.h
+++ b/backends/graphics/opengl/opengl-graphics.h
@@ -309,7 +309,7 @@ protected:
virtual bool gameNeedsAspectRatioCorrection() const override;
virtual void recalculateDisplayAreas() override;
- virtual void handleResizeImpl(const int width, const int height) override;
+ virtual void handleResizeImpl(const int width, const int height, const int xdpi, const int ydpi) override;
/**
* The default pixel format of the backend.