Kanzi 4.0.0-beta2
kanzi::CompositionStack Class Reference

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

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

Classes

struct  ColorBlendState
 Blend state. More...
 
struct  CompositionState
 Composition target state. More...
 
struct  DepthStencilState
 Depth/Stencil state. More...
 
struct  RasterizationState
 Rasterization state. More...
 
class  StateStack
 Template class for handling state arrays. More...
 

Public Member Functions

void apply ()
 Applies the topmost render settings.
 
void apply2D ()
 Applies the topmost render settings for 2D rendering.
 
void applyColorBlend ()
 Applies the topmost color/blend stack state.
 
void applyComposition ()
 Applies the topmost composition stack state.
 
void applyDepthStencil ()
 Applies the topmost depth/stencil stack state.
 
void applyPerspective2D (const Matrix4x4 &cameraMatrix, const Matrix4x4 &projectionMatrix)
 Applies the topmost render settings for 2D perspective rendering.
 
void applyRasterization ()
 Applies the topmost rasterization stack state.
 
 CompositionStack (const CompositionStack &)=delete
 
 CompositionStack (Renderer *renderer)
 Constructor.
 
const ColorBlendStategetAppliedColorBlend () const
 Gets the applied color blend state.
 
const DepthStencilStategetAppliedDepthStencil () const
 Gets the applied depth stencil state.
 
const RasterizationStategetAppliedRasterization () const
 Gets the applied rasterization state.
 
RenderPassSharedPtr getDebugComposer () const
 Get the debug composer used by this render context stack.
 
void invalidateAllState ()
 Invalidates all distinct stacks.
 
void invalidateColorBlend ()
 Invalidates color/blend stack state.
 
void invalidateComposition ()
 Invalidates composition stack state.
 
void invalidateDepthStencil ()
 Invalidates depth/stencil stack state.
 
void invalidateRasterization ()
 Invalidates rasterization stack state.
 
bool isCompositionStackEmpty () const
 Tells if composition stack is empty.
 
CompositionStackoperator= (const CompositionStack &)=delete
 
const FramebufferpeekCompositionTargetFramebuffer () const
 Kanzi uses this function internally to get the framebuffer of the current composition target.
 
optional< Vector2peekPolygonOffset ()
 Kanzi uses this function internally to get the current polygon offset.
 
optional< Vector2peekRenderContextSize () const
 Kanzi uses this function internally to get the size of the current composition target.
 
optional< Vector4peekScissor () const
 Gets current scissor.
 
optional< ViewportRectanglepeekScissorDeviceCoordinates ()
 Kanzi uses this function internally to get the current scissor area in device coordinates.
 
optional< Texture * > peekTexture () const
 Gets the current composition target texture.
 
optional< Vector4peekViewport () const
 Gets current viewport.
 
optional< ViewportRectanglepeekViewportDeviceCoordinates ()
 Kanzi uses this function internally to get the current viewport in device coordinates.
 
optional< Vector2peekViewportOffset () const
 Gets current viewport offset.
 
optional< Vector2peekViewportSize () const
 Gets current viewport size.
 
void popColorBlend ()
 Pop blend state from blend stack.
 
void popComposition ()
 Pop a composition target state from the stack.
 
void popDepthStencil ()
 Pop a depth stencil state from the stack.
 
void popRasterization ()
 Pop a rasterization state from the stack.
 
void popSettings ()
 Pops the topmost state from each composition stack.
 
void pushColorBlend (optional< int > blendMode, optional< GraphicsColorWriteMode > colorWriteMode)
 Pushes blend state into the blend stack.
 
void pushComposition (const Framebuffer &framebuffer, Vector2 size)
 Pushes a composition target into the composition stack.
 
void pushComposition (const Framebuffer &framebuffer, Vector2 size, Vector4 viewport, optional< Vector4 > scissor)
 Pushes a composition target and a viewport into the composition stack.
 
void pushComposition (optional< Vector4 > viewport, optional< Vector4 > scissor)
 Pushes a viewport or scissor into the composition stack.
 
void pushComposition (Texture &texture)
 Pushes a composition target into the composition stack.
 
void pushComposition (Texture &texture, Vector2 size)
 Pushes a composition target into the composition stack.
 
void pushComposition (Texture &texture, Vector4 viewport, optional< Vector4 > scissor)
 Pushes a composition target and a viewport into the composition stack.
 
void pushComposition (Vector4 viewport)
 Pushes a viewport into the composition stack.
 
void pushCompositionActiveGraphicsOutput ()
 Pushes the active graphics output framebuffer into the composition stack.
 
void pushCompositionActiveGraphicsOutput (Vector2 size)
 Pushes the active graphics output framebuffer into the composition stack.
 
void pushCompositionActiveGraphicsOutput (Vector4 viewport)
 Pushes the active graphics output framebuffer into the composition stack.
 
void pushDefaultSettings2D ()
 Pushes a default 2D state into each settings stack.
 
void pushDefaultSettings3D ()
 Pushes a default 3D state into each settings stack.
 
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.
 
