kanzi::CompositionStack Class Reference

Composition stack for managing current render context. More...

#include <kanzi/core.ui/platform/graphics_backend/gl/composition_stack.hpp>

Public Types

typedef unsigned int NativeCompositionTargetHandle
 Composition target handle for OpenGL. More...
 

Public Member Functions

 CompositionStack ()
 Constructor. More...
 
 CompositionStack (NativeCompositionTargetHandle handle, Vector2 size)
 Constructor. More...
 
 CompositionStack (NativeCompositionTargetHandle handle, Vector2 size, Vector4 viewport, optional< Vector4 > scissor)
 Constructor. More...
 
bool isCompositionStackEmpty () const
 Tells if composition stack is empty. More...
 
void pushColorBlend (optional< GraphicsBlendMode > blendMode, optional< GraphicsColorWriteMode > colorWriteMode)
 Push blend state into the blend stack. More...
 
void popColorBlend ()
 Pop blend state from blend stack. More...
 
void pushComposition (NativeCompositionTargetHandle handle, Vector2 size)
 Push a composition target into the composition stack. More...
 
void pushComposition (Texture &texture)
 Push a composition target into the composition stack. More...
 
void pushComposition (Texture &texture, Vector2 size)
 Push a composition target into the composition stack. More...
 
void pushComposition (Framebuffer &framebuffer, Vector2 size)
 Push a framebuffer into the composition stack. More...
 
void pushComposition (optional< Vector4 > viewport, optional< Vector4 > scissor)
 Push a viewport and/or scissor onto composition stack. More...
 
void pushComposition (Texture &texture, Vector4 viewport, optional< Vector4 > scissor)
 Push a composition target and a viewport into the composition stack. More...
 
void pushComposition (NativeCompositionTargetHandle handle, Vector2 size, Vector4 viewport, optional< Vector4 > scissor)
 Push a composition target and a viewport into the composition stack. More...
 
void popComposition ()
 Pop a composition target state from the stack. More...
 
void pushDepthStencil (optional< GraphicsCompareFunction > depthFunc, optional< bool > depthWrite, optional< GraphicsCompareFunction > stencilFunc, optional< unsigned int > referenceValue, optional< unsigned int > maskValue, optional< GraphicsStencilOperation > stencilFail, optional< GraphicsStencilOperation > stencilPassDepthFail, optional< GraphicsStencilOperation > stencilPassDepthPass, optional< bool > stencilWrite)
 Push depth stencil state. More...
 
void popDepthStencil ()
 Pop a depth stencil state from the stack. More...
 
void pushRasterization (optional< GraphicsCullMode > cullMode)
 Push rasterization state. More...
 
void popRasterization ()
 Pop a rasterization state from the stack. More...
 
RenderPassSharedPtr getDebugComposer () const
 Get the debug composer used by this render context stack. More...
 
void setDebugComposer (RenderPassSharedPtr debugComposer)
 Set the debug composer to be used by this render context stack. More...
 
void apply2D (Renderer3D &renderer)
 Apply the topmost render context for 2D rendering. More...
 
void apply3D (Renderer3D &renderer)
 Apply 3D rendering state. More...
 
void applyPerspective2D (Renderer3D &renderer, const Vector4 *worldPerspectiveOffset)
 Apply for 2D perspective rendering. More...
 
optional< NativeCompositionTargetHandlepeekCompositionTargetHandle () const
 Get current composition target handle. More...
 
optional< Vector2peekRenderContextSize () const
 Get current composition target size. More...
 
optional< Vector4peekScissor () const
 Get current scissor. More...
 
optional< Vector4peekViewport () const
 Get current viewport. More...
 
optional< Vector2peekViewportOffset () const
 Get current viewport offset. More...
 
optional< Vector2peekViewportSize () const
 Get current viewport size. More...
 
optional< ViewportRectanglepeekViewportDeviceCoordinates ()
 Get current viewport in device coordinates. More...
 
optional< ViewportRectanglepeekScissorDeviceCoordinates ()
 Get current device coordinate scissor. More...
 
void applyColorBlend2D (Renderer &renderer)
 Apply blend stack. More...
 
void applyColorBlend3D (Renderer &renderer)
 Apply blend stack. More...
 
void invalidateColorBlend ()
 Invalidate color/blend stack state. More...
 
void applyComposition2D (Renderer &renderer)
 Apply composition stack. More...
 
void applyComposition3D (Renderer &renderer)
 Apply composition stack. More...
 
void invalidateComposition ()
 Invalidate composition stack state. More...
 
void applyDepthStencil2D (Renderer &renderer)
 Apply depth/stencil stack If stack is empty, default depth/stencil settings are used. More...
 
void applyDepthStencil3D (Renderer &renderer)
 Apply depth/stencil stack If stack is empty, default depth/stencil settings are used. More...
 
void invalidateDepthStencil ()
 Invalidate depth/stencil stack state. More...
 
void applyRasterization2D (Renderer &renderer)
 Apply rasterization stack. More...
 
