Kanzi  3.9.4
Kanzi Engine API
kanzi::CompositionStack Class Reference

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

#include <kanzi/core.ui/graphics2d/composition_stack.hpp>

Public Member Functions

void apply2D (Renderer3D &renderer)
 Applies the topmost render settings for 2D rendering. More...
 
void apply3D (Renderer3D &renderer)
 Applies the topmost render settings for 3D rendering. More...
 
void applyColorBlend2D (Renderer &renderer)
 Applies the topmost color/blend stack state. More...
 
void applyColorBlend3D (Renderer &renderer)
 Applies the topmost color/blend stack state. More...
 
void applyComposition2D (Renderer &renderer)
 Applies the topmost composition stack state for 2D rendering. More...
 
void applyComposition3D (Renderer &renderer)
 Applies the topmost composition stack state for 3D rendering. More...
 
void applyDepthStencil2D (Renderer &renderer)
 Applies the topmost depth/stencil stack state. More...
 
void applyDepthStencil3D (Renderer &renderer)
 Applies the topmost depth/stencil stack state. More...
 
void applyPerspective2D (Renderer3D &renderer, const Matrix4x4 &cameraMatrix, const Matrix4x4 &projectionMatrix)
 Applies the topmost render settings for 2D perspective rendering. More...
 
void applyRasterization2D (Renderer &renderer)
 Applies the topmost rasterization stack state. More...
 
void applyRasterization3D (Renderer &renderer)
 Applies the topmost rasterization stack state. More...
 
 CompositionStack ()
 Constructor. More...
 
 CompositionStack (NativeFramebufferHandle handle, Vector2 size)
 Constructor. More...
 
 CompositionStack (NativeFramebufferHandle handle, Vector2 size, Vector4 viewport, optional< Vector4 > scissor)
 Constructor. More...
 
RenderPassSharedPtr getDebugComposer () const
 Get the debug composer used by this render context stack. More...
 
void invalidateAllState ()
 Invalidates all distinct stacks. More...
 
void invalidateColorBlend ()
 Invalidates color/blend stack state. More...
 
void invalidateComposition ()
 Invalidates composition stack state. More...
 
void invalidateDepthStencil ()
 Invalidates depth/stencil stack state. More...
 
void invalidateRasterization ()
 Invalidates rasterization stack state. More...
 
bool isCompositionStackEmpty () const
 Tells if composition stack is empty. More...
 
optional< NativeFramebufferHandlepeekCompositionTargetHandle () const
 Kanzi uses this function internally to get the handle of the current composition target. More...
 
optional< Vector2peekPolygonOffset ()
 Kanzi uses this function internally to get the current polygon offset. More...
 
optional< Vector2peekRenderContextSize () const
 Kanzi uses this function internally to get the size of the current composition target. More...
 
optional< Vector4peekScissor () const
 Gets current scissor. More...
 
optional< ViewportRectanglepeekScissorDeviceCoordinates ()
 Kanzi uses this function internally to get the current scissor area in device coordinates. More...
 
optional< Vector4peekViewport () const
 Gets current viewport. More...
 
optional< ViewportRectanglepeekViewportDeviceCoordinates ()
 Kanzi uses this function internally to get the current viewport in device coordinates. More...
 
optional< Vector2peekViewportOffset () const
 Gets current viewport offset. More...
 
optional< Vector2peekViewportSize () const
 Gets current viewport size. More...
 
void popColorBlend ()
 Pop blend state from blend stack. More...
 
void popComposition ()
 Pop a composition target state from the stack. More...
 
void popDepthStencil ()
 Pop a depth stencil state from the stack. More...
 
void popRasterization ()
 Pop a rasterization state from the stack. More...
 
void pushColorBlend (optional< int > blendMode, optional< GraphicsColorWriteMode > colorWriteMode)
 Pushes blend state into the blend stack. More...
 
void pushComposition (NativeFramebufferHandle handle, Vector2 size)
 Pushes a composition target into the composition stack. More...
 
void pushComposition (NativeFramebufferHandle handle, unsigned int bufferCount, Vector2 size)
 Pushes a composition target into the composition stack. More...
 
void pushComposition (Texture &texture)
 Pushes a composition target into the composition stack. More...
 
void pushComposition (Texture &texture, Vector2 size)
 Pushes a composition target into the composition stack. More...
 
void pushComposition (optional< Vector4 > viewport, optional< Vector4 > scissor)
 Pushes a viewport and/or scissor onto composition stack. More...
 
void pushComposition (Texture &texture, Vector4 viewport, optional< Vector4 > scissor)
 Pushes a composition target and a viewport into the composition stack. More...
 
