From 6d8462674f765dfbcc357ff50c57f5459aa1d64c Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Mon, 12 Jul 2021 13:36:11 +0100 Subject: [PATCH] COMMON: Add getHiDPIScreenFactor to OSystem --- backends/graphics/graphics.h | 1 + backends/modular-backend.cpp | 4 ++++ backends/modular-backend.h | 2 ++ common/system.h | 6 ++++++ 4 files changed, 13 insertions(+) diff --git a/backends/graphics/graphics.h b/backends/graphics/graphics.h index 3b56f5138d6..3533a8bafee 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 21992de2d0a..7950018d574 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 0bde48e1893..2318bfc0eb4 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 4ef6825d097..e040ba1a648 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. *