summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@theqtcompany.com>2015-06-19 16:40:39 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-07-30 04:04:01 +0000
commitdcd2debe625841ee8cba6d13a56cde7613c40358 (patch)
treed1d1e6c98d9cc5d81f29a389721acca6a9f7d150 /src/opengl
parent0167ace5f0a7e5ad80ce95efc99c86235bcf8c0d (diff)
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 <paul.tvete@theqtcompany.com> Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/qgl.cpp4
-rw-r--r--src/opengl/qglframebufferobject.cpp3
-rw-r--r--src/opengl/qglpaintdevice.cpp2
-rw-r--r--src/opengl/qglpixelbuffer.cpp3
4 files changed, 10 insertions, 2 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index c62e09b3f3..63ebf14bd5 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -4496,7 +4496,7 @@ QImage QGLWidget::grabFrameBuffer(bool withAlpha)
{
makeCurrent();
QImage res;
- qreal pixelRatio = devicePixelRatio();
+ qreal pixelRatio = devicePixelRatioF();
int w = pixelRatio * width();
int h = pixelRatio * height();
if (format().rgba())
@@ -4909,7 +4909,7 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con
GLdouble win_x = 0, win_y = 0, win_z = 0;
qgluProject(x, y, z, &model[0], &proj[0], &view[0],
&win_x, &win_y, &win_z);
- const int dpr = d->glcx->device()->devicePixelRatio();
+ const int dpr = d->glcx->device()->devicePixelRatioF();
win_x /= dpr;
win_y /= dpr;
win_y = height - win_y; // y is inverted
diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp
index 3479fccf58..b636f90918 100644
--- a/src/opengl/qglframebufferobject.cpp
+++ b/src/opengl/qglframebufferobject.cpp
@@ -1285,6 +1285,9 @@ int QGLFramebufferObject::metric(PaintDeviceMetric metric) const
case QPaintDevice::PdmDevicePixelRatio:
return 1;
+ case QPaintDevice::PdmDevicePixelRatioScaled:
+ return 1 * QPaintDevice::devicePixelRatioFScale();
+
default:
qWarning("QGLFramebufferObject::metric(), Unhandled metric type: %d.\n", metric);
break;
diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp
index 89cf01d8ec..b5df45bcc8 100644
--- a/src/opengl/qglpaintdevice.cpp
+++ b/src/opengl/qglpaintdevice.cpp
@@ -62,6 +62,8 @@ int QGLPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const
}
case PdmDevicePixelRatio:
return 1;
+ case PdmDevicePixelRatioScaled:
+ return 1 * QPaintDevice::devicePixelRatioFScale();
default:
qWarning("QGLPaintDevice::metric() - metric %d not known", metric);
return 0;
diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp
index 42fa3415ef..943ec7ad30 100644
--- a/src/opengl/qglpixelbuffer.cpp
+++ b/src/opengl/qglpixelbuffer.cpp
@@ -458,6 +458,9 @@ int QGLPixelBuffer::metric(PaintDeviceMetric metric) const
case QPaintDevice::PdmDevicePixelRatio:
return 1;
+ case QPaintDevice::PdmDevicePixelRatioScaled:
+ return QPaintDevice::devicePixelRatioFScale();
+
default:
qWarning("QGLPixelBuffer::metric(), Unhandled metric type: %d\n", metric);
break;