summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qplatformscreen.cpp
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@theqtcompany.com>2015-05-26 22:22:37 +0200
committerPaul Olav Tvete <paul.tvete@theqtcompany.com>2015-05-29 15:41:38 +0000
commitf9b1596fe1aeacf4f3d977c32e74b7ad585d3d3e (patch)
tree82c04fce2ef3a56540ebb6e06df5b29a4f1fa71b /src/gui/kernel/qplatformscreen.cpp
parentc2d5ecf8766d3da70b17348e92cda31b00e204a7 (diff)
Refactor QHighDpiScaling internals and usage
Overall goal is to simplify, separate concerns, and improve cross-platform-ness and testability. QT_SCALE_FACTOR is now a pure cross-platform global scale factor setter has no "auto". "auto" requires input from the platform plugin via QPlatformScreen:: pixelDensity() and gets a separate environment variable: QT_AUTO_SCREEN_SCALE_FACTOR The effective scale factor (aka devicePixelRatio) is now computed as the product of the global, screen, and window scale factors. This matches how devicePixelRatio is computed in general (the window system devicePixelRatio is also a factor), and makes QT_SCALE_FACTOR work consistently regardless if there is a window scale factor set or not. This also means we can remove the if/else casing from the nativePixels conversion functions. Add QHighDpiScaling initializer which reads the environment variables and sets the "active" variables. Call it during QGuiApplication construction, before the platform plugin is created Add per-screen scale factor setting capability to the manual test. This makes it possible to test this logic on all platforms. The command line argument is --screen-scale-factor. Change-Id: I054337cbae37a01cdd731d26d9cb628fcecdb652 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Diffstat (limited to 'src/gui/kernel/qplatformscreen.cpp')
-rw-r--r--src/gui/kernel/qplatformscreen.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp
index bda7280e81..ccb0452629 100644
--- a/src/gui/kernel/qplatformscreen.cpp
+++ b/src/gui/kernel/qplatformscreen.cpp
@@ -159,9 +159,11 @@ QDpi QPlatformScreen::logicalDpi() const
/*!
Reimplement this function in subclass to return the device pixel ratio
for the screen. This is the ratio between physical pixels and the
- device-independent pixels of the windowing system.
+ device-independent pixels of the windowing system. The default
+ implementation returns 1.0.
- \sa QPlatformWindow::devicePixelRatio();
+ \sa QPlatformWindow::devicePixelRatio()
+ \sa QPlatformScreen::pixelDensity()
*/
qreal QPlatformScreen::devicePixelRatio() const
{
@@ -171,7 +173,17 @@ qreal QPlatformScreen::devicePixelRatio() const
/*!
Reimplement this function in subclass to return the pixel density of the
screen. This is the scale factor needed to make a low-dpi application
- usable on this screen. The default implementation returns 1.0.
+ usable on this screen. The default implementation returns 1.0. In
+ addition the platform integration must return true for the PlatformScreenPixelDensity
+ Capability for this value to have an effect.
+
+ Returning something else than 1 from this function causes Qt to
+ apply the scale factor to the application's coordinate system.
+ This is different from devicePixelRatio, which reports a scale
+ factor already applied by the windowing system. A platform plugin
+ typically implements one (or none) of these two functions.
+
+ \sa QPlatformWindow::devicePixelRatio()
*/
qreal QPlatformScreen::pixelDensity() const
{