1// Copyright (C) 2015 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 "statesetnode_p.h"
5
6#include <Qt3DRender/qrenderstateset.h>
7#include <Qt3DRender/private/qrenderstateset_p.h>
8#include <Qt3DRender/private/genericstate_p.h>
9#include <Qt3DRender/private/renderstateset_p.h>
10#include <Qt3DRender/qrenderstate.h>
11
12QT_BEGIN_NAMESPACE
13
14using namespace Qt3DCore;
15
16namespace Qt3DRender {
17namespace Render {
18
19StateSetNode::StateSetNode()
20 : FrameGraphNode(FrameGraphNode::StateSet)
21{
22}
23
24StateSetNode::~StateSetNode()
25{
26}
27
28QList<QNodeId> StateSetNode::renderStates() const
29{
30 return m_renderStates;
31}
32
33void StateSetNode::syncFromFrontEnd(const QNode *frontEnd, bool firstTime)
34{
35 const QRenderStateSet *node = qobject_cast<const QRenderStateSet *>(object: frontEnd);
36 if (!node)
37 return;
38
39 FrameGraphNode::syncFromFrontEnd(frontEnd, firstTime);
40
41 auto stateIds = qIdsForNodes(nodes: node->renderStates());
42 std::sort(first: std::begin(cont&: stateIds), last: std::end(cont&: stateIds));
43 if (m_renderStates != stateIds) {
44 m_renderStates = stateIds;
45 markDirty(changes: AbstractRenderer::FrameGraphDirty);
46 }
47}
48
49void StateSetNode::addRenderState(QNodeId renderStateId)
50{
51 if (!m_renderStates.contains(t: renderStateId))
52 m_renderStates.push_back(t: renderStateId);
53}
54
55void StateSetNode::removeRenderState(QNodeId renderStateId)
56{
57 m_renderStates.removeOne(t: renderStateId);
58}
59
60} // namespace Render
61
62} // namespace Qt3DRender
63
64QT_END_NAMESPACE
65

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