void applyRasterization3D (Renderer &renderer)
 Apply rasterization stack. More...
 
void invalidateRasterization ()
 Invalidate rasterization stack state. More...
 
void invalidateAllState ()
 Invalidate all distinct stacks. More...
 

Detailed Description

Composition stack for managing current render context.

The stack has no ownership over the stored render targets - they will not be reserved or deleted.

Member Typedef Documentation

Composition target handle for OpenGL.

Constructor & Destructor Documentation

kanzi::CompositionStack::CompositionStack ( )
inlineexplicit

Constructor.

kanzi::CompositionStack::CompositionStack ( NativeCompositionTargetHandle  handle,
Vector2  size 
)
inlineexplicit

Constructor.

Parameters
handleComposition target handle.
sizeComposition target size.
kanzi::CompositionStack::CompositionStack ( NativeCompositionTargetHandle  handle,
Vector2  size,
Vector4  viewport,
optional< Vector4 scissor 
)
inlineexplicit

Constructor.

Parameters
handleComposition target handle.
sizeComposition target size.
viewportViewport area.
scissorScissor area.

Member Function Documentation

bool kanzi::CompositionStack::isCompositionStackEmpty ( ) const
inline

Tells if composition stack is empty.

Empty composition stack has no states whatsoever.

void kanzi::CompositionStack::pushColorBlend ( optional< GraphicsBlendMode blendMode,
optional< GraphicsColorWriteMode colorWriteMode 
)

Push blend state into the blend stack.

Using nullopt with any parameter will take the default value or the last value pushed.

Parameters
blendModeBlend mode.
colorWriteModeColor write mode.
void kanzi::CompositionStack::popColorBlend ( )
inline

Pop blend state from blend stack.

void kanzi::CompositionStack::pushComposition ( NativeCompositionTargetHandle  handle,
Vector2  size 
)

Push a composition target into the composition stack.

Parameters
handleComposition target handle.
sizeComposition target size.
void kanzi::CompositionStack::pushComposition ( Texture texture)

Push a composition target into the composition stack.

Parameters
textureComposition target.
void kanzi::CompositionStack::pushComposition ( Texture texture,
Vector2  size 
)

Push a composition target into the composition stack.

Parameters
textureComposition target.
sizeComposition target size.
void kanzi::CompositionStack::pushComposition ( Framebuffer framebuffer,
Vector2  size 
)

Push a framebuffer into the composition stack.

Parameters
framebufferFramebuffer.
sizeComposition target size.
void kanzi::CompositionStack::pushComposition ( optional< Vector4 viewport,
optional< Vector4 scissor 
)

Push a viewport and/or scissor onto composition stack.

Parameters
viewportoptional viewport area.
scissoroptional scissor area.
void kanzi::CompositionStack::pushComposition ( Texture texture,
Vector4  viewport,
optional< Vector4 scissor 
)

Push a composition target and a viewport into the composition stack.

Parameters
textureComposition target.
viewportViewport area.
scissorScissor area.
void kanzi::CompositionStack::pushComposition ( NativeCompositionTargetHandle  handle,
Vector2  size,
Vector4  viewport,
optional< Vector4 scissor 
)
inline

Push a composition target and a viewport into the composition stack.

Parameters
handleComposition target handle.
sizeComposition target size.
viewportViewport area.
scissorScissor area.
void kanzi::CompositionStack::popComposition ( )
inline

Pop a composition target state from the stack.

void kanzi::CompositionStack::pushDepthStencil ( optional< GraphicsCompareFunction depthFunc,
optional< bool >  depthWrite,
optional< GraphicsCompareFunction stencilFunc,
optional< unsigned int >  referenceValue,
optional< unsigned int >  maskValue,
optional< GraphicsStencilOperation stencilFail,
optional< GraphicsStencilOperation stencilPassDepthFail,
optional< GraphicsStencilOperation stencilPassDepthPass,
optional< bool >  stencilWrite 
)

Push depth stencil state.

Using nullopt with any parameter will take the default value or the last value pushed.

Parameters
depthFuncDepth testing function.
depthWriteDepth write enabled?
stencilfuncStencil function.
referenceValueStencil reference value.
maskValueStencil mask value.
stencilFailOperation for stencil fail.
stencilPassDepthFailOperation for stencil pass but depth fail.
stencilPassDepthPassOperation for stencil and depth pass.
stencilWriteStencil write enabled?
void kanzi::CompositionStack::popDepthStencil ( )
inline

Pop a depth stencil state from the stack.

void kanzi::CompositionStack::pushRasterization ( optional< GraphicsCullMode cullMode)

Push rasterization state.

Using nullopt with any parameter will take the default value or the last value pushed.

Parameters
cullModeCulling mode.
void kanzi::CompositionStack::popRasterization ( )
inline

Pop a rasterization state from the stack.

RenderPassSharedPtr kanzi::CompositionStack::getDebugComposer ( ) const
inline

