diff options
author | Morten Johan Sørvig <morten.sorvig@digia.com> | 2012-11-20 11:34:52 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-12-01 08:33:20 +0100 |
commit | 5e61bbe586519c3d9bc636153d32e810da4e59a3 (patch) | |
tree | 67d67ef644be72ee5b3d685c9a22538d7ec1e01d /src/opengl | |
parent | c8dc41bacdc30026cb79d0d6c72255312084bfe3 (diff) | |
download | qtbase-5e61bbe586519c3d9bc636153d32e810da4e59a3.tar.gz |
Basic high-dpi "retina" support for Qt 5.
Bring Qt 5 on par with Qt 4, prepare for more comprehensive
support later on.
Introduce device independent pixels (dips), device pixels,
and devicePixelRatio. Add high-dpi support to QPainter,
QGLWidget, the cocoa platform plugin, mac and fusion styles.
Dips are similar to CSS pixels, Apple points and
Android density-independent pixels. Device pixels
are pixels in the backing store/physical pixels on screen.
devicePixelRatio is the ratio between them, which is
1.0 on standard displays and 2.0 on "retina" displays.
New API:
QImage::devicePixelRatio() and setDevicePixelRatio()
QPixmap::devicePixelRatio() and setDevicePixelRatio()
QWindow::devicePixelRatio()
QScreen::devicePixelRatio()
QGuiApplicaiton::devicePixelRatio()
Change-Id: If98c3ca9bfdf0e1bdbcf7574cd5b912c9ff63856
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Diffstat (limited to 'src/opengl')
-rw-r--r-- | src/opengl/qgl.cpp | 4 | ||||
-rw-r--r-- | src/opengl/qgl_qpa.cpp | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 8c98a0ea3a..69f4871c6b 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -4100,7 +4100,9 @@ void QGLWidget::glDraw() #endif if (!d->glcx->initialized()) { glInit(); - resizeGL(d->glcx->device()->width(), d->glcx->device()->height()); // New context needs this "resize" + const qreal scaleFactor = (window() && window()->windowHandle()) ? + window()->windowHandle()->devicePixelRatio() : 1.0; + resizeGL(d->glcx->device()->width() * scaleFactor, d->glcx->device()->height() * scaleFactor); // New context needs this "resize" } paintGL(); if (doubleBuffer()) { diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index ba07f6121c..0e8b8abb4f 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -370,7 +370,10 @@ void QGLWidget::resizeEvent(QResizeEvent *e) makeCurrent(); if (!d->glcx->initialized()) glInit(); - resizeGL(width(), height()); + const qreal scaleFactor = (window() && window()->windowHandle()) ? + window()->windowHandle()->devicePixelRatio() : 1.0; + + resizeGL(width() * scaleFactor, height() * scaleFactor); } |