diff options
author | Morten Johan Sørvig <morten.sorvig@digia.com> | 2015-04-14 20:01:15 +0200 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@digia.com> | 2015-04-15 12:54:15 +0200 |
commit | 7ec765b1d10d26de2e13cb22364e45427b654d86 (patch) | |
tree | b41a1ead7cd4bee427fd3b4f4b3a5e4a9ea47e99 /src/gui/kernel | |
parent | 56b72d7809a6016149668b7df0dfd35022ff01c6 (diff) |
Use qreal for devicePixelRatio everywhere
QPaintDevice::devicePixelRatio() -> devicePixelRatioF()
Implement PdmDevicePixelRatioScaled for QPaintDevice subclasses.
Remove instances of casting to int.
Change-Id: I6e769d21e889bf8f88aedc1c49b53fef20a6709c
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qopenglwindow.cpp | 5 | ||||
-rw-r--r-- | src/gui/kernel/qpaintdevicewindow.cpp | 6 | ||||
-rw-r--r-- | src/gui/kernel/qrasterwindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qwindow.cpp | 14 |
4 files changed, 13 insertions, 14 deletions
diff --git a/src/gui/kernel/qopenglwindow.cpp b/src/gui/kernel/qopenglwindow.cpp index a7ba57e85e..2853f05ef3 100644 --- a/src/gui/kernel/qopenglwindow.cpp +++ b/src/gui/kernel/qopenglwindow.cpp @@ -646,15 +646,10 @@ int QOpenGLWindow::metric(PaintDeviceMetric metric) const if (d->paintDevice) return d->paintDevice->depth(); break; - case PdmDevicePixelRatio: - if (d->paintDevice) - return devicePixelRatio(); - break; default: break; } return QPaintDeviceWindow::metric(metric); - } /*! diff --git a/src/gui/kernel/qpaintdevicewindow.cpp b/src/gui/kernel/qpaintdevicewindow.cpp index b32ab3b34d..32f0aeb6d5 100644 --- a/src/gui/kernel/qpaintdevicewindow.cpp +++ b/src/gui/kernel/qpaintdevicewindow.cpp @@ -144,8 +144,10 @@ int QPaintDeviceWindow::metric(PaintDeviceMetric metric) const return qRound(screen->physicalDotsPerInchY()); break; case PdmDevicePixelRatio: - if (screen) - return screen->devicePixelRatio(); + return int(QWindow::devicePixelRatio()); + break; + case PdmDevicePixelRatioScaled: + return int(QWindow::devicePixelRatio() * devicePixelRatioFScale); break; default: break; diff --git a/src/gui/kernel/qrasterwindow.cpp b/src/gui/kernel/qrasterwindow.cpp index c04eb71420..fc1739ca0e 100644 --- a/src/gui/kernel/qrasterwindow.cpp +++ b/src/gui/kernel/qrasterwindow.cpp @@ -108,8 +108,6 @@ int QRasterWindow::metric(PaintDeviceMetric metric) const switch (metric) { case PdmDepth: return d->backingstore->paintDevice()->depth(); - case PdmDevicePixelRatio: - return d->backingstore->paintDevice()->devicePixelRatio(); default: break; } diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 6b74bd66ed..e376df24cb 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -1082,13 +1082,17 @@ qreal QWindow::devicePixelRatio() const { Q_D(const QWindow); - // If there is no platform window, do the second best thing and - // return the app global devicePixelRatio. This is the highest + // Get the platform scale factor. If there is no platform window + // use the app global devicePixelRatio, which is the the highest // devicePixelRatio found on the system screens, and will be // correct for single-display systems (a very common case). - if (!d->platformWindow) - return qApp->devicePixelRatio(); - return d->platformWindow->devicePixelRatio() * QHighDpiScaling::factor(this); + qreal ratio = d->platformWindow ? d->platformWindow->devicePixelRatio() + : qApp->devicePixelRatio(); + + // + ratio *= QHighDpiScaling::factor(this); + + return ratio; } /*! |