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#ifndef QT3DRENDER_QSHADERDATA_P_H
5#define QT3DRENDER_QSHADERDATA_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 for the convenience
12// of other Qt classes. 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 <private/qcomponent_p.h>
19#include <Qt3DRender/qshaderdata.h>
20#include <Qt3DRender/private/qt3drender_global_p.h>
21
22QT_BEGIN_NAMESPACE
23
24namespace Qt3DRender {
25
26namespace {
27
28const int qVectorShaderDataTypeId = qMetaTypeId<QList<QShaderData *>>();
29
30}
31
32class QShaderDataPropertyReader: public PropertyReaderInterface
33{
34 QVariant readProperty(const QVariant &v) override
35 {
36 const auto node = v.value<Qt3DCore::QNode *>();
37
38 if (node) {
39 return QVariant::fromValue(value: node->id());
40 } else if (v.userType() == qVectorShaderDataTypeId) {
41 QVariantList vlist;
42 const auto data_ = v.value<QList<QShaderData *>>();
43 for (QShaderData *data : data_) {
44 if (data)
45 vlist.append(t: QVariant::fromValue(value: data->id()));
46 }
47 return vlist;
48 }
49 return v;
50 }
51};
52
53class Q_3DRENDERSHARED_PRIVATE_EXPORT QShaderDataPrivate : public Qt3DCore::QComponentPrivate
54{
55public:
56 QShaderDataPrivate();
57 QShaderDataPrivate(PropertyReaderInterfacePtr reader);
58 PropertyReaderInterfacePtr m_propertyReader;
59
60 Q_DECLARE_PUBLIC(QShaderData)
61};
62
63} // namespace Qt3DRender
64
65QT_END_NAMESPACE
66
67#endif // QT3DRENDER_QSHADERDATA_P_H
68

source code of qt3d/src/render/materialsystem/qshaderdata_p.h