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 "layerfilternode_p.h"
5#include "qlayerfilter.h"
6#include <Qt3DRender/private/qlayerfilter_p.h>
7#include <algorithm>
8
9QT_BEGIN_NAMESPACE
10
11using namespace Qt3DCore;
12
13namespace Qt3DRender {
14namespace Render {
15
16LayerFilterNode::LayerFilterNode()
17 : FrameGraphNode(FrameGraphNode::LayerFilter)
18 , m_filterMode(QLayerFilter::AcceptAnyMatchingLayers)
19{
20}
21
22void LayerFilterNode::syncFromFrontEnd(const QNode *frontEnd, bool firstTime)
23{
24 const QLayerFilter *node = qobject_cast<const QLayerFilter *>(object: frontEnd);
25 if (!node)
26 return;
27
28 FrameGraphNode::syncFromFrontEnd(frontEnd, firstTime);
29
30 if (m_filterMode != node->filterMode()) {
31 m_filterMode = node->filterMode();
32 markDirty(changes: AbstractRenderer::FrameGraphDirty|AbstractRenderer::LayersDirty);
33 }
34
35 auto layerIds = qIdsForNodes(nodes: node->layers());
36 std::sort(first: std::begin(cont&: layerIds), last: std::end(cont&: layerIds));
37 if (m_layerIds != layerIds) {
38 m_layerIds = layerIds;
39 markDirty(changes: AbstractRenderer::FrameGraphDirty|AbstractRenderer::LayersDirty);
40 }
41}
42
43QNodeIdVector LayerFilterNode::layerIds() const
44{
45 return m_layerIds;
46}
47
48void LayerFilterNode::setLayerIds(const QNodeIdVector &list)
49{
50 m_layerIds = list;
51}
52
53QLayerFilter::FilterMode LayerFilterNode::filterMode() const
54{
55 return m_filterMode;
56}
57
58} // namespace Render
59} // namespace Qt3DRender
60
61QT_END_NAMESPACE
62

source code of qt3d/src/render/framegraph/layerfilternode.cpp