From: Morten Johan Sørvig Date: Wed, 21 Nov 2012 13:26:05 +0000 (+0100) Subject: Qt Quick high-dpi support. X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=9c9ad9b86f5ae30df1021300d1b775f6d341a78f;p=konrad%2Fqtdeclarative.git Qt Quick high-dpi support. 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 --- diff --git a/src/quick/items/qquickshadereffectsource.cpp b/src/quick/items/qquickshadereffectsource.cpp index 547e214..2b613df 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 2ce91cd..a915430 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();