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 | |
7 | QT_BEGIN_NAMESPACE |
8 | |
9 | using namespace Qt3DCore; |
10 | |
11 | namespace Qt3DRender { |
12 | namespace Render { |
13 | |
14 | FilterKey::FilterKey() |
15 | : BackendNode() |
16 | { |
17 | } |
18 | |
19 | FilterKey::~FilterKey() |
20 | { |
21 | cleanup(); |
22 | } |
23 | |
24 | void FilterKey::cleanup() |
25 | { |
26 | QBackendNode::setEnabled(false); |
27 | m_name.clear(); |
28 | m_value.clear(); |
29 | } |
30 | |
31 | void 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 | |
50 | bool 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 | |
67 | QT_END_NAMESPACE |
68 |