Commit a02a9b36 authored by Paul Lemire's avatar Paul Lemire
Browse files

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's avatarMike Krus <mike.krus@kdab.com>
parent b80febc0
......@@ -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;
}
......
......@@ -129,6 +129,7 @@ Q_SIGNALS:
private Q_SLOTS:
void applyRootEntityChange();
void onBeforeSync();
void requestUpdate();
private:
QSGNode *updatePaintNode(QSGNode *node, UpdatePaintNodeData *nodeData) override;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment