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< NativeCompositionTargetHandle > | peekCompositionTargetHandle () const |
Get current composition target handle. More... | |
optional< Vector2 > | peekRenderContextSize () const |
Get current composition target size. More... | |
optional< Vector4 > | peekScissor () const |
Get current scissor. More... | |
optional< Vector4 > | peekViewport () const |
Get current viewport. More... | |
optional< Vector2 > | peekViewportOffset () const |
Get current viewport offset. More... | |
optional< Vector2 > | peekViewportSize () const |
Get current viewport size. More... | |
optional< ViewportRectangle > | peekViewportDeviceCoordinates () |
Get current viewport in device coordinates. More... | |
optional< ViewportRectangle > | peekScissorDeviceCoordinates () |
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... | |
Composition stack for managing current render context.
The stack has no ownership over the stored render targets - they will not be reserved or deleted.
typedef unsigned int kanzi::CompositionStack::NativeCompositionTargetHandle |
Composition target handle for OpenGL.
|
inlineexplicit |
Constructor.
|
inlineexplicit |
Constructor.
handle | Composition target handle. |
size | Composition target size. |
|
inlineexplicit |
Constructor.
handle | Composition target handle. |
size | Composition target size. |
viewport | Viewport area. |
scissor | Scissor area. |
|
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.
blendMode | Blend mode. |
colorWriteMode | Color write mode. |
|
inline |
Pop blend state from blend stack.
void kanzi::CompositionStack::pushComposition | ( | NativeCompositionTargetHandle | handle, |
Vector2 | size | ||
) |
Push a composition target into the composition stack.
handle | Composition target handle. |
size | Composition target size. |
void kanzi::CompositionStack::pushComposition | ( | Texture & | texture | ) |
Push a composition target into the composition stack.
texture | Composition target. |
Push a composition target into the composition stack.
texture | Composition target. |
size | Composition target size. |
void kanzi::CompositionStack::pushComposition | ( | Framebuffer & | framebuffer, |
Vector2 | size | ||
) |
Push a framebuffer into the composition stack.
framebuffer | Framebuffer. |
size | Composition target size. |
void kanzi::CompositionStack::pushComposition | ( | optional< Vector4 > | viewport, |
optional< Vector4 > | scissor | ||
) |
Push a viewport and/or scissor onto composition stack.
viewport | optional viewport area. |
scissor | optional scissor area. |
void kanzi::CompositionStack::pushComposition | ( | Texture & | texture, |
Vector4 | viewport, | ||
optional< Vector4 > | scissor | ||
) |
Push a composition target and a viewport into the composition stack.
texture | Composition target. |
viewport | Viewport area. |
scissor | Scissor area. |
|
inline |
Push a composition target and a viewport into the composition stack.
handle | Composition target handle. |
size | Composition target size. |
viewport | Viewport area. |
scissor | Scissor area. |
|
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.
depthFunc | Depth testing function. |
depthWrite | Depth write enabled? |
stencilfunc | Stencil function. |
referenceValue | Stencil reference value. |
maskValue | Stencil mask value. |
stencilFail | Operation for stencil fail. |
stencilPassDepthFail | Operation for stencil pass but depth fail. |
stencilPassDepthPass | Operation for stencil and depth pass. |
stencilWrite | Stencil write enabled? |
|
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.
cullMode | Culling mode. |
|
inline |
Pop a rasterization state from the stack.
|
inline |
Get the debug composer used by this render context stack.
|
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.
renderer | Renderer 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.
renderer | Renderer to use. |
worldPerspectiveOffset | World perspective offset provided by 2D rendering. |
|
inline |
|
inline |
Get current composition target size.
This function exists for tests.
|
inline |
Get current scissor.
|
inline |
Get current viewport.
|
inline |
Get current viewport offset.
|
inline |
Get current viewport size.
Disregards scissor.
|
inline |
Get current viewport in device coordinates.
This function exists for tests.
|
inline |
Get current device coordinate scissor.
This function exists for tests.
|
inline |
Apply blend stack.
If stack is empty, default 2D blend settings are used.
renderer | Renderer to use. |
|
inline |
Apply blend stack.
If stack is empty, default 3D blend settings are used.
renderer | Renderer to use. |
|
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.
|
inline |
Apply composition stack.
Default composition state for 2D is not defined.
renderer | Renderer to use. |
|
inline |
Apply composition stack.
Default composition state for 2D is not defined.
renderer | Renderer to use. |
|
inline |
Invalidate composition stack state.
Should only be called when manually modifying composition state so that applying again will not assume no changes.
|
inline |
Apply depth/stencil stack If stack is empty, default depth/stencil settings are used.
renderer | Renderer to use. |
|
inline |
Apply depth/stencil stack If stack is empty, default depth/stencil settings are used.
renderer | Renderer to use. |
|
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.
|
inline |
Apply rasterization stack.
If stack is empty, default rasterization settings are used.
renderer | Renderer to use. |
|
inline |
Apply rasterization stack.
If stack is empty, default rasterization settings are used.
renderer | Renderer to use. |
|
inline |
Invalidate rasterization stack state.
Should only be called when manually modifying rasterization state so that applying again will not assume no changes.
|
inline |
Invalidate all distinct stacks.
User should not need to call this function. Intended to be called along #Renderer3D::reset() to signify context change.