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_QSHADERNODE_P_H
5#define QT3DRENDER_QSHADERNODE_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/qshaderformat_p.h>
21#include <Qt3DRender/private/qshadernodeport_p.h>
22
23#include <QtCore/quuid.h>
24
25QT_BEGIN_NAMESPACE
26
27namespace Qt3DRender
28{
29class QShaderNode
30{
31public:
32 enum Type : char {
33 Invalid,
34 Input,
35 Output,
36 Function
37 };
38
39 class Rule
40 {
41 public:
42 Q_3DRENDERSHARED_PRIVATE_EXPORT Rule(const QByteArray &substitution = QByteArray(), const QByteArrayList &headerSnippets = QByteArrayList()) noexcept;
43
44 QByteArray substitution;
45 QByteArrayList headerSnippets;
46 };
47
48 Q_3DRENDERSHARED_PRIVATE_EXPORT Type type() const noexcept;
49
50 Q_3DRENDERSHARED_PRIVATE_EXPORT QUuid uuid() const noexcept;
51 Q_3DRENDERSHARED_PRIVATE_EXPORT void setUuid(const QUuid &uuid) noexcept;
52
53 Q_3DRENDERSHARED_PRIVATE_EXPORT QStringList layers() const noexcept;
54 Q_3DRENDERSHARED_PRIVATE_EXPORT void setLayers(const QStringList &layers) noexcept;
55
56 Q_3DRENDERSHARED_PRIVATE_EXPORT QList<QShaderNodePort> ports() const noexcept;
57 Q_3DRENDERSHARED_PRIVATE_EXPORT void addPort(const QShaderNodePort &port);
58 Q_3DRENDERSHARED_PRIVATE_EXPORT void removePort(const QShaderNodePort &port);
59
60 Q_3DRENDERSHARED_PRIVATE_EXPORT QStringList parameterNames() const;
61 Q_3DRENDERSHARED_PRIVATE_EXPORT QVariant parameter(const QString &name) const;
62 Q_3DRENDERSHARED_PRIVATE_EXPORT void setParameter(const QString &name, const QVariant &value);
63 Q_3DRENDERSHARED_PRIVATE_EXPORT void clearParameter(const QString &name);
64
65 Q_3DRENDERSHARED_PRIVATE_EXPORT void addRule(const QShaderFormat &format, const Rule &rule);
66 Q_3DRENDERSHARED_PRIVATE_EXPORT void removeRule(const QShaderFormat &format);
67
68 Q_3DRENDERSHARED_PRIVATE_EXPORT QList<QShaderFormat> availableFormats() const;
69 Q_3DRENDERSHARED_PRIVATE_EXPORT Rule rule(const QShaderFormat &format) const;
70
71private:
72 QUuid m_uuid;
73 QStringList m_layers;
74 QList<QShaderNodePort> m_ports;
75 QHash<QString, QVariant> m_parameters;
76 QList<QPair<QShaderFormat, QShaderNode::Rule>> m_rules;
77};
78
79Q_3DRENDERSHARED_PRIVATE_EXPORT bool operator==(const QShaderNode::Rule &lhs, const QShaderNode::Rule &rhs) noexcept;
80
81inline bool operator!=(const QShaderNode::Rule &lhs, const QShaderNode::Rule &rhs) noexcept
82{
83 return !(lhs == rhs);
84}
85
86}
87
88Q_DECLARE_TYPEINFO(Qt3DRender::QShaderNode, Q_RELOCATABLE_TYPE);
89Q_DECLARE_TYPEINFO(Qt3DRender::QShaderNode::Rule, Q_RELOCATABLE_TYPE);
90QT_END_NAMESPACE
91
92Q_DECLARE_METATYPE(Qt3DRender::QShaderNode)
93Q_DECLARE_METATYPE(Qt3DRender::QShaderNode::Rule)
94
95#endif // QT3DRENDER_QSHADERNODE_P_H
96

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