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/painting/qpainter.cpp | |
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/painting/qpainter.cpp')
-rw-r--r-- | src/gui/painting/qpainter.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 1726bbe71f..e80c0130c3 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -219,18 +219,18 @@ QTransform QPainterPrivate::viewTransform() const return QTransform(); } -int QPainterPrivate::effectiveDevicePixelRatio() const +qreal QPainterPrivate::effectiveDevicePixelRatio() const { // Special cases for devices that does not support PdmDevicePixelRatio go here: if (device->devType() == QInternal::Printer) - return 1; + return qreal(1); - return qMax(1, device->metric(QPaintDevice::PdmDevicePixelRatio)); + return qMax(qreal(1), device->devicePixelRatioF()); } QTransform QPainterPrivate::hidpiScaleTransform() const { - int devicePixelRatio = effectiveDevicePixelRatio(); + const qreal devicePixelRatio = effectiveDevicePixelRatio(); return QTransform::fromScale(devicePixelRatio, devicePixelRatio); } @@ -5110,7 +5110,7 @@ void QPainter::drawPixmap(const QPointF &p, const QPixmap &pm) x += d->state->matrix.dx(); y += d->state->matrix.dy(); } - int scale = pm.devicePixelRatio(); + qreal scale = pm.devicePixelRatio(); d->engine->drawPixmap(QRectF(x, y, w / scale, h / scale), pm, QRectF(0, 0, w, h)); } } |