void pushComposition (NativeFramebufferHandle handle, Vector2 size, Vector4 viewport, optional< Vector4 > scissor)
 Pushes a composition target and a viewport into the composition stack. More...
 
void pushComposition (NativeFramebufferHandle handle, unsigned int bufferCount, Vector2 size, Vector4 viewport, optional< Vector4 > scissor)
 Pushes a composition target and a viewport into the composition 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)
 Pushes depth stencil state. More...
 
void pushRasterization (optional< GraphicsCullMode > cullMode, optional< Vector2 > polygonOffset)
 Pushes rasterization state. More...
 
void setDebugComposer (RenderPassSharedPtr debugComposer)
 Set the debug composer to be used by this render context stack. 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.

Constructor & Destructor Documentation

◆ CompositionStack() [1/3]

kanzi::CompositionStack::CompositionStack ( )
inlineexplicit

Constructor.

◆ CompositionStack() [2/3]

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

Constructor.

Parameters
handleComposition target handle.
sizeComposition target size.

◆ CompositionStack() [3/3]

kanzi::CompositionStack::CompositionStack ( NativeFramebufferHandle  handle,
Vector2  size,
Vector4  viewport,
optional< Vector4 scissor 
)
inlineexplicit

Constructor.

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

Member Function Documentation

◆ isCompositionStackEmpty()

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

Tells if composition stack is empty.

Empty composition stack has no states whatsoever.

◆ pushColorBlend()

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

Pushes 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.
Since
Kanzi 3.9.1 type of blendMode parameter changed from GraphicsBlendMode to int.

◆ popColorBlend()

void kanzi::CompositionStack::popColorBlend ( )
inline

Pop blend state from blend stack.

◆ pushComposition() [1/8]

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

Pushes a composition target into the composition stack.

Parameters
handleComposition target handle.
sizeComposition target size.

◆ pushComposition() [2/8]

void kanzi::CompositionStack::pushComposition ( NativeFramebufferHandle  handle,
unsigned int  bufferCount,
Vector2  size 
)

Pushes a composition target into the composition stack.

Parameters
handleComposition target handle.
bufferCountComposition target handle.
sizeComposition target size.

◆ pushComposition() [3/8]

void kanzi::CompositionStack::pushComposition ( Texture texture)

Pushes a composition target into the composition stack.

Parameters
textureComposition target.

◆ pushComposition() [4/8]

void kanzi::CompositionStack::pushComposition ( Texture texture,
Vector2  size 
)

Pushes a composition target into the composition stack.

Parameters
textureComposition target.
sizeComposition target size.

◆ pushComposition() [5/8]

void kanzi::CompositionStack::pushComposition ( optional< Vector4 viewport,
optional< Vector4 scissor 
)

Pushes a viewport and/or scissor onto composition stack.

Parameters
viewportoptional viewport area.
scissoroptional scissor area.

◆ pushComposition() [6/8]

void kanzi::CompositionStack::pushComposition ( Texture texture,
Vector4  viewport,
optional< Vector4 scissor 
)

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

Parameters
textureComposition target.
viewportViewport area.
scissorScissor area.

◆ pushComposition() [7/8]

void kanzi::CompositionStack::pushComposition ( NativeFramebufferHandle  handle,
Vector2  size,
Vector4  viewport,
optional< Vector4 scissor 
)

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

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

◆ pushComposition() [8/8]

void kanzi::CompositionStack::pushComposition ( NativeFramebufferHandle  handle,
unsigned int  bufferCount,
Vector2  size,
Vector4  viewport,
optional< Vector4 scissor 
)
inline

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

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

◆ popComposition()

void kanzi::CompositionStack::popComposition ( )
inline

Pop a composition target state from the stack.

◆ pushDepthStencil()

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 
)

Pushes 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?

◆ popDepthStencil()

void kanzi::CompositionStack::popDepthStencil ( )
inline

Pop a depth stencil state from the stack.

◆ pushRasterization()

void kanzi::CompositionStack::pushRasterization ( optional< GraphicsCullMode cullMode,
optional< Vector2 polygonOffset 
)

Pushes rasterization state.

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

Parameters
cullModeCulling mode.
polygonOffsetPolygon offset.
Since
Kanzi 3.9.4 polygonOffset parameter

◆ popRasterization()

void kanzi::CompositionStack::popRasterization ( )
inline

Pop a rasterization state from the stack.

◆ getDebugComposer()

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

Get the debug composer used by this render context stack.

◆ setDebugComposer()

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

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

◆ apply2D()

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

