summaryrefslogtreecommitdiffstats
path: root/src/api
diff options
context:
space:
mode:
authorAntti Määttä <antti.maatta@qt.io>2020-01-17 07:57:05 +0200
committerAntti Määttä <antti.maatta@qt.io>2020-01-22 13:28:49 +0200
commit88849a83a6f9ca3524cf3ba32c3a4ed7e6fabdb9 (patch)
treecbe79006339b63245381cef7e2822cbbf01dcae9 /src/api
parent7a49e1bdc590f0d3f397dd04355fd165bbd1cb86 (diff)
Don't render when scene is not changing
Reduce CPU and GPU load by checking if the scene has changed and render only if it has. Task-number: QT3DS-4042 Change-Id: I54e447760f04fdad8d64319f326245175b471331 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'src/api')
-rw-r--r--src/api/studio3dqml/q3dsrenderer.cpp13
-rw-r--r--src/api/studio3dqml/q3dsrenderer_p.h2
2 files changed, 10 insertions, 5 deletions
diff --git a/src/api/studio3dqml/q3dsrenderer.cpp b/src/api/studio3dqml/q3dsrenderer.cpp
index 7d63b30..c902934 100644
--- a/src/api/studio3dqml/q3dsrenderer.cpp
+++ b/src/api/studio3dqml/q3dsrenderer.cpp
@@ -197,27 +197,32 @@ void Q3DSRenderer::render()
// Don't render if the plugin is hidden; however, if hidden, but sure
// to process pending commands so we can be shown again.
if (m_initialized) {
+ bool updateAgain = false;
if (m_visibleFlag)
- draw();
+ updateAgain = draw();
else
processCommands();
- update(); // mark as dirty to ensure update again
+
+ if (updateAgain)
+ update(); // mark as dirty to ensure update again
}
}
/** Cause Qt3DS runtime to render content.
* Initializes GL and the runtime when called the first time.
*/
-void Q3DSRenderer::draw()
+bool Q3DSRenderer::draw()
{
+ bool ret = true;
if (m_runtime && m_runtime->IsInitialised() && m_window) {
if (m_initialized)
m_runtime->RestoreState();
- m_runtime->Render();
+ ret = m_runtime->Render();
m_runtime->SaveState();
m_window->resetOpenGLState();
}
+ return ret;
}
bool Q3DSRenderer::initializeRuntime(QOpenGLFramebufferObject *inFbo)
diff --git a/src/api/studio3dqml/q3dsrenderer_p.h b/src/api/studio3dqml/q3dsrenderer_p.h
index 0817494..dbc85a2 100644
--- a/src/api/studio3dqml/q3dsrenderer_p.h
+++ b/src/api/studio3dqml/q3dsrenderer_p.h
@@ -89,7 +89,7 @@ protected:
static void onInitHandler(void *userData);
static void onUpdateHandler(void *userData);
bool initializeRuntime(QOpenGLFramebufferObject *inFbo);
- void draw();
+ bool draw();
void render() override;
void synchronize(QQuickFramebufferObject *inView) override;
void releaseRuntime();