diff options
author | Morten Johan Sørvig <morten.sorvig@theqtcompany.com> | 2015-06-19 16:40:39 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-07-30 04:04:01 +0000 |
commit | dcd2debe625841ee8cba6d13a56cde7613c40358 (patch) | |
tree | d1d1e6c98d9cc5d81f29a389721acca6a9f7d150 /src/gui/image | |
parent | 0167ace5f0a7e5ad80ce95efc99c86235bcf8c0d (diff) |
Enable non-integer device pixel ratio
Work around QPaintDevice::metric's int return type
by adding a new metric that returns a scaled devicePixelRatio.
Choose a scale factor that gives us more than enough
range.
The QPaintDevice::devicePixelRatio() convenience accessor
is public API and can unfortunately not be changed
to return a qreal. Add devicePixelRatioF() which
returns the (unscaled) devicePixelRatio.
Change all call sites of QPaintDevice::devicePixelRatio()
to use QPainDevice::devicePixelRatioF().
Task-number: QTBUG-46615
Change-Id: I97ec4000fe379b7ff5e1624a871ae2512790aad9
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/qimage.cpp | 4 | ||||
-rw-r--r-- | src/gui/image/qpicture.cpp | 3 | ||||
-rw-r--r-- | src/gui/image/qpixmap_blitter.cpp | 2 | ||||
-rw-r--r-- | src/gui/image/qpixmap_raster.cpp | 3 |
4 files changed, 12 insertions, 0 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 3c192a237e..b8606a92b4 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -3891,6 +3891,10 @@ int QImage::metric(PaintDeviceMetric metric) const return d->devicePixelRatio; break; + case PdmDevicePixelRatioScaled: + return d->devicePixelRatio * QPaintDevice::devicePixelRatioFScale(); + break; + default: qWarning("QImage::metric(): Unhandled metric type %d", metric); break; diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp index 4a1e65b20a..2b184466f4 100644 --- a/src/gui/image/qpicture.cpp +++ b/src/gui/image/qpicture.cpp @@ -961,6 +961,9 @@ int QPicture::metric(PaintDeviceMetric m) const case PdmDevicePixelRatio: val = 1; break; + case PdmDevicePixelRatioScaled: + val = 1 * QPaintDevice::devicePixelRatioFScale(); + break; default: val = 0; qWarning("QPicture::metric: Invalid metric command"); diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index f24cbc3db9..b254c5a2af 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -115,6 +115,8 @@ int QBlittablePlatformPixmap::metric(QPaintDevice::PaintDeviceMetric metric) con return qt_defaultDpiY(); case QPaintDevice::PdmDevicePixelRatio: return devicePixelRatio(); + case QPaintDevice::PdmDevicePixelRatioScaled: + return devicePixelRatio() * QPaintDevice::devicePixelRatioFScale(); default: qWarning("QRasterPlatformPixmap::metric(): Unhandled metric type %d", metric); break; diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp index 9c8835a7a0..a2b84b358e 100644 --- a/src/gui/image/qpixmap_raster.cpp +++ b/src/gui/image/qpixmap_raster.cpp @@ -288,6 +288,9 @@ int QRasterPlatformPixmap::metric(QPaintDevice::PaintDeviceMetric metric) const return qt_defaultDpiY(); case QPaintDevice::PdmDevicePixelRatio: return image.devicePixelRatio(); + case QPaintDevice::PdmDevicePixelRatioScaled: + return image.devicePixelRatio() * QPaintDevice::devicePixelRatioFScale(); + default: qWarning("QRasterPlatformPixmap::metric(): Unhandled metric type %d", metric); break; |