1// Copyright (C) 2017 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#ifndef QT3DRENDER_QSHADERGRAPH_P_H
5#define QT3DRENDER_QSHADERGRAPH_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <Qt3DRender/private/qt3drender_global_p.h>
19
20#include <Qt3DRender/private/qshadernode_p.h>
21
22QT_BEGIN_NAMESPACE
23
24namespace Qt3DRender
25{
26class QShaderGraph
27{
28public:
29 class Edge
30 {
31 public:
32 QStringList layers;
33 QUuid sourceNodeUuid;
34 QString sourcePortName;
35 QUuid targetNodeUuid;
36 QString targetPortName;
37 };
38
39 class Statement
40 {
41 public:
42 Q_3DRENDERSHARED_PRIVATE_EXPORT QUuid uuid() const noexcept;
43 Q_3DRENDERSHARED_PRIVATE_EXPORT int portIndex(QShaderNodePort::Direction direction, const QString &portName) const noexcept;
44
45 QShaderNode node;
46 QList<int> inputs;
47 QList<int> outputs;
48 };
49
50 Q_3DRENDERSHARED_PRIVATE_EXPORT void addNode(const QShaderNode &node);
51 Q_3DRENDERSHARED_PRIVATE_EXPORT void removeNode(const QShaderNode &node);
52 Q_3DRENDERSHARED_PRIVATE_EXPORT QList<QShaderNode> nodes() const noexcept;
53
54 Q_3DRENDERSHARED_PRIVATE_EXPORT void addEdge(const Edge &edge);
55 Q_3DRENDERSHARED_PRIVATE_EXPORT void removeEdge(const Edge &edge);
56 Q_3DRENDERSHARED_PRIVATE_EXPORT QList<Edge> edges() const noexcept;
57
58 Q_3DRENDERSHARED_PRIVATE_EXPORT QList<Statement> createStatements(const QStringList &enabledLayers = QStringList()) const;
59
60private:
61 QList<QShaderNode> m_nodes;
62 QList<Edge> m_edges;
63};
64
65Q_3DRENDERSHARED_PRIVATE_EXPORT bool operator==(const QShaderGraph::Edge &lhs, const QShaderGraph::Edge &rhs) noexcept;
66
67inline bool operator!=(const QShaderGraph::Edge &lhs, const QShaderGraph::Edge &rhs) noexcept
68{
69 return !(lhs == rhs);
70}
71
72Q_3DRENDERSHARED_PRIVATE_EXPORT bool operator==(const QShaderGraph::Statement &lhs, const QShaderGraph::Statement &rhs) noexcept;
73
74inline bool operator!=(const QShaderGraph::Statement &lhs, const QShaderGraph::Statement &rhs) noexcept
75{
76 return !(lhs == rhs);
77}
78
79}
80
81Q_DECLARE_TYPEINFO(Qt3DRender::QShaderGraph, Q_RELOCATABLE_TYPE);
82Q_DECLARE_TYPEINFO(Qt3DRender::QShaderGraph::Edge, Q_RELOCATABLE_TYPE);
83Q_DECLARE_TYPEINFO(Qt3DRender::QShaderGraph::Statement, Q_RELOCATABLE_TYPE);
84QT_END_NAMESPACE
85
86Q_DECLARE_METATYPE(Qt3DRender::QShaderGraph)
87Q_DECLARE_METATYPE(Qt3DRender::QShaderGraph::Edge)
88Q_DECLARE_METATYPE(Qt3DRender::QShaderGraph::Statement)
89
90#endif // QT3DRENDER_QSHADERGRAPH_P_H
91

source code of qt3d/src/render/shadergraph/qshadergraph_p.h