Applies the topmost render settings for 2D rendering.

Parameters
rendererRenderer to use.

◆ apply3D()

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

Applies the topmost render settings for 3D rendering.

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

◆ applyPerspective2D()

void kanzi::CompositionStack::applyPerspective2D ( Renderer3D renderer,
const Matrix4x4 cameraMatrix,
const Matrix4x4 projectionMatrix 
)

Applies the topmost render settings for 2D perspective rendering.

Parameters
rendererRenderer to use.
cameraMatrixPrecalculated cameraMatrix.
projectionMatrixPrecalculated projectionMatrix.

◆ peekCompositionTargetHandle()

optional<NativeFramebufferHandle> kanzi::CompositionStack::peekCompositionTargetHandle ( ) const
inline

Kanzi uses this function internally to get the handle of the current composition target.

Returns
Framebuffer handle.

◆ peekRenderContextSize()

optional<Vector2> kanzi::CompositionStack::peekRenderContextSize ( ) const
inline

Kanzi uses this function internally to get the size of the current composition target.

Returns
Composition target size.

◆ peekScissor()

optional<Vector4> kanzi::CompositionStack::peekScissor ( ) const
inline

Gets current scissor.

Returns
Scissor in Node2D coordinates or an empty optional if no scissor is set.

◆ peekViewport()

optional<Vector4> kanzi::CompositionStack::peekViewport ( ) const
inline

Gets current viewport.

Returns
Viewport in Node2D coordinates or an empty optional if composition stack is empty.

◆ peekViewportOffset()

optional<Vector2> kanzi::CompositionStack::peekViewportOffset ( ) const
inline

Gets current viewport offset.

Returns
Offset of topmost viewport or an empty optional if composition stack is empty.

◆ peekViewportSize()

optional<Vector2> kanzi::CompositionStack::peekViewportSize ( ) const
inline

Gets current viewport size.

Disregards scissor.

Returns
Size of topmost viewport or an empty optional if composition stack is empty.

◆ peekViewportDeviceCoordinates()

optional<ViewportRectangle> kanzi::CompositionStack::peekViewportDeviceCoordinates ( )
inline

Kanzi uses this function internally to get the current viewport in device coordinates.

Returns
Device coordinate viewport.

◆ peekScissorDeviceCoordinates()

optional<ViewportRectangle> kanzi::CompositionStack::peekScissorDeviceCoordinates ( )
inline

Kanzi uses this function internally to get the current scissor area in device coordinates.

Returns
Device coordinate viewport.

◆ peekPolygonOffset()

optional<Vector2> kanzi::CompositionStack::peekPolygonOffset ( )
inline

Kanzi uses this function internally to get the current polygon offset.

Returns
Polygon offset.

◆ applyColorBlend2D()

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

Applies the topmost color/blend stack state.

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

Parameters
rendererRenderer to use.

◆ applyColorBlend3D()

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

Applies the topmost color/blend stack state.

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

Parameters
rendererRenderer to use.

◆ invalidateColorBlend()

void kanzi::CompositionStack::invalidateColorBlend ( )
inline

Invalidates color/blend stack state.

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

◆ applyComposition2D()

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

Applies the topmost composition stack state for 2D rendering.

Default composition state for 2D is not defined.

Parameters
rendererRenderer to use.

◆ applyComposition3D()

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

Applies the topmost composition stack state for 3D rendering.

Default composition state for 2D is not defined.

Parameters
rendererRenderer to use.

◆ invalidateComposition()

void kanzi::CompositionStack::invalidateComposition ( )
inline

Invalidates composition stack state.

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

◆ applyDepthStencil2D()

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

Applies the topmost depth/stencil stack state.

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

Parameters
rendererRenderer to use.

◆ applyDepthStencil3D()

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

Applies the topmost depth/stencil stack state.

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

Parameters
rendererRenderer to use.

◆ invalidateDepthStencil()

void kanzi::CompositionStack::invalidateDepthStencil ( )
inline

Invalidates depth/stencil stack state.

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

◆ applyRasterization2D()

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

Applies the topmost rasterization stack state.

If stack is empty, default rasterization settings are used.

Parameters
rendererRenderer to use.

◆ applyRasterization3D()

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

Applies the topmost rasterization stack state.

If stack is empty, default rasterization settings are used.

Parameters
rendererRenderer to use.

◆ invalidateRasterization()

void kanzi::CompositionStack::invalidateRasterization ( )
inline

Invalidates rasterization stack state.

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

◆ invalidateAllState()

void kanzi::CompositionStack::invalidateAllState ( )
inline

Invalidates 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: