1 | // Copyright (C) 2016 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 "statevariant_p.h" |
5 | |
6 | QT_BEGIN_NAMESPACE |
7 | |
8 | namespace Qt3DRender { |
9 | namespace Render { |
10 | |
11 | RenderStateImpl *StateVariant::state() |
12 | { |
13 | switch (type) { |
14 | case BlendEquationArgumentsMask: |
15 | case BlendStateMask: |
16 | case AlphaTestMask: |
17 | case MSAAEnabledStateMask: |
18 | case DepthRangeMask: |
19 | case DepthTestStateMask: |
20 | case DepthWriteStateMask: |
21 | case CullFaceStateMask: |
22 | case FrontFaceStateMask: |
23 | case DitheringStateMask: |
24 | case ScissorStateMask: |
25 | case StencilTestStateMask: |
26 | case AlphaCoverageStateMask: |
27 | case PointSizeMask: |
28 | case PolygonOffsetStateMask: |
29 | case ColorStateMask: |
30 | case ClipPlaneMask: |
31 | case SeamlessCubemapMask: |
32 | case StencilOpMask: |
33 | case StencilWriteStateMask: |
34 | case LineWidthMask: |
35 | case RasterModeMask: |
36 | return &data.blendEquationArguments; |
37 | default: |
38 | Q_UNREACHABLE(); |
39 | } |
40 | } |
41 | |
42 | const RenderStateImpl *StateVariant::constState() const |
43 | { |
44 | switch (type) { |
45 | case BlendEquationArgumentsMask: |
46 | case BlendStateMask: |
47 | case AlphaTestMask: |
48 | case MSAAEnabledStateMask: |
49 | case DepthRangeMask: |
50 | case DepthTestStateMask: |
51 | case DepthWriteStateMask: |
52 | case CullFaceStateMask: |
53 | case FrontFaceStateMask: |
54 | case DitheringStateMask: |
55 | case ScissorStateMask: |
56 | case StencilTestStateMask: |
57 | case AlphaCoverageStateMask: |
58 | case PointSizeMask: |
59 | case PolygonOffsetStateMask: |
60 | case ColorStateMask: |
61 | case ClipPlaneMask: |
62 | case SeamlessCubemapMask: |
63 | case StencilOpMask: |
64 | case StencilWriteStateMask: |
65 | case LineWidthMask: |
66 | case RasterModeMask: |
67 | return &data.blendEquationArguments; |
68 | default: |
69 | Q_UNREACHABLE(); |
70 | } |
71 | } |
72 | |
73 | bool StateVariant::operator ==(const StateVariant &other) const |
74 | { |
75 | return (other.type == type && constState()->equalTo(renderState: *other.constState())); |
76 | } |
77 | |
78 | bool StateVariant::operator !=(const StateVariant &other) const |
79 | { |
80 | return !(*this == other); |
81 | } |
82 | |
83 | } // namespace Render |
84 | } // namespace Qt3DRender |
85 | |
86 | QT_END_NAMESPACE |
87 |