| 1 | /**************************************************************************** | 
| 2 | ** | 
| 3 | ** Copyright (C) 2015 Paul Lemire | 
| 4 | ** Contact: https://www.qt.io/licensing/ | 
| 5 | ** | 
| 6 | ** This file is part of the Qt3D module of the Qt Toolkit. | 
| 7 | ** | 
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | 
| 9 | ** Commercial License Usage | 
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | 
| 11 | ** accordance with the commercial license agreement provided with the | 
| 12 | ** Software or, alternatively, in accordance with the terms contained in | 
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | 
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | 
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | 
| 16 | ** | 
| 17 | ** GNU Lesser General Public License Usage | 
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
| 19 | ** General Public License version 3 as published by the Free Software | 
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | 
| 21 | ** packaging of this file. Please review the following information to | 
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | 
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | 
| 24 | ** | 
| 25 | ** GNU General Public License Usage | 
| 26 | ** Alternatively, this file may be used under the terms of the GNU | 
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | 
| 28 | ** Public license version 3 or any later version approved by the KDE Free | 
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | 
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | 
| 31 | ** included in the packaging of this file. Please review the following | 
| 32 | ** information to ensure the GNU General Public License requirements will | 
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | 
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | 
| 35 | ** | 
| 36 | ** $QT_END_LICENSE$ | 
| 37 | ** | 
| 38 | ****************************************************************************/ | 
| 39 |  | 
| 40 | #include "qstencilmask.h" | 
| 41 | #include "qstencilmask_p.h" | 
| 42 | #include <Qt3DRender/private/qrenderstatecreatedchange_p.h> | 
| 43 |  | 
| 44 | QT_BEGIN_NAMESPACE | 
| 45 |  | 
| 46 | namespace Qt3DRender { | 
| 47 |  | 
| 48 | /*! | 
| 49 |     \class Qt3DRender::QStencilMask | 
| 50 |     \brief The QStencilMask class controls the front and back writing of | 
| 51 |     individual bits in the stencil planes. | 
| 52 |     \since 5.7 | 
| 53 |     \ingroup renderstates | 
| 54 |     \inmodule Qt3DRender | 
| 55 |  | 
| 56 |     A Qt3DRender::QStencilMask class specifies a write mask for the stencil values | 
| 57 |     after the stencil test. Mask can be specified separately for the front-facing | 
| 58 |     and back-facing polygons. The fragment stencil value is and'd with the mask | 
| 59 |     before it is written to the stencil buffer. | 
| 60 |  | 
| 61 |     \sa Qt3DRender::QStencilTest | 
| 62 |  */ | 
| 63 |  | 
| 64 | /*! | 
| 65 |     \qmltype StencilMask | 
| 66 |     \brief The StencilMask type controls the front and back writing of | 
| 67 |     individual bits in the stencil planes. | 
| 68 |     \since 5.7 | 
| 69 |     \ingroup renderstates | 
| 70 |     \inqmlmodule Qt3D.Render | 
| 71 |     \instantiates Qt3DRender::QStencilMask | 
| 72 |     \inherits RenderState | 
| 73 |  | 
| 74 |     A StencilMask type specifies the mask for the stencil test. Mask can be specified | 
| 75 |     separately for the front-facing and back-facing polygons. The stencil test reference | 
| 76 |     value and stencil buffer value gets and'd with the mask prior to applying stencil function. | 
| 77 |  | 
| 78 |     \sa StencilTest | 
| 79 |  */ | 
| 80 |  | 
| 81 | /*! | 
| 82 |     \qmlproperty int StencilMask::frontOutputMask | 
| 83 |     Holds the write mask for the fragment stencil values for front-facing polygons. | 
| 84 | */ | 
| 85 |  | 
| 86 | /*! | 
| 87 |     \qmlproperty int StencilMask::backOutputMask | 
| 88 |     Holds the write mask for the fragment stencil values for back-facing polygons. | 
| 89 | */ | 
| 90 |  | 
| 91 | /*! | 
| 92 |     \property QStencilMask::frontOutputMask | 
| 93 |     Holds the write mask for the fragment stencil values for front-facing polygons. | 
| 94 | */ | 
| 95 |  | 
| 96 | /*! | 
| 97 |     \property QStencilMask::backOutputMask | 
| 98 |     Holds the write mask for the fragment stencil values for back-facing polygons. | 
| 99 | */ | 
| 100 |  | 
| 101 | /*! | 
| 102 |     The constructor creates a new QStencilMask::QStencilMask instance with the | 
| 103 |     specified \a parent. | 
| 104 |  */ | 
| 105 | QStencilMask::QStencilMask(QNode *parent) | 
| 106 |     : QRenderState(*new QStencilMaskPrivate(), parent) | 
| 107 | { | 
| 108 | } | 
| 109 |  | 
| 110 | /*! \internal */ | 
| 111 | QStencilMask::~QStencilMask() | 
| 112 | { | 
| 113 | } | 
| 114 |  | 
| 115 | void QStencilMask::setFrontOutputMask(uint mask) | 
| 116 | { | 
| 117 |     Q_D(QStencilMask); | 
| 118 |     if (d->m_frontOutputMask != mask) { | 
| 119 |         d->m_frontOutputMask = mask; | 
| 120 |         Q_EMIT frontOutputMaskChanged(frontOutputMask: mask); | 
| 121 |     } | 
| 122 | } | 
| 123 |  | 
| 124 | void QStencilMask::setBackOutputMask(uint mask) | 
| 125 | { | 
| 126 |     Q_D(QStencilMask); | 
| 127 |     if (d->m_backOutputMask != mask) { | 
| 128 |         d->m_backOutputMask = mask; | 
| 129 |         Q_EMIT backOutputMaskChanged(backOutputMask: mask); | 
| 130 |     } | 
| 131 | } | 
| 132 |  | 
| 133 | uint QStencilMask::frontOutputMask() const | 
| 134 | { | 
| 135 |     Q_D(const QStencilMask); | 
| 136 |     return d->m_frontOutputMask; | 
| 137 | } | 
| 138 |  | 
| 139 | uint QStencilMask::backOutputMask() const | 
| 140 | { | 
| 141 |     Q_D(const QStencilMask); | 
| 142 |     return d->m_backOutputMask; | 
| 143 | } | 
| 144 |  | 
| 145 | Qt3DCore::QNodeCreatedChangeBasePtr QStencilMask::createNodeCreationChange() const | 
| 146 | { | 
| 147 |     auto creationChange = QRenderStateCreatedChangePtr<QStencilMaskData>::create(arguments: this); | 
| 148 |     auto &data = creationChange->data; | 
| 149 |     Q_D(const QStencilMask); | 
| 150 |     data.frontOutputMask = d->m_frontOutputMask; | 
| 151 |     data.backOutputMask = d->m_backOutputMask; | 
| 152 |     return creationChange; | 
| 153 | } | 
| 154 |  | 
| 155 | } // namespace Qt3DRender | 
| 156 |  | 
| 157 | QT_END_NAMESPACE | 
| 158 |  |