From dcd2debe625841ee8cba6d13a56cde7613c40358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 19 Jun 2015 16:40:39 +0200 Subject: 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 Reviewed-by: Lars Knoll --- src/gui/kernel/qpaintdevicewindow.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/gui/kernel/qpaintdevicewindow.cpp') diff --git a/src/gui/kernel/qpaintdevicewindow.cpp b/src/gui/kernel/qpaintdevicewindow.cpp index ff661d017d..cd894866c3 100644 --- a/src/gui/kernel/qpaintdevicewindow.cpp +++ b/src/gui/kernel/qpaintdevicewindow.cpp @@ -155,8 +155,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; -- cgit v1.2.3