1// Copyright (C) 2015 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 "qstenciloperation.h"
5#include "qstenciloperation_p.h"
6#include "qstenciloperationarguments.h"
7
8QT_BEGIN_NAMESPACE
9
10namespace Qt3DRender {
11
12QStencilOperationPrivate::~QStencilOperationPrivate() = default;
13
14/*!
15 \class Qt3DRender::QStencilOperation
16 \brief The QStencilOperation class specifies stencil operation.
17 \since 5.7
18 \ingroup renderstates
19 \inmodule Qt3DRender
20
21 A Qt3DRender::QStencilOperation class specifies the stencil operations
22 for the front- and back-facing polygons. The stencil operation control
23 what is done to fragment when the stencil and depth test pass or fail.
24
25 \sa Qt3DRender::QStencilTest
26 */
27
28/*!
29 \qmltype StencilOperation
30 \brief The StencilOperation type specifies stencil operation.
31 \since 5.7
32 \ingroup renderstates
33 \inqmlmodule Qt3D.Render
34 \inherits RenderState
35 \instantiates Qt3DRender::QStencilOperation
36
37 A StencilOperation type specifies the stencil operations
38 for the front- and back-facing polygons. The stencil operation control
39 what is done to fragment when the stencil and depth test pass or fail.
40
41 \sa StencilTest
42 */
43
44/*!
45 \qmlproperty StencilOperationArguments StencilOperation::front
46 Holds the stencil operation arguments for front-facing polygons.
47*/
48
49/*!
50 \qmlproperty StencilOperationArguments StencilOperation::back
51 Holds the stencil operation arguments for back-facing polygons.
52*/
53
54/*!
55 \property QStencilOperation::front
56 Holds the stencil operation arguments for front-facing polygons.
57*/
58
59/*!
60 \property QStencilOperation::back
61 Holds the stencil operation arguments for back-facing polygons.
62*/
63
64/*!
65 The constructor creates a new QStencilOperation::QStencilOperation instance with
66 the specified \a parent.
67 */
68QStencilOperation::QStencilOperation(QNode *parent)
69 : QRenderState(*new QStencilOperationPrivate(), parent)
70{
71 Q_D(QStencilOperation);
72
73 const auto resend = [d]() { d->update(); };
74
75 (void) connect(sender: d->m_front, signal: &QStencilOperationArguments::allTestsPassOperationChanged, slot: resend);
76 (void) connect(sender: d->m_front, signal: &QStencilOperationArguments::depthTestFailureOperationChanged, slot: resend);
77 (void) connect(sender: d->m_front, signal: &QStencilOperationArguments::stencilTestFailureOperationChanged, slot: resend);
78 (void) connect(sender: d->m_front, signal: &QStencilOperationArguments::faceModeChanged, slot: resend);
79
80 (void) connect(sender: d->m_back, signal: &QStencilOperationArguments::allTestsPassOperationChanged, slot: resend);
81 (void) connect(sender: d->m_back, signal: &QStencilOperationArguments::depthTestFailureOperationChanged, slot: resend);
82 (void) connect(sender: d->m_back, signal: &QStencilOperationArguments::stencilTestFailureOperationChanged, slot: resend);
83 (void) connect(sender: d->m_back, signal: &QStencilOperationArguments::faceModeChanged, slot: resend);
84}
85
86/*! \internal */
87QStencilOperation::~QStencilOperation()
88{
89}
90
91/*! \internal */
92void QStencilOperationPrivate::fillData(QStencilOperationData &data) const
93{
94 data.front.face = m_front->faceMode();
95 data.front.stencilTestFailureOperation = m_front->stencilTestFailureOperation();
96 data.front.depthTestFailureOperation = m_front->depthTestFailureOperation();
97 data.front.allTestsPassOperation = m_front->allTestsPassOperation();
98 data.back.face = m_back->faceMode();
99 data.back.stencilTestFailureOperation = m_back->stencilTestFailureOperation();
100 data.back.depthTestFailureOperation = m_back->depthTestFailureOperation();
101 data.back.allTestsPassOperation = m_back->allTestsPassOperation();
102}
103
104QStencilOperationArguments *QStencilOperation::front() const
105{
106 Q_D(const QStencilOperation);
107 return d->m_front;
108}
109
110QStencilOperationArguments *QStencilOperation::back() const
111{
112 Q_D(const QStencilOperation);
113 return d->m_back;
114}
115
116} // namespace Qt3DRender
117
118QT_END_NAMESPACE
119
120#include "moc_qstenciloperation.cpp"
121

source code of qt3d/src/render/renderstates/qstenciloperation.cpp