Qt Quick high-dpi support.
authorMorten Johan Sørvig <morten.sorvig@digia.com>
Wed, 21 Nov 2012 13:26:05 +0000 (14:26 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Sat, 1 Dec 2012 10:33:17 +0000 (11:33 +0100)
Set the device and viewport rect to the full device
pixel size. Set the projection matrix to the device
independent pixel size.

Scale shader effect source texture sizes.

Change-Id: I61dd546ff36a7ce6ad05f908796555674c714c1a
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
src/quick/items/qquickshadereffectsource.cpp
src/quick/items/qquickwindow.cpp

index 547e214..2b613df 100644 (file)
@@ -955,6 +955,11 @@ QSGNode *QQuickShaderEffectSource::updatePaintNode(QSGNode *oldNode, UpdatePaint
                       ? QSize(qCeil(qAbs(sourceRect.width())), qCeil(qAbs(sourceRect.height())))
                       : m_textureSize;
     Q_ASSERT(!textureSize.isEmpty());
+
+    // Crate large textures on high-dpi displays.
+    if (sourceItem() && sourceItem()->window())
+        textureSize *= sourceItem()->window()->devicePixelRatio();
+
     QQuickItemPrivate *d = static_cast<QQuickItemPrivate *>(QObjectPrivate::get(this));
     const QSize minTextureSize = d->sceneGraphContext()->minimumFBOSize();
     // Keep power-of-two by doubling the size.
index 2ce91cd..a915430 100644 (file)
@@ -336,14 +336,15 @@ void QQuickWindowPrivate::renderSceneGraph(const QSize &size)
     Q_Q(QQuickWindow);
     emit q->beforeRendering();
     int fboId = 0;
-    renderer->setDeviceRect(QRect(QPoint(0, 0), size));
+    const qreal devicePixelRatio = q->devicePixelRatio();
+    renderer->setDeviceRect(QRect(QPoint(0, 0), size * devicePixelRatio));
     if (renderTargetId) {
         fboId = renderTargetId;
         renderer->setViewportRect(QRect(QPoint(0, 0), renderTargetSize));
     } else {
-        renderer->setViewportRect(QRect(QPoint(0, 0), size));
+        renderer->setViewportRect(QRect(QPoint(0, 0), size * devicePixelRatio));
     }
-    renderer->setProjectionMatrixToDeviceRect();
+    renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), size));
 
     context->renderNextFrame(renderer, fboId);
     emit q->afterRendering();