1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). |
4 | ** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies). |
5 | ** Contact: https://www.qt.io/licensing/ |
6 | ** |
7 | ** This file is part of the Qt3D module of the Qt Toolkit. |
8 | ** |
9 | ** $QT_BEGIN_LICENSE:LGPL$ |
10 | ** Commercial License Usage |
11 | ** Licensees holding valid commercial Qt licenses may use this file in |
12 | ** accordance with the commercial license agreement provided with the |
13 | ** Software or, alternatively, in accordance with the terms contained in |
14 | ** a written agreement between you and The Qt Company. For licensing terms |
15 | ** and conditions see https://www.qt.io/terms-conditions. For further |
16 | ** information use the contact form at https://www.qt.io/contact-us. |
17 | ** |
18 | ** GNU Lesser General Public License Usage |
19 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
20 | ** General Public License version 3 as published by the Free Software |
21 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
22 | ** packaging of this file. Please review the following information to |
23 | ** ensure the GNU Lesser General Public License version 3 requirements |
24 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
25 | ** |
26 | ** GNU General Public License Usage |
27 | ** Alternatively, this file may be used under the terms of the GNU |
28 | ** General Public License version 2.0 or (at your option) the GNU General |
29 | ** Public license version 3 or any later version approved by the KDE Free |
30 | ** Qt Foundation. The licenses are as published by the Free Software |
31 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
32 | ** included in the packaging of this file. Please review the following |
33 | ** information to ensure the GNU General Public License requirements will |
34 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
35 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
36 | ** |
37 | ** $QT_END_LICENSE$ |
38 | ** |
39 | ****************************************************************************/ |
40 | |
41 | #include <Qt3DQuickRender/private/quick3drenderpass_p.h> |
42 | |
43 | QT_BEGIN_NAMESPACE |
44 | |
45 | namespace Qt3DRender { |
46 | namespace Render { |
47 | namespace Quick { |
48 | |
49 | Quick3DRenderPass::Quick3DRenderPass(QObject *parent) |
50 | : QObject(parent) |
51 | { |
52 | } |
53 | |
54 | QQmlListProperty<QFilterKey> Quick3DRenderPass::filterKeyList() |
55 | { |
56 | return QQmlListProperty<QFilterKey>(this, 0, |
57 | &Quick3DRenderPass::appendFilterKey, |
58 | &Quick3DRenderPass::filterKeysCount, |
59 | &Quick3DRenderPass::filterKeyAt, |
60 | &Quick3DRenderPass::clearFilterKey); |
61 | } |
62 | |
63 | QQmlListProperty<QRenderState> Quick3DRenderPass::renderStateList() |
64 | { |
65 | return QQmlListProperty<QRenderState>(this, 0, |
66 | &Quick3DRenderPass::appendRenderState, |
67 | &Quick3DRenderPass::renderStateCount, |
68 | &Quick3DRenderPass::renderStateAt, |
69 | &Quick3DRenderPass::clearRenderStates); |
70 | } |
71 | |
72 | QQmlListProperty<QParameter> Quick3DRenderPass::parameterList() |
73 | { |
74 | return QQmlListProperty<QParameter>(this, 0, |
75 | &Quick3DRenderPass::appendParameter, |
76 | &Quick3DRenderPass::parametersCount, |
77 | &Quick3DRenderPass::parameterAt, |
78 | &Quick3DRenderPass::clearParameterList); |
79 | } |
80 | |
81 | void Quick3DRenderPass::appendFilterKey(QQmlListProperty<QFilterKey> *list, QFilterKey *filterKey) |
82 | { |
83 | Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(object: list->object); |
84 | rPass->parentRenderPass()->addFilterKey(filterKey); |
85 | } |
86 | |
87 | QFilterKey *Quick3DRenderPass::filterKeyAt(QQmlListProperty<QFilterKey> *list, int index) |
88 | { |
89 | Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(object: list->object); |
90 | return rPass->parentRenderPass()->filterKeys().at(i: index); |
91 | } |
92 | |
93 | int Quick3DRenderPass::filterKeysCount(QQmlListProperty<QFilterKey> *list) |
94 | { |
95 | Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(object: list->object); |
96 | return rPass->parentRenderPass()->filterKeys().count(); |
97 | } |
98 | |
99 | void Quick3DRenderPass::clearFilterKey(QQmlListProperty<QFilterKey> *list) |
100 | { |
101 | Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(object: list->object); |
102 | const auto keys = rPass->parentRenderPass()->filterKeys(); |
103 | for (QFilterKey *c : keys) |
104 | rPass->parentRenderPass()->removeFilterKey(filterKey: c); |
105 | } |
106 | |
107 | void Quick3DRenderPass::appendRenderState(QQmlListProperty<QRenderState> *list, QRenderState *state) |
108 | { |
109 | Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(object: list->object); |
110 | rPass->parentRenderPass()->addRenderState(state); |
111 | } |
112 | |
113 | QRenderState *Quick3DRenderPass::renderStateAt(QQmlListProperty<QRenderState> *list, int index) |
114 | { |
115 | Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(object: list->object); |
116 | return rPass->parentRenderPass()->renderStates().at(i: index); |
117 | } |
118 | |
119 | int Quick3DRenderPass::renderStateCount(QQmlListProperty<QRenderState> *list) |
120 | { |
121 | Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(object: list->object); |
122 | return rPass->parentRenderPass()->renderStates().count(); |
123 | } |
124 | |
125 | void Quick3DRenderPass::clearRenderStates(QQmlListProperty<QRenderState> *list) |
126 | { |
127 | Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(object: list->object); |
128 | const auto states = rPass->parentRenderPass()->renderStates(); |
129 | for (QRenderState *s : states) |
130 | rPass->parentRenderPass()->removeRenderState(state: s); |
131 | } |
132 | |
133 | void Quick3DRenderPass::appendParameter(QQmlListProperty<QParameter> *list, QParameter *param) |
134 | { |
135 | Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(object: list->object); |
136 | rPass->parentRenderPass()->addParameter(p: param); |
137 | } |
138 | |
139 | QParameter *Quick3DRenderPass::parameterAt(QQmlListProperty<QParameter> *list, int index) |
140 | { |
141 | Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(object: list->object); |
142 | return rPass->parentRenderPass()->parameters().at(i: index); |
143 | } |
144 | |
145 | int Quick3DRenderPass::parametersCount(QQmlListProperty<QParameter> *list) |
146 | { |
147 | Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(object: list->object); |
148 | return rPass->parentRenderPass()->parameters().count(); |
149 | } |
150 | |
151 | void Quick3DRenderPass::clearParameterList(QQmlListProperty<QParameter> *list) |
152 | { |
153 | Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(object: list->object); |
154 | const auto parameters = rPass->parentRenderPass()->parameters(); |
155 | for (QParameter *p : parameters) |
156 | rPass->parentRenderPass()->removeParameter(p); |
157 | } |
158 | |
159 | |
160 | } // namespace Quick |
161 | } // namespace Render |
162 | } // namespace Qt3DRender |
163 | |
164 | QT_END_NAMESPACE |
165 | |