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 "parameter_p.h"
5#include <Qt3DRender/qparameter.h>
6#include <Qt3DRender/private/qparameter_p.h>
7#include <Qt3DRender/qtexture.h>
8#include <Qt3DRender/qshaderdata.h>
9#include <Qt3DRender/private/buffer_p.h>
10
11#include <Qt3DRender/private/managers_p.h>
12#include <Qt3DRender/private/stringtoint_p.h>
13
14QT_BEGIN_NAMESPACE
15
16using namespace Qt3DCore;
17
18namespace Qt3DRender {
19namespace Render {
20
21Parameter::Parameter()
22 : BackendNode()
23 , m_nameId(-1)
24{
25}
26
27void Parameter::cleanup()
28{
29 QBackendNode::setEnabled(false);
30 m_nameId = -1;
31 m_name.clear();
32 m_uniformValue = UniformValue();
33 m_backendValue = {};
34}
35
36void Parameter::syncFromFrontEnd(const QNode *frontEnd, bool firstTime)
37{
38 const QParameter *node = qobject_cast<const QParameter *>(object: frontEnd);
39 if (!node)
40 return;
41
42 AbstractRenderer::BackendNodeDirtySet dirty = firstTime ? AbstractRenderer::ParameterDirty : static_cast<AbstractRenderer::BackendNodeDirtyFlag>(0);
43 if (node->isEnabled() != isEnabled())
44 dirty |= (AbstractRenderer::MaterialDirty | AbstractRenderer::ParameterDirty);
45
46 if (node->name() != m_name) {
47 m_name = node->name();
48 m_nameId = StringToInt::lookupId(str: m_name);
49 dirty |= (AbstractRenderer::MaterialDirty | AbstractRenderer::ParameterDirty);
50 }
51
52 QParameterPrivate* d = static_cast<QParameterPrivate *>(QParameterPrivate::get(q: const_cast<QParameter *>(node)));
53 if (d->m_backendValue != m_backendValue) {
54 m_backendValue = d->m_backendValue;
55 m_uniformValue = UniformValue::fromVariant(variant: m_backendValue);
56 dirty |= (AbstractRenderer::ParameterDirty);
57 }
58
59 if (dirty)
60 markDirty(changes: dirty);
61
62 BackendNode::syncFromFrontEnd(frontEnd, firstTime);
63}
64
65QString Parameter::name() const
66{
67 return m_name;
68}
69
70} // namespace Render
71} // namespace Qt3DRender
72
73QT_END_NAMESPACE
74

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