path: root/src/opengl/qglpaintdevice.cpp
diff options
authorMorten Johan Sørvig <>2013-01-24 09:26:45 +0100
committerThe Qt Project <>2013-04-15 07:55:52 +0200
commitcea58f4b77e1639e5671cf424544d4948fb8e9ef (patch)
treec794d9e3505a9f1e4b9909bf470aa4bfbef25770 /src/opengl/qglpaintdevice.cpp
parent1f3a67e8701bd8e8d4e58ca740bc03781c10136b (diff)
Add devicePixelRatio metric to QPaintDevice.
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 <>
Diffstat (limited to 'src/opengl/qglpaintdevice.cpp')
1 files changed, 2 insertions, 0 deletions
diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp
index a3779218d2..ef9bdba070 100644
--- a/src/opengl/qglpaintdevice.cpp
+++ b/src/opengl/qglpaintdevice.cpp
@@ -67,6 +67,8 @@ int QGLPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const
const QGLFormat f = format();
return f.redBufferSize() + f.greenBufferSize() + f.blueBufferSize() + f.alphaBufferSize();
+ case PdmDevicePixelRatio:
+ return 1;
qWarning("QGLPaintDevice::metric() - metric %d not known", metric);
return 0;