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 <Qt3DQuickRender/private/quick3dshaderdataarray_p.h>
5#include <Qt3DRender/private/qshaderdata_p.h>
6
7QT_BEGIN_NAMESPACE
8
9namespace Qt3DRender {
10namespace Render {
11namespace Quick {
12
13class Quick3DShaderDataArrayPrivate : public Qt3DCore::QNodePrivate
14{
15public:
16 Quick3DShaderDataArrayPrivate()
17 : QNodePrivate()
18 {}
19
20 QList<QShaderData *> m_values;
21};
22
23Quick3DShaderDataArray::Quick3DShaderDataArray(QNode *parent)
24 : QNode(*new Quick3DShaderDataArrayPrivate, parent)
25{
26}
27
28QQmlListProperty<QShaderData> Quick3DShaderDataArray::valuesList()
29{
30 using qt_size_type = qsizetype;
31 using ListContentType = QShaderData;
32 auto appendFunction = [](QQmlListProperty<ListContentType> *list, ListContentType *bar) {
33 Quick3DShaderDataArray *self = static_cast<Quick3DShaderDataArray *>(list->object);
34 static_cast<Quick3DShaderDataArrayPrivate *>(Quick3DShaderDataArrayPrivate::get(q: self))->m_values.append(t: bar);
35 };
36 auto countFunction = [](QQmlListProperty<ListContentType> *list) -> qt_size_type {
37 Quick3DShaderDataArray *self = static_cast<Quick3DShaderDataArray *>(list->object);
38 return static_cast<Quick3DShaderDataArrayPrivate *>(Quick3DShaderDataArrayPrivate::get(q: self))->m_values.size();
39 };
40 auto atFunction = [](QQmlListProperty<ListContentType> *list, qt_size_type index) -> ListContentType * {
41 Quick3DShaderDataArray *self = static_cast<Quick3DShaderDataArray *>(list->object);
42 return static_cast<Quick3DShaderDataArrayPrivate *>(Quick3DShaderDataArrayPrivate::get(q: self))->m_values.at(i: index);
43 };
44 auto clearFunction = [](QQmlListProperty<ListContentType> *list) {
45 Quick3DShaderDataArray *self = static_cast<Quick3DShaderDataArray *>(list->object);
46 static_cast<Quick3DShaderDataArrayPrivate *>(Quick3DShaderDataArrayPrivate::get(q: self))->m_values.clear();
47 };
48
49 return QQmlListProperty<ListContentType>(this, nullptr, appendFunction, countFunction, atFunction, clearFunction);
50}
51
52QList<QShaderData *> Quick3DShaderDataArray::values() const
53{
54 Q_D(const Quick3DShaderDataArray);
55 return d->m_values;
56}
57
58// TODO: Avoid cloning here
59//void Quick3DShaderDataArray::copy(const QNode *ref)
60//{
61// QNode::copy(ref);
62// const Quick3DShaderDataArray *dataArray = static_cast<const Quick3DShaderDataArray *>(ref);
63// Q_FOREACH (QShaderData *v, dataArray->d_func()->m_values)
64// d_func()->m_values.append(static_cast<QShaderData *>(QNode::clone(v)));
65//}
66
67} // namespace Quick
68} // namespace Render
69} // namespace Qt3DRender
70
71QT_END_NAMESPACE
72
73#include "moc_quick3dshaderdataarray_p.cpp"
74

source code of qt3d/src/quick3d/quick3drender/items/quick3dshaderdataarray.cpp