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 "qcolormask.h"
5#include "qcolormask_p.h"
6
7QT_BEGIN_NAMESPACE
8
9namespace Qt3DRender {
10
11/*!
12 \class Qt3DRender::QColorMask
13 \inmodule Qt3DRender
14 \since 5.7
15 \brief Allows specifying which color components should be written to the
16 currently bound frame buffer.
17
18 By default, the property for each color component (red, green, blue, alpha)
19 is set to \c true which means they will be written to the frame buffer.
20 Setting any of the color component to \c false will prevent it from being
21 written into the frame buffer.
22 */
23
24/*!
25 \qmltype ColorMask
26 \inqmlmodule Qt3D.Render
27 \since 5.7
28 \inherits RenderState
29 \instantiates Qt3DRender::QColorMask
30 \brief Allows specifying which color components should be written to the
31 currently bound frame buffer.
32
33 By default, the property for each color component (red, green, blue, alpha)
34 is set to \c true which means they will be written to the frame buffer.
35 Setting any of the color component to \c false will prevent it from being
36 written into the frame buffer.
37 */
38
39/*!
40 \qmlproperty bool ColorMask::redMasked
41 Holds whether red color component should be written to the frame buffer.
42*/
43
44/*!
45 \qmlproperty bool ColorMask::greenMasked
46 Holds whether green color component should be written to the frame buffer.
47*/
48
49/*!
50 \qmlproperty bool ColorMask::blueMasked
51 Holds whether blue color component should be written to the frame buffer.
52*/
53
54/*!
55 \qmlproperty bool ColorMask::alphaMasked
56 Holds whether alpha component should be written to the frame buffer.
57*/
58
59
60/*!
61 Constructs a new Qt3DCore::QColorMask instance with \a parent as parent.
62 */
63QColorMask::QColorMask(QNode *parent)
64 : QRenderState(*new QColorMaskPrivate, parent)
65{
66}
67
68/*! \internal */
69QColorMask::~QColorMask()
70{
71}
72
73bool QColorMask::isRedMasked() const
74{
75 Q_D(const QColorMask);
76 return d->m_redMasked;
77}
78
79bool QColorMask::isGreenMasked() const
80{
81 Q_D(const QColorMask);
82 return d->m_greenMasked;
83}
84
85bool QColorMask::isBlueMasked() const
86{
87 Q_D(const QColorMask);
88 return d->m_blueMasked;
89}
90
91bool QColorMask::isAlphaMasked() const
92{
93 Q_D(const QColorMask);
94 return d->m_alphaMasked;
95}
96
97/*!
98 \property QColorMask::redMasked
99 Holds whether the red color component should be written to the frame buffer.
100 */
101void QColorMask::setRedMasked(bool redMasked)
102{
103 Q_D(QColorMask);
104 if (redMasked != d->m_redMasked) {
105 d->m_redMasked = redMasked;
106 emit redMaskedChanged(redMasked);
107 }
108}
109
110/*!
111 \property QColorMask::greenMasked
112 Holds whether the green color component should be written to the frame buffer.
113 */
114void QColorMask::setGreenMasked(bool greenMasked)
115{
116 Q_D(QColorMask);
117 if (greenMasked != d->m_greenMasked) {
118 d->m_greenMasked = greenMasked;
119 emit greenMaskedChanged(greenMasked);
120 }
121}
122
123/*!
124 \property QColorMask::blueMasked
125 Holds whether the blue color component should be written to the frame buffer.
126 */
127void QColorMask::setBlueMasked(bool blueMasked)
128{
129 Q_D(QColorMask);
130 if (blueMasked != d->m_blueMasked) {
131 d->m_blueMasked = blueMasked;
132 emit blueMaskedChanged(blueMasked);
133 }
134}
135
136/*!
137 \property QColorMask::alphaMasked
138 Holds whether the alphaMasked component should be written to the frame buffer.
139 */
140void QColorMask::setAlphaMasked(bool alphaMasked)
141{
142 Q_D(QColorMask);
143 if (alphaMasked != d->m_alphaMasked) {
144 d->m_alphaMasked = alphaMasked;
145 emit alphaMaskedChanged(alphaMasked);
146 }
147}
148
149} // namespace Qt3DRender
150
151QT_END_NAMESPACE
152
153#include "moc_qcolormask.cpp"
154
155

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