From a593de41edfac04f3e3c6dd5bb024254e7e6ff4e Mon Sep 17 00:00:00 2001 From: Morten Johan Sorvig Date: Fri, 14 Dec 2012 17:25:56 +0100 Subject: iOS: Retina display support. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Scale the OpenGL paint device size and physical dpi by the device pixel ratio. Change-Id: I8b576f23129aafc47371795151c548663e94ad52 Reviewed-by: Tor Arne Vestbø --- src/gui/opengl/qopenglpaintdevice.cpp | 14 ++++++++++++-- src/gui/opengl/qopenglpaintdevice.h | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src/gui/opengl') diff --git a/src/gui/opengl/qopenglpaintdevice.cpp b/src/gui/opengl/qopenglpaintdevice.cpp index 0b3d9dc46d..d55d6a91bf 100644 --- a/src/gui/opengl/qopenglpaintdevice.cpp +++ b/src/gui/opengl/qopenglpaintdevice.cpp @@ -116,6 +116,7 @@ public: qreal dpmx; qreal dpmy; + qreal devicePixelRatio; bool flipped; @@ -178,6 +179,7 @@ QOpenGLPaintDevicePrivate::QOpenGLPaintDevicePrivate(const QSize &sz) , ctx(QOpenGLContext::currentContext()) , dpmx(qt_defaultDpiX() * 100. / 2.54) , dpmy(qt_defaultDpiY() * 100. / 2.54) + , devicePixelRatio(1.0) , flipped(false) , engine(0) { @@ -248,6 +250,14 @@ void QOpenGLPaintDevice::setSize(const QSize &size) d_ptr->size = size; } +/*! + Sets the device pixel ratio for the paint device to \a devicePixelRatio. +*/ +void QOpenGLPaintDevice::setDevicePixelRatio(qreal devicePixelRatio) +{ + d_ptr->devicePixelRatio = devicePixelRatio; +} + /*! \reimp */ @@ -272,9 +282,9 @@ int QOpenGLPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const case PdmDpiY: return qRound(d_ptr->dpmy * 0.0254); case PdmPhysicalDpiX: - return qRound(d_ptr->dpmx * 0.0254); + return qRound(d_ptr->dpmx * 0.0254 * d_ptr->devicePixelRatio); case PdmPhysicalDpiY: - return qRound(d_ptr->dpmy * 0.0254); + return qRound(d_ptr->dpmy * 0.0254 * d_ptr->devicePixelRatio); default: qWarning("QOpenGLPaintDevice::metric() - metric %d not known", metric); return 0; diff --git a/src/gui/opengl/qopenglpaintdevice.h b/src/gui/opengl/qopenglpaintdevice.h index 731000f131..5868a5740a 100644 --- a/src/gui/opengl/qopenglpaintdevice.h +++ b/src/gui/opengl/qopenglpaintdevice.h @@ -68,6 +68,7 @@ public: QOpenGLContext *context() const; QSize size() const; void setSize(const QSize &size); + void setDevicePixelRatio(qreal devicePixelRatio); qreal dotsPerMeterX() const; qreal dotsPerMeterY() const; -- cgit v1.2.3