summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel
diff options
context:
space:
mode:
authorMorten Sørvig <morten.sorvig@qt.io>2022-06-09 12:48:17 +0200
committerMorten Johan Sørvig <morten.sorvig@qt.io>2022-06-14 19:16:35 +0000
commit79bead6c3b507331614dcc3c789e18438bc10395 (patch)
tree183d60b61388f1b2813d50608e948b00ffa662cd /src/widgets/kernel
parentd38118c80828eecb3c0192404249c1fad5660792 (diff)
Add support for painting at integer DPR with downscale
Enable by setting QT_WIDGETS_HIGHDPI_DOWNSCALE=1 and QT_WIDGETS_RHI=1. This will make the backing store and painter operate at the next highest integer DPR in cases where QWindow::devicePixelRatio() returns a fractional value. The backing store image will then be downscaled to the target DPR at flush time, using the RHI flush pipeline. [ChangeLog][QWidgets] Added experimental support for always painting at an integer device pixel ratio (rounding the DPR up if necessary), followed by a downscale to the target DPR.Enable by setting QT_WIDGETS_HIGHDPI_DOWNSCALE=1 and QT_WIDGETS_RHI=1. Pick-to: 6.4 Task-number: QTBUG-86344 Change-Id: Id5b834a0e3499818b0b656161f5e0c38a6caa340 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r--src/widgets/kernel/qwidget.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 01a8905c79..9c1cec5d8d 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -12698,6 +12698,17 @@ int QWidget::metric(PaintDeviceMetric m) const
return QPaintDevice::metric(m);
}
+ auto resolveDevicePixelRatio = [this, screen]() -> qreal {
+
+ // Note: keep in sync with QBackingStorePrivate::backingStoreDevicePixelRatio()!
+ static bool downscale = qEnvironmentVariableIntValue("QT_WIDGETS_HIGHDPI_DOWNSCALE") > 0;
+ QWindow *window = this->window()->windowHandle();
+ if (downscale && window)
+ return std::ceil(window->devicePixelRatio());
+
+ return screen->devicePixelRatio();
+ };
+
switch (m) {
case PdmWidth:
return data->crect.width();
@@ -12726,9 +12737,9 @@ int QWidget::metric(PaintDeviceMetric m) const
case PdmPhysicalDpiY:
return qRound(screen->physicalDotsPerInchY());
case PdmDevicePixelRatio:
- return screen->devicePixelRatio();
+ return resolveDevicePixelRatio();
case PdmDevicePixelRatioScaled:
- return QPaintDevice::devicePixelRatioFScale() * screen->devicePixelRatio();
+ return QPaintDevice::devicePixelRatioFScale() * resolveDevicePixelRatio();
default:
break;
}