void pushRasterization (optional< GraphicsCullMode > cullMode, optional< GraphicsFillMode > fillMode, optional< Vector2 > polygonOffset, optional< float > lineWidth)
 Pushes rasterization state.
 
void setDebugComposer (RenderPassSharedPtr debugComposer)
 Set the debug composer to be used by this render context stack.
 
void setRasterizationFillModeOverride (optional< GraphicsFillMode > fillMode)
 Sets a manual override of the Rasterization FillMode.
 
void setStencilOverride (optional< GraphicsCompareFunction > stencilFunc, optional< unsigned int > referenceValue, optional< unsigned int > maskValue, optional< GraphicsStencilOperation > stencilFail, optional< GraphicsStencilOperation > stencilPassDepthFail, optional< GraphicsStencilOperation > stencilPassDepthPass, optional< bool > stencilWrite)
 Sets a manual override of the Stencil State.
 

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.

Since
Kanzi 4.0.0
  • Removes applyColorBlend2D and applyColorBlend3D functions, replaced with applyColorBlend.
  • Removes applyDepthStencil2D and applyDepthStencil3D functions, replaced with applyDepthStencil.
  • Removes applyRasterization2D and applyRasterization3D functions, replaced with applyRasterization.
  • Removes the apply3D function, replaced with apply.

Constructor & Destructor Documentation

◆ CompositionStack() [1/2]

kanzi::CompositionStack::CompositionStack ( Renderer * renderer)
inlineexplicit

Constructor.

Parameters
rendererThe core renderer.
Since
Kanzi 4.0.0

◆ CompositionStack() [2/2]

kanzi::CompositionStack::CompositionStack ( const CompositionStack & )
delete

Member Function Documentation

◆ operator=()

CompositionStack & kanzi::CompositionStack::operator= ( const CompositionStack & )
delete

◆ isCompositionStackEmpty()

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

Tells if composition stack is empty.

Empty composition stack has no states of any kind.

Returns
If the composition stack is empty true, false otherwise.

◆ 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.

◆ pushCompositionActiveGraphicsOutput() [1/3]

void kanzi::CompositionStack::pushCompositionActiveGraphicsOutput ( )

Pushes the active graphics output framebuffer into the composition stack.

Since
Kanzi 4.0.0

◆ pushCompositionActiveGraphicsOutput() [2/3]

void kanzi::CompositionStack::pushCompositionActiveGraphicsOutput ( Vector2 size)

Pushes the active graphics output framebuffer into the composition stack.

Parameters
sizeComposition target size.
Since
Kanzi 4.0.0

◆ pushCompositionActiveGraphicsOutput() [3/3]

void kanzi::CompositionStack::pushCompositionActiveGraphicsOutput ( Vector4 viewport)

Pushes the active graphics output framebuffer into the composition stack.

Parameters
viewportViewport area.
Since
Kanzi 4.0.0

◆ pushComposition() [1/7]

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

Pushes a composition target into the composition stack.

Parameters
textureComposition target.

◆ pushComposition() [2/7]

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

Pushes a composition target into the composition stack.

Parameters
textureComposition target.
sizeComposition target size.

◆ pushComposition() [3/7]

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() [4/7]

void kanzi::CompositionStack::pushComposition ( const Framebuffer & framebuffer,
Vector2 size )

Pushes a composition target into the composition stack.

Parameters
framebufferComposition target framebuffer.
sizeComposition target size.
Since
Kanzi 4.0.0

◆ pushComposition() [5/7]

void kanzi::CompositionStack::pushComposition ( const Framebuffer & framebuffer,
Vector2 size,
Vector4 viewport,
optional< Vector4 > scissor )

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

Parameters
framebufferComposition target framebuffer.
sizeComposition target size.
viewportViewport area.
scissorScissor area.
Since
Kanzi 4.0.0

◆ pushComposition() [6/7]

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

Pushes a viewport or scissor into the composition stack.

Parameters
viewportOptional viewport area.
scissorOptional scissor area.

◆ pushComposition() [7/7]

void kanzi::CompositionStack::pushComposition ( Vector4 viewport)

Pushes a viewport into the composition stack.

Parameters
viewportViewport area.

◆ popComposition()

void kanzi::CompositionStack::popComposition ( )

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< GraphicsFillMode > fillMode,
optional< Vector2 > polygonOffset,
optional< float > lineWidth )

Pushes rasterization state.

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

Parameters
cullModeCulling mode.
fillModeFilling mode.
polygonOffsetPolygon offset.
lineWidthLine width.
Since
Kanzi 3.9.4 polygonOffset parameter
Kanzi 4.0.0 fillMode and lineWidth parameters.

◆ 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.

◆ apply()

void kanzi::CompositionStack::apply ( )

Applies the topmost render settings.

Since
Kanzi 4.0.0

◆ apply2D()

void kanzi::CompositionStack::apply2D ( )

Applies the topmost render settings for 2D rendering.

Since
Kanzi 4.0.0 removed the renderer parameter.

◆ applyPerspective2D()

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

