From cea58f4b77e1639e5671cf424544d4948fb8e9ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 24 Jan 2013 09:26:45 +0100 Subject: Add devicePixelRatio metric to QPaintDevice. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously QPainter computed the devicePixelRatio based on the physical and logical dpi, and expected that the ratio between them would be either 1x or 2x. This was problematic for paint devices like printers where the physical dpi can be much higher than the logical dpi, and also for QScreen where the physical dpi would have to be defined as a multiple of the logical dpi. Add QPaintDevice::PdmDevicePixelRatio and QPaintDevice:: devicePixelRatio() getter and implement it for the QPaintDevice subclasses. Use it when calculating the highdpi scale transform in qpainter.cpp and when scaling the clip rect in qwidget.cpp. Remove physical dpi scaling for QImage, QPixmap and QOpenGLPaintDevice, reverting to the old behavior. Change-Id: I6c97510613196d4536ff39d08e9750b8782283d4 Reviewed-by: Samuel Rødal Reviewed-by: Gunnar Sletta --- src/gui/painting/qpaintdevice.qdoc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/gui/painting/qpaintdevice.qdoc') diff --git a/src/gui/painting/qpaintdevice.qdoc b/src/gui/painting/qpaintdevice.qdoc index 7397dc7fc2..993b23850e 100644 --- a/src/gui/painting/qpaintdevice.qdoc +++ b/src/gui/painting/qpaintdevice.qdoc @@ -114,6 +114,10 @@ \value PdmPhysicalDpiY The vertical resolution of the device in dots per inch. See also physicalDpiY(). + \value PdmDevicePixelRatio The device pixel ratio for device. Common + values are 1 for normal-dpi displays and 2 for high-dpi "retina" + displays. + \sa metric() */ @@ -273,3 +277,12 @@ \sa physicalDpiX(), logicalDpiY() */ + +/*! + \fn int QPaintDevice::devicePixelRatio() const + + Returns the device pixel ratio for device. + + Common values are 1 for normal-dpi displays and 2 for high-dpi + "retina" displays. +*/ -- cgit v1.2.3