From c9edc164ab165ddd31ef2411be19deb130614e8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 13 Dec 2017 23:58:36 +0100 Subject: Set devicePixelRatio on item size change Propagate the dpr to the QRenderSurfaceSelector in addition to the the item size. Task-number: QTBUG-62235 Change-Id: I6555685392334b8edf2327fae97d5d531cffeaae Reviewed-by: Sean Harmer --- src/quick3d/imports/scene3d/scene3ditem.cpp | 6 ++++-- src/quick3d/imports/scene3d/scene3ditem_p.h | 2 +- src/quick3d/imports/scene3d/scene3drenderer.cpp | 9 +++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/quick3d/imports/scene3d/scene3ditem.cpp b/src/quick3d/imports/scene3d/scene3ditem.cpp index c31f4aa97..ab832d463 100644 --- a/src/quick3d/imports/scene3d/scene3ditem.cpp +++ b/src/quick3d/imports/scene3d/scene3ditem.cpp @@ -223,11 +223,13 @@ void Scene3DItem::setWindowSurface(QObject *rootObject) } } -void Scene3DItem::setItemArea(QSize area) +void Scene3DItem::setItemAreaAndDevicePixelRatio(QSize area, qreal devicePixelRatio) { Qt3DRender::QRenderSurfaceSelector *surfaceSelector = Qt3DRender::QRenderSurfaceSelectorPrivate::find(m_entity); - if (surfaceSelector) + if (surfaceSelector) { surfaceSelector->setExternalRenderTargetSize(area); + surfaceSelector->setSurfacePixelRatio(devicePixelRatio); + } } bool Scene3DItem::isHoverEnabled() const diff --git a/src/quick3d/imports/scene3d/scene3ditem_p.h b/src/quick3d/imports/scene3d/scene3ditem_p.h index e0ce3addc..37d7cbcc2 100644 --- a/src/quick3d/imports/scene3d/scene3ditem_p.h +++ b/src/quick3d/imports/scene3d/scene3ditem_p.h @@ -88,7 +88,7 @@ public: bool multisample() const; void setMultisample(bool enable); - Q_INVOKABLE void setItemArea(QSize area); + Q_INVOKABLE void setItemAreaAndDevicePixelRatio(QSize area, qreal devicePixelRatio); bool isHoverEnabled() const; enum CameraAspectRatioMode { diff --git a/src/quick3d/imports/scene3d/scene3drenderer.cpp b/src/quick3d/imports/scene3d/scene3drenderer.cpp index 26e966f76..23aaf9ed0 100644 --- a/src/quick3d/imports/scene3d/scene3drenderer.cpp +++ b/src/quick3d/imports/scene3d/scene3drenderer.cpp @@ -59,9 +59,9 @@ namespace Qt3DRender { namespace { -inline QMetaMethod setItemAreaMethod() +inline QMetaMethod setItemAreaAndDevicePixelRatioMethod() { - const int idx = Scene3DItem::staticMetaObject.indexOfMethod("setItemArea(QSize)"); + const int idx = Scene3DItem::staticMetaObject.indexOfMethod("setItemAreaAndDevicePixelRatio(QSize,qreal)"); Q_ASSERT(idx != -1); return Scene3DItem::staticMetaObject.method(idx); } @@ -267,8 +267,9 @@ void Scene3DRenderer::render() if (sizeHasChanged) { // We are in the QSGRenderThread (doing a direct call would result in a race) - static const QMetaMethod setItemArea = setItemAreaMethod(); - setItemArea.invoke(m_item, Qt::QueuedConnection, Q_ARG(QSize, boundingRectSize)); + static const QMetaMethod setItemAreaAndDevicePixelRatio = setItemAreaAndDevicePixelRatioMethod(); + setItemAreaAndDevicePixelRatio.invoke(m_item, Qt::QueuedConnection, Q_ARG(QSize, boundingRectSize), + Q_ARG(qreal, window->effectiveDevicePixelRatio())); } // Rebuild FBO and textures if never created or a resize has occurred -- cgit v1.2.3