summaryrefslogtreecommitdiffstats
path: root/src/runtime/q3dsslideplayer.cpp
diff options
context:
space:
mode:
authorChristian Strømme <christian.stromme@qt.io>2018-05-23 16:06:33 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2018-05-23 15:14:58 +0000
commitb81bba4795eea06d4dcbf39c99f986de2654077d (patch)
tree7a1ae164efc44b4cd74344fb88d13fe1158576c4 /src/runtime/q3dsslideplayer.cpp
parentb7e63b82396abfb25e1c31443ed6c7f9437aa30d (diff)
Compress the visibility updates of nodes
Just keep the last update state for each object or else we end-up doing two calls for each object. Change-Id: I42d98e27513772972c38dbb4dbd36ddc0b84661b Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/runtime/q3dsslideplayer.cpp')
-rw-r--r--src/runtime/q3dsslideplayer.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/runtime/q3dsslideplayer.cpp b/src/runtime/q3dsslideplayer.cpp
index fd2a328..9c7b03e 100644
--- a/src/runtime/q3dsslideplayer.cpp
+++ b/src/runtime/q3dsslideplayer.cpp
@@ -737,17 +737,25 @@ void Q3DSSlidePlayer::updateObjectVisibility(Q3DSGraphObject *obj, bool shouldBe
{
Q_ASSERT(obj->isNode() || obj->type() == Q3DSGraphObject::Effect);
if (obj->isNode()) {
- if (shouldBeVisible) {
- qCDebug(lcSlidePlayer, "Scheduling node \"%s\" to be shown", obj->id().constData());
- m_sceneManager->m_pendingNodeShow.insert(static_cast<Q3DSNode *>(obj));
- } else {
- qCDebug(lcSlidePlayer, "Scheduling node \"%s\" to be hidden", obj->id().constData());
- m_sceneManager->m_pendingNodeHide.insert(static_cast<Q3DSNode *>(obj));
+ Q3DSNode *node = static_cast<Q3DSNode *>(obj);
+ auto foundIt = m_sceneManager->m_pendingNodeVisibility.find(node);
+ const bool insertValue = (foundIt == m_sceneManager->m_pendingNodeVisibility.end());
+ const bool updateValue = (!insertValue && foundIt.value() != shouldBeVisible);
+
+ if (insertValue || updateValue) {
+ qCDebug(lcSlidePlayer, "Scheduling node \"%s\" to be %s", obj->id().constData(), shouldBeVisible ? "shown" : "hidden");
+ if (updateValue)
+ *foundIt = shouldBeVisible;
+ else if (insertValue)
+ m_sceneManager->m_pendingNodeVisibility.insert(node, shouldBeVisible);
}
} else {
- qCDebug(lcSlidePlayer, "Scheduling effect \"%s\" to be %s", obj->id().constData(), shouldBeVisible ? "shown" : "hidden");
- obj->applyPropertyChanges(Q3DSPropertyChangeList({Q3DSPropertyChange::fromVariant(QLatin1String("eyeball"), QVariant::fromValue(shouldBeVisible))}));
- obj->notifyPropertyChanges(Q3DSPropertyChangeList({Q3DSPropertyChange::fromVariant(QLatin1String("eyeball"), QVariant::fromValue(shouldBeVisible))}));
+ Q3DSEffectInstance *effect = static_cast<Q3DSEffectInstance *>(obj);
+ if (effect->active() != shouldBeVisible) {
+ qCDebug(lcSlidePlayer, "Scheduling effect \"%s\" to be %s", obj->id().constData(), shouldBeVisible ? "shown" : "hidden");
+ obj->applyPropertyChanges(Q3DSPropertyChangeList({Q3DSPropertyChange::fromVariant(QLatin1String("eyeball"), QVariant::fromValue(shouldBeVisible))}));
+ obj->notifyPropertyChanges(Q3DSPropertyChangeList({Q3DSPropertyChange::fromVariant(QLatin1String("eyeball"), QVariant::fromValue(shouldBeVisible))}));
+ }
}
}