| 162 | } |
| 163 | |
| 164 | void ClipNode::visit() { |
| 165 | if (!_stencil || !_stencil->isVisible()) { |
| 166 | if (_flags.isOn(ClipNode::Inverted)) { |
| 167 | Node::visit(); |
| 168 | } |
| 169 | return; |
| 170 | } |
| 171 | if (_layer + 1 == 8) { |
| 172 | static bool once = true; |
| 173 | if (once) { |
| 174 | once = false; |
| 175 | Warn("nesting more than {} stencils is not supported. Everything will be drawn without stencil for this node and its childs.", 8); |
| 176 | } |
| 177 | Node::visit(); |
| 178 | return; |
| 179 | } |
| 180 | _layer++; |
| 181 | uint32_t maskLayer = 1 << _layer; |
| 182 | uint32_t maskLayerLess = maskLayer - 1; |
| 183 | uint32_t maskLayerLessEqual = maskLayer | maskLayerLess; |
| 184 | SharedRendererManager.flush(); |
| 185 | if (isInverted()) { |
| 186 | drawFullScreenStencil(maskLayer, true); |
| 187 | } |
| 188 | drawStencil(maskLayer, !isInverted()); |
| 189 | uint32_t func = BGFX_STENCIL_TEST_EQUAL | BGFX_STENCIL_FUNC_REF(maskLayerLessEqual) | BGFX_STENCIL_FUNC_RMASK(maskLayerLessEqual); |
| 190 | uint32_t op = BGFX_STENCIL_OP_FAIL_S_KEEP | BGFX_STENCIL_OP_FAIL_Z_KEEP | BGFX_STENCIL_OP_PASS_Z_KEEP; |
| 191 | SharedRendererManager.pushStencilState(func | op, [&]() { |
| 192 | Node::visit(); |
| 193 | SharedRendererManager.flush(); |
| 194 | }); |
| 195 | if (isInverted()) { |
| 196 | drawFullScreenStencil(maskLayer, false); |
| 197 | } else { |
| 198 | drawStencil(maskLayer, false); |
| 199 | } |
| 200 | _layer--; |
| 201 | } |
| 202 | |
| 203 | NS_DORA_END |
no test coverage detected