1 | // Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). |
2 | // Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies). |
3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
4 | |
5 | #include <Qt3DQuickRender/private/quick3drenderpass_p.h> |
6 | |
7 | QT_BEGIN_NAMESPACE |
8 | |
9 | namespace Qt3DRender { |
10 | namespace Render { |
11 | namespace Quick { |
12 | |
13 | Quick3DRenderPass::Quick3DRenderPass(QObject *parent) |
14 | : QObject(parent) |
15 | { |
16 | } |
17 | |
18 | QQmlListProperty<QFilterKey> Quick3DRenderPass::filterKeyList() |
19 | { |
20 | using qt_size_type = qsizetype; |
21 | using ListContentType = QFilterKey; |
22 | auto appendFunction = [](QQmlListProperty<ListContentType> *list, ListContentType *filterKey) { |
23 | Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(object: list->object); |
24 | rPass->parentRenderPass()->addFilterKey(filterKey); |
25 | }; |
26 | auto countFunction = [](QQmlListProperty<ListContentType> *list) -> qt_size_type { |
27 | Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(object: list->object); |
28 | return rPass->parentRenderPass()->filterKeys().size(); |
29 | }; |
30 | auto atFunction = [](QQmlListProperty<ListContentType> *list, qt_size_type index) -> ListContentType * { |
31 | Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(object: list->object); |
32 | return rPass->parentRenderPass()->filterKeys().at(i: index); |
33 | }; |
34 | auto clearFunction = [](QQmlListProperty<ListContentType> *list) { |
35 | Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(object: list->object); |
36 | const auto keys = rPass->parentRenderPass()->filterKeys(); |
37 | for (QFilterKey *c : keys) |
38 | rPass->parentRenderPass()->removeFilterKey(filterKey: c); |
39 | }; |
40 | |
41 | return QQmlListProperty<ListContentType>(this, nullptr, appendFunction, countFunction, atFunction, clearFunction); |
42 | } |
43 | |
44 | QQmlListProperty<QRenderState> Quick3DRenderPass::renderStateList() |
45 | { |
46 | using qt_size_type = qsizetype; |
47 | using ListContentType = QRenderState; |
48 | auto appendFunction = [](QQmlListProperty<ListContentType> *list, ListContentType *state) { |
49 | Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(object: list->object); |
50 | rPass->parentRenderPass()->addRenderState(state); |
51 | }; |
52 | auto countFunction = [](QQmlListProperty<ListContentType> *list) -> qt_size_type { |
53 | Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(object: list->object); |
54 | return rPass->parentRenderPass()->renderStates().size(); |
55 | }; |
56 | auto atFunction = [](QQmlListProperty<ListContentType> *list, qt_size_type index) -> ListContentType * { |
57 | Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(object: list->object); |
58 | return rPass->parentRenderPass()->renderStates().at(i: index); |
59 | }; |
60 | auto clearFunction = [](QQmlListProperty<ListContentType> *list) { |
61 | Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(object: list->object); |
62 | const auto states = rPass->parentRenderPass()->renderStates(); |
63 | for (QRenderState *s : states) |
64 | rPass->parentRenderPass()->removeRenderState(state: s); |
65 | }; |
66 | |
67 | return QQmlListProperty<ListContentType>(this, nullptr, appendFunction, countFunction, atFunction, clearFunction); |
68 | } |
69 | |
70 | QQmlListProperty<QParameter> Quick3DRenderPass::parameterList() |
71 | { |
72 | using qt_size_type = qsizetype; |
73 | using ListContentType = QParameter; |
74 | auto appendFunction = [](QQmlListProperty<ListContentType> *list, ListContentType *param) { |
75 | Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(object: list->object); |
76 | rPass->parentRenderPass()->addParameter(p: param); |
77 | }; |
78 | auto countFunction = [](QQmlListProperty<ListContentType> *list) -> qt_size_type { |
79 | Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(object: list->object); |
80 | return rPass->parentRenderPass()->parameters().size(); |
81 | }; |
82 | auto atFunction = [](QQmlListProperty<ListContentType> *list, qt_size_type index) -> ListContentType * { |
83 | Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(object: list->object); |
84 | return rPass->parentRenderPass()->parameters().at(i: index); |
85 | }; |
86 | auto clearFunction = [](QQmlListProperty<ListContentType> *list) { |
87 | Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(object: list->object); |
88 | const auto parameters = rPass->parentRenderPass()->parameters(); |
89 | for (QParameter *p : parameters) |
90 | rPass->parentRenderPass()->removeParameter(p); |
91 | }; |
92 | |
93 | return QQmlListProperty<ListContentType>(this, nullptr, appendFunction, countFunction, atFunction, clearFunction); |
94 | } |
95 | |
96 | } // namespace Quick |
97 | } // namespace Render |
98 | } // namespace Qt3DRender |
99 | |
100 | QT_END_NAMESPACE |
101 | |
102 | #include "moc_quick3drenderpass_p.cpp" |
103 | |