summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@digia.com>2013-01-24 09:26:45 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-15 07:55:52 +0200
commitcea58f4b77e1639e5671cf424544d4948fb8e9ef (patch)
treec794d9e3505a9f1e4b9909bf470aa4bfbef25770 /src/gui/image
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 <samuel.rodal@digia.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Diffstat (limited to 'src/gui/image')
-rw-r--r--src/gui/image/qimage.cpp9
-rw-r--r--src/gui/image/qpicture.cpp3
-rw-r--r--src/gui/image/qpixmap_blitter.cpp2
-rw-r--r--src/gui/image/qpixmap_raster.cpp6
4 files changed, 16 insertions, 4 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 7287f54e74..0efb9c2646 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -4994,12 +4994,17 @@ int QImage::metric(PaintDeviceMetric metric) const
break;
case PdmPhysicalDpiX:
- return qRound(d->dpmx * 0.0254 * d->devicePixelRatio);
+ return qRound(d->dpmx * 0.0254);
break;
case PdmPhysicalDpiY:
- return qRound(d->dpmy * 0.0254 * d->devicePixelRatio);
+ return qRound(d->dpmy * 0.0254);
break;
+
+ case PdmDevicePixelRatio:
+ return d->devicePixelRatio;
+ 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 f6de22851d..1071ed754b 100644
--- a/src/gui/image/qpicture.cpp
+++ b/src/gui/image/qpicture.cpp
@@ -956,6 +956,9 @@ int QPicture::metric(PaintDeviceMetric m) const
case PdmDepth:
val = 24;
break;
+ case PdmDevicePixelRatio:
+ val = 1;
+ 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 75b7a4ba06..4c1b30a6d8 100644
--- a/src/gui/image/qpixmap_blitter.cpp
+++ b/src/gui/image/qpixmap_blitter.cpp
@@ -120,6 +120,8 @@ int QBlittablePlatformPixmap::metric(QPaintDevice::PaintDeviceMetric metric) con
case QPaintDevice::PdmDpiY: // fall-through
case QPaintDevice::PdmPhysicalDpiY:
return qt_defaultDpiY();
+ case QPaintDevice::PdmDevicePixelRatio:
+ return 1;
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 302945dbf8..c80ccd8b1d 100644
--- a/src/gui/image/qpixmap_raster.cpp
+++ b/src/gui/image/qpixmap_raster.cpp
@@ -278,11 +278,13 @@ int QRasterPlatformPixmap::metric(QPaintDevice::PaintDeviceMetric metric) const
case QPaintDevice::PdmDpiX:
return qt_defaultDpiX();
case QPaintDevice::PdmPhysicalDpiX:
- return qt_defaultDpiX() * image.devicePixelRatio();
+ return qt_defaultDpiX();
case QPaintDevice::PdmDpiY:
return qt_defaultDpiX();
case QPaintDevice::PdmPhysicalDpiY:
- return qt_defaultDpiY() * image.devicePixelRatio();
+ return qt_defaultDpiY();
+ case QPaintDevice::PdmDevicePixelRatio:
+ return image.devicePixelRatio();
default:
qWarning("QRasterPlatformPixmap::metric(): Unhandled metric type %d", metric);
break;