- * @brief Set up the stencil and color buffer based on the current Renderers properties.
- * @param[in] item The current RenderItem about to be rendered
- * @param[in] context The context
- * @param[in/out] usedStencilBuffer True if the stencil buffer has been used so far within this RenderList. Used by StencilMode::ON.
- * @param[in/out] lastStencilDepth The stencil depth of the last renderer drawn. Used by the clipping feature.
- * @param[in/out] lastClippingId The clipping ID of the last renderer drawn. Used by the clipping feature.
- */
-inline void SetupStencilBuffer( const RenderItem& item, Context& context, bool& usedStencilBuffer, uint32_t& lastStencilDepth, uint32_t& lastClippingId )
-{
- const Renderer *renderer = item.mRenderer;
-
- // Setup the stencil using either the automatic clipping feature, or, the manual per-renderer stencil API.
- // Note: This switch is in order of most likely value first.
- RenderMode::Type renderMode = renderer->GetRenderMode();
- switch( renderMode )
- {
- case RenderMode::AUTO:
- {
- // The automatic clipping feature will manage the stencil functions and color buffer mask.
- SetupClipping( item, context, lastStencilDepth, lastClippingId );
- break;
- }
-
- case RenderMode::NONE:
- case RenderMode::COLOR:
- {
- // The stencil buffer will not be used at all.
- context.EnableStencilBuffer( false );
-
- // Setup the color buffer based on the RenderMode.
- context.ColorMask( renderMode == RenderMode::COLOR );
- return;
- break; // Break statement for consistency (although return will be called instead).
- }
-
- case RenderMode::STENCIL:
- case RenderMode::COLOR_STENCIL:
- {
- // We are using the low-level Renderer Stencil API.
- // The stencil buffer must be enabled for every renderer with stencil mode on, as renderers in between can disable it.
- // Note: As the command state is cached, it is only sent when needed.
- context.EnableStencilBuffer( true );
-
- // Setup the color buffer based on the RenderMode.
- context.ColorMask( renderMode == RenderMode::COLOR_STENCIL );
-
- // If this is the first use of the stencil buffer within this RenderList, clear it (this avoids unnecessary clears).
- if( !usedStencilBuffer )
- {
- context.Clear( GL_STENCIL_BUFFER_BIT, Context::CHECK_CACHED_VALUES );
- usedStencilBuffer = true;
- }
-
- // Setup the stencil buffer based on the renderers properties.
- context.StencilFunc( DaliStencilFunctionToGL[ renderer->GetStencilFunction() ],
- renderer->GetStencilFunctionReference(),
- renderer->GetStencilFunctionMask() );
- context.StencilOp( DaliStencilOperationToGL[ renderer->GetStencilOperationOnFail() ],
- DaliStencilOperationToGL[ renderer->GetStencilOperationOnZFail() ],
- DaliStencilOperationToGL[ renderer->GetStencilOperationOnZPass() ] );
- context.StencilMask( renderer->GetStencilMask() );
- break;
- }
- }
-}
-
-/**