diff options
Diffstat (limited to 'src/quick3d/imports/scene3d/scene3ditem.cpp')
-rw-r--r-- | src/quick3d/imports/scene3d/scene3ditem.cpp | 76 |
1 files changed, 46 insertions, 30 deletions
diff --git a/src/quick3d/imports/scene3d/scene3ditem.cpp b/src/quick3d/imports/scene3d/scene3ditem.cpp index c8c0e0f59..57e6b0e6e 100644 --- a/src/quick3d/imports/scene3d/scene3ditem.cpp +++ b/src/quick3d/imports/scene3d/scene3ditem.cpp @@ -5,8 +5,7 @@ ** ** This file is part of the Qt3D module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:COMM$ -** +** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the @@ -15,25 +14,26 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** $QT_END_LICENSE$ -** -** -** -** -** -** -** -** -** -** -** -** -** -** -** -** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. ** +** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -200,6 +200,9 @@ private: expression that depends on property updates driven by the Qt 3D simulation loop (FrameAction) will never reavaluates. */ + +qint8 Scene3DItem::ms_framesNeededToFlushPipeline = 3; + Scene3DItem::Scene3DItem(QQuickItem *parent) : QQuickItem(parent) , m_entity(nullptr) @@ -219,6 +222,7 @@ Scene3DItem::Scene3DItem(QQuickItem *parent) , m_cameraAspectRatioMode(AutomaticAspectRatio) , m_compositingMode(FBO) , m_dummySurface(nullptr) + , m_framesToRender(ms_framesNeededToFlushPipeline) { setFlag(QQuickItem::ItemHasContents, true); setAcceptedMouseButtons(Qt::MouseButtonMask); @@ -229,6 +233,11 @@ Scene3DItem::Scene3DItem(QQuickItem *parent) // we still won't get ignored by the QtQuick SG when in Underlay mode setWidth(1); setHeight(1); + + const QByteArray framesToFlushCountEnvVar = qgetenv("QT3D_SCENE3D_FRAMES_FLUSH_COUNT"); + if (!framesToFlushCountEnvVar.isEmpty()) { + ms_framesNeededToFlushPipeline = framesToFlushCountEnvVar.toInt(); + } } Scene3DItem::~Scene3DItem() @@ -542,8 +551,13 @@ bool Scene3DItem::needsRender(QRenderAspect *renderAspect) || (renderAspectPriv && renderAspectPriv->m_renderer && renderAspectPriv->m_renderer->shouldRender()); - m_dirty = false; - return dirty; + + if (m_dirty) { + --m_framesToRender; + if (m_framesToRender <= 0) + m_dirty = false; + } + return dirty || m_framesToRender > 0; } // This function is triggered in the context of the Main Thread @@ -911,15 +925,16 @@ QSGNode *Scene3DItem::updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNode updateWindowSurface(); managerNode->init(); // Note: ChangeArbiter is only set after aspect was registered - - // This allows Scene3DItem to know when it needs to re-render as a result of frontend nodes receiving a change. - QObject::connect(renderAspectPriv->m_aspectManager->changeArbiter(), &Qt3DCore::QChangeArbiter::receivedChange, - this, [this] { m_dirty = true; }, Qt::DirectConnection); - - // This allows Scene3DItem to know when it needs to re-render as a result of backend nodes receiving a change. - // For e.g. nodes being created/destroyed. - QObject::connect(renderAspectPriv->m_aspectManager->changeArbiter(), &Qt3DCore::QChangeArbiter::syncedChanges, - this, [this] { m_dirty = true; }, Qt::QueuedConnection); + QObject::connect( + renderAspectPriv->m_aspectManager->changeArbiter(), + &Qt3DCore::QChangeArbiter::receivedChange, this, + [this] { + m_dirty = true; + m_framesToRender = ms_framesNeededToFlushPipeline; + }, + Qt::DirectConnection); + // Give the window a nudge to trigger an update. + QMetaObject::invokeMethod(window(), "requestUpdate", Qt::QueuedConnection); } const bool usesFBO = m_compositingMode == FBO; @@ -1007,4 +1022,5 @@ void Scene3DItem::mousePressEvent(QMouseEvent *event) QT_END_NAMESPACE +#include "moc_scene3ditem_p.cpp" #include "scene3ditem.moc" |