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 "filterkey_p.h"
5#include <Qt3DRender/private/qfilterkey_p.h>
6
7QT_BEGIN_NAMESPACE
8
9using namespace Qt3DCore;
10
11namespace Qt3DRender {
12namespace Render {
13
14FilterKey::FilterKey()
15 : BackendNode()
16{
17}
18
19FilterKey::~FilterKey()
20{
21 cleanup();
22}
23
24void FilterKey::cleanup()
25{
26 QBackendNode::setEnabled(false);
27 m_name.clear();
28 m_value.clear();
29}
30
31void FilterKey::syncFromFrontEnd(const QNode *frontEnd, bool firstTime)
32{
33 const QFilterKey *node = qobject_cast<const QFilterKey *>(object: frontEnd);
34 if (!node)
35 return;
36
37 BackendNode::syncFromFrontEnd(frontEnd, firstTime);
38
39 if (node->name() != m_name) {
40 m_name = node->name();
41 markDirty(changes: AbstractRenderer::AllDirty);
42 }
43
44 if (node->value() != m_value) {
45 m_value = node->value();
46 markDirty(changes: AbstractRenderer::AllDirty);
47 }
48}
49
50bool FilterKey::equals(const FilterKey &other) const
51{
52 if (&other == this)
53 return true;
54 // TODO create a QVaraint::fastCompare function that returns false
55 // if types are not equal. For now, applying
56 // https://codereview.qt-project.org/#/c/204484/
57 // and adding the following early comparison of the types should give
58 // an equivalent performance gain:
59 return (other.value().metaType() == value().metaType() &&
60 other.name() == name() &&
61 other.value() == value());
62}
63
64} // namespace Render
65} // namespace Qt3DRender
66
67QT_END_NAMESPACE
68

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