Applies the topmost render settings for 2D perspective rendering.

Parameters
cameraMatrixPrecalculated cameraMatrix.
projectionMatrixPrecalculated projectionMatrix.
Since
Kanzi 4.0.0 removed the renderer parameter.

◆ peekCompositionTargetFramebuffer()

const Framebuffer * kanzi::CompositionStack::peekCompositionTargetFramebuffer ( ) const
inline

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

Returns
Framebuffer pointer.
Since
Kanzi 4.0.0

◆ 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.

◆ peekTexture()

optional< Texture * > kanzi::CompositionStack::peekTexture ( ) const
inline

Gets the current composition target texture.

Returns
The target texture. If the composition stack is empty, returns an empty optional.
Since
Kanzi 3.9.7

◆ 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.

◆ applyColorBlend()

void kanzi::CompositionStack::applyColorBlend ( )
inline

Applies the topmost color/blend stack state.

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

Since
Kanzi 4.0.0 removed the renderer parameter.
Kanzi 4.0.0 combined the applyColorBlend2D and applyColorBlend3D functions.

◆ 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.

◆ applyComposition()

void kanzi::CompositionStack::applyComposition ( )
inline

Applies the topmost composition stack state.

Since
Kanzi 4.0.0 removed the renderer parameter.
Kanzi 4.0.0 combined the applyComposition2D and applyComposition3D functions.

◆ 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.

◆ applyDepthStencil()

void kanzi::CompositionStack::applyDepthStencil ( )
inline

Applies the topmost depth/stencil stack state.

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

Since
Kanzi 4.0.0 removed the renderer parameter.
Kanzi 4.0.0 combined the applyDepthStencil2D and applyDepthStencil3D functions.

◆ 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.

◆ applyRasterization()

void kanzi::CompositionStack::applyRasterization ( )
inline

Applies the topmost rasterization stack state.

If stack is empty, default rasterization settings are used.

Since
Kanzi 4.0.0 removed the renderer parameter.
Kanzi 4.0.0 combined the applyRasterization2D and applyRasterization3D functions.

◆ 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.

◆ getAppliedColorBlend()

const ColorBlendState * kanzi::CompositionStack::getAppliedColorBlend ( ) const
inline

Gets the applied color blend state.

Returns
Pointer to the currently applied color blend state. If no state is applied, nullptr is returned.
Since
Kanzi 4.0.0

◆ getAppliedDepthStencil()

const DepthStencilState * kanzi::CompositionStack::getAppliedDepthStencil ( ) const
inline

Gets the applied depth stencil state.

Returns
Pointer to the currently applied depth stencil state. If no state is applied, nullptr is returned.
Since
Kanzi 4.0.0

◆ getAppliedRasterization()

const RasterizationState * kanzi::CompositionStack::getAppliedRasterization ( ) const
inline

Gets the applied rasterization state.

Returns
Pointer to the currently applied rasterization state. If no state is applied, nullptr is returned.
Since
Kanzi 4.0.0

◆ invalidateAllState()

void kanzi::CompositionStack::invalidateAllState ( )
inline

Invalidates all distinct stacks.

Removes all states from each stack. User should not need to call this function. Intended to be called along Renderer::reset() to signify context change.

◆ pushDefaultSettings2D()

void kanzi::CompositionStack::pushDefaultSettings2D ( )

Pushes a default 2D state into each settings stack.

This does not push the composition stack.

Since
Kanzi 4.0.0

◆ pushDefaultSettings3D()

void kanzi::CompositionStack::pushDefaultSettings3D ( )

Pushes a default 3D state into each settings stack.

This does not push the composition stack.

Since
Kanzi 4.0.0

◆ popSettings()

void kanzi::CompositionStack::popSettings ( )

Pops the topmost state from each composition stack.

This does not pop the composition stack.

Since
Kanzi 4.0.0

◆ setRasterizationFillModeOverride()

void kanzi::CompositionStack::setRasterizationFillModeOverride ( optional< GraphicsFillMode > fillMode)

Sets a manual override of the Rasterization FillMode.

The override takes effect when a pushRasterization, pushDefaultSettings2D, or pushDefaultSettings3D operation occurs.

Parameters
fillModeThe fill mode, or nullopt to disable the override.
Since
Kanzi 4.0.0

◆ setStencilOverride()

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

Sets a manual override of the Stencil State.

The override takes effect when a pushDepthStencil, pushDefaultSettings2D, or pushDefaultSettings3D operation occurs.

Parameters
stencilFuncThe stencil function, or nullopt to disable the override.
referenceValueThe reference value, or nullopt to disable the override.
maskValueThe mask value, or nullopt to disable the override.
stencilFailThe stencil fail operation, or nullopt to disable the override.
stencilPassDepthFailThe stencil pass, but depth fail operation, or nullopt to disable the override.
stencilPassDepthPassThe depth and stencil pass operation, or nullopt to disable the override.
stencilWriteIs stencil write enabled, or nullopt to disable the override.
Since
Kanzi 4.0.0

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