diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2019-10-11 13:00:11 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2019-10-15 10:25:28 +0200 |
commit | a02a9b3671226f4c8e4636163ba76cf8e9a48b42 (patch) | |
tree | fc283eb102b874ee54a71b2516282487405ac074 | |
parent | b80febc045464009ecf0355a51bce048bc9b84a9 (diff) |
Scene3D: fix next frame update request
We were requesting a QQuickItem frame update in the middle of an update
which lead to it being ignored.
This led to some scene not being refreshed or rendered until the window
was moved (which forced an update)
Change-Id: I9f411b4cfe18813d3e24ac02daa138822c767a46
Reviewed-by: Mike Krus <mike.krus@kdab.com>
-rw-r--r-- | src/quick3d/imports/scene3d/scene3ditem.cpp | 16 | ||||
-rw-r--r-- | src/quick3d/imports/scene3d/scene3ditem_p.h | 1 |
2 files changed, 14 insertions, 3 deletions
diff --git a/src/quick3d/imports/scene3d/scene3ditem.cpp b/src/quick3d/imports/scene3d/scene3ditem.cpp index 02e8447c7..f3f7acd71 100644 --- a/src/quick3d/imports/scene3d/scene3ditem.cpp +++ b/src/quick3d/imports/scene3d/scene3ditem.cpp @@ -500,10 +500,16 @@ void Scene3DItem::onBeforeSync() // make Qt3D enter a locked state m_renderer->allowRender(); - // Request refresh for next frame + // Note: it's too early to request an update at this point as + // beforeSync() triggered by afterAnimating is considered + // to be as being part of the current frame update +} +void Scene3DItem::requestUpdate() +{ // When using the FBO mode, only the QQuickItem needs to be updated // When using the Underlay mode, the whole windows needs updating + const bool usesFBO = m_compositingMode == FBO; if (usesFBO) { QQuickItem::update(); for (Scene3DView *view : m_views) @@ -629,8 +635,6 @@ QSGNode *Scene3DItem::updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNode auto renderAspectPriv = static_cast<QRenderAspectPrivate*>(QRenderAspectPrivate::get(m_renderAspect)); QObject::connect(renderAspectPriv->m_aspectManager->changeArbiter(), &Qt3DCore::QChangeArbiter::receivedChange, this, [this] { m_dirty = true; }, Qt::DirectConnection); - QObject::connect(renderAspectPriv->m_aspectManager->changeArbiter(), &Qt3DCore::QChangeArbiter::receivedChange, - this, &QQuickItem::update, Qt::AutoConnection); } if (m_renderer == nullptr) { @@ -672,6 +676,12 @@ QSGNode *Scene3DItem::updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNode window()->setClearBeforeRendering(false); } + // Request update for next frame so that we can check whether we need to + // render again or not + static int requestUpdateMethodIdx = Scene3DItem::staticMetaObject.indexOfMethod("requestUpdate()"); + static QMetaMethod requestUpdateMethod =Scene3DItem::staticMetaObject.method(requestUpdateMethodIdx); + requestUpdateMethod.invoke(this, Qt::QueuedConnection); + return fboNode; } diff --git a/src/quick3d/imports/scene3d/scene3ditem_p.h b/src/quick3d/imports/scene3d/scene3ditem_p.h index 4a2fc7f44..e46bb20af 100644 --- a/src/quick3d/imports/scene3d/scene3ditem_p.h +++ b/src/quick3d/imports/scene3d/scene3ditem_p.h @@ -129,6 +129,7 @@ Q_SIGNALS: private Q_SLOTS: void applyRootEntityChange(); void onBeforeSync(); + void requestUpdate(); private: QSGNode *updatePaintNode(QSGNode *node, UpdatePaintNodeData *nodeData) override; |