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 "renderstates_p.h" |
6 | |
7 | #include <Qt3DRender/qrenderstate.h> |
8 | #include <Qt3DRender/qcullface.h> |
9 | #include <Qt3DRender/qpointsize.h> |
10 | |
11 | #include <Qt3DRender/private/qstenciloperation_p.h> |
12 | #include <Qt3DRender/private/qstenciltest_p.h> |
13 | #include <Qt3DRender/qblendequationarguments.h> |
14 | #include <Qt3DRender/qblendequation.h> |
15 | #include <Qt3DRender/qalphatest.h> |
16 | #include <Qt3DRender/qdepthrange.h> |
17 | #include <Qt3DRender/qdepthtest.h> |
18 | #include <Qt3DRender/qrastermode.h> |
19 | #include <Qt3DRender/qfrontface.h> |
20 | #include <Qt3DRender/qscissortest.h> |
21 | #include <Qt3DRender/qpolygonoffset.h> |
22 | #include <Qt3DRender/qcolormask.h> |
23 | #include <Qt3DRender/qclipplane.h> |
24 | #include <Qt3DRender/qstencilmask.h> |
25 | #include <Qt3DRender/qlinewidth.h> |
26 | |
27 | QT_BEGIN_NAMESPACE |
28 | |
29 | namespace Qt3DRender { |
30 | namespace Render { |
31 | |
32 | void RenderStateImpl::updateProperties(const QRenderState *) |
33 | { |
34 | } |
35 | |
36 | void BlendEquationArguments::updateProperties(const QRenderState *node) |
37 | { |
38 | const QBlendEquationArguments *args = static_cast<const QBlendEquationArguments *>(node); |
39 | |
40 | std::get<0>(t&: m_values) = args->sourceRgb(); |
41 | std::get<1>(t&: m_values) = args->destinationRgb(); |
42 | std::get<2>(t&: m_values) = args->sourceAlpha(); |
43 | std::get<3>(t&: m_values) = args->destinationAlpha(); |
44 | std::get<4>(t&: m_values) = args->isEnabled(); |
45 | std::get<5>(t&: m_values) = args->bufferIndex(); |
46 | } |
47 | |
48 | void BlendEquation::updateProperties(const QRenderState *node) |
49 | { |
50 | const QBlendEquation *equation = static_cast<const QBlendEquation *>(node); |
51 | std::get<0>(t&: m_values) = equation->blendFunction(); |
52 | } |
53 | |
54 | void AlphaFunc::updateProperties(const QRenderState *node) |
55 | { |
56 | const QAlphaTest *alphaTest = static_cast<const QAlphaTest *>(node); |
57 | std::get<0>(t&: m_values) = alphaTest->alphaFunction(); |
58 | std::get<1>(t&: m_values) = alphaTest->referenceValue(); |
59 | } |
60 | |
61 | void MSAAEnabled::updateProperties(const QRenderState *node) |
62 | { |
63 | std::get<0>(t&: m_values) = node->isEnabled(); |
64 | } |
65 | |
66 | void DepthRange::updateProperties(const QRenderState *node) |
67 | { |
68 | const QDepthRange *depthRange = static_cast<const QDepthRange *>(node); |
69 | |
70 | std::get<0>(t&: m_values) = depthRange->nearValue(); |
71 | std::get<1>(t&: m_values) = depthRange->farValue(); |
72 | } |
73 | |
74 | void DepthTest::updateProperties(const QRenderState *node) |
75 | { |
76 | const QDepthTest *depthTest = static_cast<const QDepthTest *>(node); |
77 | |
78 | std::get<0>(t&: m_values) = depthTest->depthFunction(); |
79 | } |
80 | |
81 | void RasterMode::updateProperties(const QRenderState *node) |
82 | { |
83 | const QRasterMode *rasterMode = static_cast<const QRasterMode *>(node); |
84 | |
85 | std::get<0>(t&: m_values) = rasterMode->faceMode(); |
86 | std::get<1>(t&: m_values) = rasterMode->rasterMode(); |
87 | } |
88 | |
89 | void CullFace::updateProperties(const QRenderState *node) |
90 | { |
91 | const QCullFace *cullFace = static_cast<const QCullFace *>(node); |
92 | |
93 | std::get<0>(t&: m_values) = cullFace->mode(); |
94 | } |
95 | |
96 | void FrontFace::updateProperties(const QRenderState *node) |
97 | { |
98 | const QFrontFace *frontFace = static_cast<const QFrontFace *>(node); |
99 | |
100 | std::get<0>(t&: m_values) = frontFace->direction(); |
101 | } |
102 | |
103 | void NoDepthMask::updateProperties(const QRenderState *node) |
104 | { |
105 | std::get<0>(t&: m_values) = !node->isEnabled(); |
106 | } |
107 | |
108 | void ScissorTest::updateProperties(const QRenderState *node) |
109 | { |
110 | const QScissorTest *scissorTest = static_cast<const QScissorTest *>(node); |
111 | |
112 | std::get<0>(t&: m_values) = scissorTest->left(); |
113 | std::get<1>(t&: m_values) = scissorTest->bottom(); |
114 | std::get<2>(t&: m_values) = scissorTest->width(); |
115 | std::get<3>(t&: m_values) = scissorTest->height(); |
116 | } |
117 | |
118 | void StencilTest::updateProperties(const QRenderState *node) |
119 | { |
120 | const QStencilTest *stencilTest = static_cast<const QStencilTest *>(node); |
121 | std::get<0>(t&: m_values) = stencilTest->front()->stencilFunction(); |
122 | std::get<1>(t&: m_values) = stencilTest->front()->referenceValue(); |
123 | std::get<2>(t&: m_values) = stencilTest->front()->comparisonMask(); |
124 | std::get<3>(t&: m_values) = stencilTest->back()->stencilFunction(); |
125 | std::get<4>(t&: m_values) = stencilTest->back()->referenceValue(); |
126 | std::get<5>(t&: m_values) = stencilTest->back()->comparisonMask(); |
127 | } |
128 | |
129 | void PointSize::updateProperties(const QRenderState *node) |
130 | { |
131 | const QPointSize *pointSize = static_cast<const QPointSize *>(node); |
132 | |
133 | std::get<0>(t&: m_values) = (pointSize->sizeMode() == QPointSize::Programmable); |
134 | std::get<1>(t&: m_values) = pointSize->value(); |
135 | } |
136 | |
137 | void PolygonOffset::updateProperties(const QRenderState *node) |
138 | { |
139 | const QPolygonOffset *offset = static_cast<const QPolygonOffset *>(node); |
140 | |
141 | std::get<0>(t&: m_values) = offset->scaleFactor(); |
142 | std::get<1>(t&: m_values) = offset->depthSteps(); |
143 | } |
144 | |
145 | void ColorMask::updateProperties(const QRenderState *node) |
146 | { |
147 | const QColorMask *colorMask = static_cast<const QColorMask *>(node); |
148 | |
149 | std::get<0>(t&: m_values) = colorMask->isRedMasked(); |
150 | std::get<1>(t&: m_values) = colorMask->isGreenMasked(); |
151 | std::get<2>(t&: m_values) = colorMask->isBlueMasked(); |
152 | std::get<3>(t&: m_values) = colorMask->isAlphaMasked(); |
153 | } |
154 | |
155 | void ClipPlane::updateProperties(const QRenderState *node) |
156 | { |
157 | const QClipPlane *clipPlane = static_cast<const QClipPlane *>(node); |
158 | |
159 | std::get<0>(t&: m_values) = clipPlane->planeIndex(); |
160 | std::get<1>(t&: m_values) = clipPlane->normal(); |
161 | std::get<2>(t&: m_values) = clipPlane->distance(); |
162 | } |
163 | |
164 | void StencilOp::updateProperties(const QRenderState *node) |
165 | { |
166 | const QStencilOperation *stencilOp = static_cast<const QStencilOperation *>(node); |
167 | |
168 | std::get<0>(t&: m_values) = stencilOp->front()->stencilTestFailureOperation(); |
169 | std::get<1>(t&: m_values) = stencilOp->front()->depthTestFailureOperation(); |
170 | std::get<2>(t&: m_values) = stencilOp->front()->allTestsPassOperation(); |
171 | std::get<3>(t&: m_values) = stencilOp->back()->stencilTestFailureOperation(); |
172 | std::get<4>(t&: m_values) = stencilOp->back()->depthTestFailureOperation(); |
173 | std::get<5>(t&: m_values) = stencilOp->back()->allTestsPassOperation(); |
174 | } |
175 | |
176 | void StencilMask::updateProperties(const QRenderState *node) |
177 | { |
178 | const QStencilMask *stencilMask = static_cast<const QStencilMask *>(node); |
179 | std::get<0>(t&: m_values) = stencilMask->frontOutputMask(); |
180 | std::get<1>(t&: m_values) = stencilMask->backOutputMask(); |
181 | } |
182 | |
183 | void LineWidth::updateProperties(const QRenderState *node) |
184 | { |
185 | const QLineWidth *lineWidth = static_cast<const QLineWidth *>(node); |
186 | std::get<0>(t&: m_values) = lineWidth->value(); |
187 | std::get<1>(t&: m_values) = lineWidth->smooth(); |
188 | } |
189 | |
190 | } // namespace Render |
191 | } // namespace Qt3DRender |
192 | |
193 | QT_END_NAMESPACE |
194 |