From 9c9ad9b86f5ae30df1021300d1b775f6d341a78f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 21 Nov 2012 14:26:05 +0100 Subject: Qt Quick high-dpi support. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Lars Knoll Reviewed-by: Jens Bache-Wiig Reviewed-by: Gunnar Sletta --- src/quick/items/qquickshadereffectsource.cpp | 5 +++++ src/quick/items/qquickwindow.cpp | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/quick/items/qquickshadereffectsource.cpp b/src/quick/items/qquickshadereffectsource.cpp index 547e2141f6..2b613df0f2 100644 --- a/src/quick/items/qquickshadereffectsource.cpp +++ b/src/quick/items/qquickshadereffectsource.cpp @@ -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(QObjectPrivate::get(this)); const QSize minTextureSize = d->sceneGraphContext()->minimumFBOSize(); // Keep power-of-two by doubling the size. diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 2ce91cdc2c..a915430616 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -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(); -- cgit v1.2.3