1// Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include <Qt3DRender/private/effect_p.h>
5#include <Qt3DRender/qeffect.h>
6#include <Qt3DRender/qparameter.h>
7#include <Qt3DRender/qtechnique.h>
8#include <Qt3DRender/private/qeffect_p.h>
9
10#include <QVariant>
11#include <algorithm>
12
13QT_BEGIN_NAMESPACE
14
15using namespace Qt3DCore;
16
17namespace Qt3DRender {
18namespace Render {
19
20Effect::Effect()
21 : BackendNode()
22{
23}
24
25Effect::~Effect()
26{
27 cleanup();
28}
29
30void Effect::cleanup()
31{
32 QBackendNode::setEnabled(false);
33 m_parameterPack.clear();
34 m_techniques.clear();
35}
36
37void Effect::syncFromFrontEnd(const QNode *frontEnd, bool firstTime)
38{
39 BackendNode::syncFromFrontEnd(frontEnd, firstTime);
40 const QEffect *node = qobject_cast<const QEffect *>(object: frontEnd);
41 if (!node)
42 return;
43
44 auto parameters = qIdsForNodes(nodes: node->parameters());
45 std::sort(first: std::begin(cont&: parameters), last: std::end(cont&: parameters));
46 if (m_parameterPack.parameters() != parameters)
47 m_parameterPack.setParameters(parameters);
48
49 auto techniques = qIdsForNodes(nodes: node->techniques());
50 std::sort(first: std::begin(cont&: techniques), last: std::end(cont&: techniques));
51 if (m_techniques != techniques)
52 m_techniques = techniques;
53
54 if (!firstTime)
55 markDirty(changes: AbstractRenderer::AllDirty);
56}
57
58void Effect::appendRenderTechnique(Qt3DCore::QNodeId technique)
59{
60 if (!m_techniques.contains(t: technique))
61 m_techniques.append(t: technique);
62}
63
64QList<Qt3DCore::QNodeId> Effect::techniques() const
65{
66 return m_techniques;
67}
68
69QList<Qt3DCore::QNodeId> Effect::parameters() const
70{
71 return m_parameterPack.parameters();
72}
73
74} // namespace Render
75} // namespace Qt3DRender
76
77QT_END_NAMESPACE
78

source code of qt3d/src/render/materialsystem/effect.cpp