Get the debug composer used by this render context stack.

void kanzi::CompositionStack::setDebugComposer ( RenderPassSharedPtr  debugComposer)
inline

Set the debug composer to be used by this render context stack.

void kanzi::CompositionStack::apply2D ( Renderer3D renderer)

Apply the topmost render context for 2D rendering.

Parameters
rendererRenderer to use.
void kanzi::CompositionStack::apply3D ( Renderer3D renderer)

Apply 3D rendering state.

Default values will be used for those states with empty stacks.

void kanzi::CompositionStack::applyPerspective2D ( Renderer3D renderer,
const Vector4 worldPerspectiveOffset 
)

Apply for 2D perspective rendering.

TODO: fix everything about this.

Parameters
rendererRenderer to use.
worldPerspectiveOffsetWorld perspective offset provided by 2D rendering.
optional<NativeCompositionTargetHandle> kanzi::CompositionStack::peekCompositionTargetHandle ( ) const
inline

Get current composition target handle.

This function exists for tests.

Returns
Framebuffer handle.
optional<Vector2> kanzi::CompositionStack::peekRenderContextSize ( ) const
inline

Get current composition target size.

This function exists for tests.

Returns
Composition target size.
optional<Vector4> kanzi::CompositionStack::peekScissor ( ) const
inline

Get current scissor.

Returns
Scissor in Node2D coordinates or an empty optional if no scissor is set.
optional<Vector4> kanzi::CompositionStack::peekViewport ( ) const
inline

Get current viewport.

Returns
Viewport in Node2D coordinates or an empty optional if composition stack is empty.
optional<Vector2> kanzi::CompositionStack::peekViewportOffset ( ) const
inline

Get current viewport offset.

Returns
Offset of topmost viewport or an empty optional if composition stack is empty.
optional<Vector2> kanzi::CompositionStack::peekViewportSize ( ) const
inline

Get current viewport size.

Disregards scissor.

Returns
Size of topmost viewport or an empty optional if composition stack is empty.
optional<ViewportRectangle> kanzi::CompositionStack::peekViewportDeviceCoordinates ( )
inline

Get current viewport in device coordinates.

This function exists for tests.

Returns
Device coordinate viewport.
optional<ViewportRectangle> kanzi::CompositionStack::peekScissorDeviceCoordinates ( )
inline

Get current device coordinate scissor.

This function exists for tests.

Returns
Device coordinate viewport.
void kanzi::CompositionStack::applyColorBlend2D ( Renderer renderer)
inline

Apply blend stack.

If stack is empty, default 2D blend settings are used.

Parameters
rendererRenderer to use.
void kanzi::CompositionStack::applyColorBlend3D ( Renderer renderer)
inline

Apply blend stack.

If stack is empty, default 3D blend settings are used.

Parameters
rendererRenderer to use.
void kanzi::CompositionStack::invalidateColorBlend ( )
inline

Invalidate color/blend stack state.

Should only be called when manually modifying color/blend state so that applying again will not assume no changes.

void kanzi::CompositionStack::applyComposition2D ( Renderer renderer)
inline

Apply composition stack.

Default composition state for 2D is not defined.

Parameters
rendererRenderer to use.
void kanzi::CompositionStack::applyComposition3D ( Renderer renderer)
inline

Apply composition stack.

Default composition state for 2D is not defined.

Parameters
rendererRenderer to use.
void kanzi::CompositionStack::invalidateComposition ( )
inline

Invalidate composition stack state.

Should only be called when manually modifying composition state so that applying again will not assume no changes.

void kanzi::CompositionStack::applyDepthStencil2D ( Renderer renderer)
inline

Apply depth/stencil stack If stack is empty, default depth/stencil settings are used.

Parameters
rendererRenderer to use.
void kanzi::CompositionStack::applyDepthStencil3D ( Renderer renderer)
inline

Apply depth/stencil stack If stack is empty, default depth/stencil settings are used.

Parameters
rendererRenderer to use.
void kanzi::CompositionStack::invalidateDepthStencil ( )
inline

Invalidate depth/stencil stack state.

Should only be called when manually modifying depth/stencil state so that applying again will not assume no changes.

void kanzi::CompositionStack::applyRasterization2D ( Renderer renderer)
inline

Apply rasterization stack.

If stack is empty, default rasterization settings are used.

Parameters
rendererRenderer to use.
void kanzi::CompositionStack::applyRasterization3D ( Renderer renderer)
inline

Apply rasterization stack.

If stack is empty, default rasterization settings are used.

Parameters
rendererRenderer to use.
void kanzi::CompositionStack::invalidateRasterization ( )
inline

Invalidate rasterization stack state.

Should only be called when manually modifying rasterization state so that applying again will not assume no changes.

void kanzi::CompositionStack::invalidateAllState ( )
inline

Invalidate all distinct stacks.

User should not need to call this function. Intended to be called along #Renderer3D::reset() to signify context change.


The documentation for this class was generated from the following file: