Composition functionality for 2D nodes. More...
#include <kanzi/core.ui/node/node_compositor2d.hpp>
Classes | |
struct | CompositionState |
CompositionState defines the state held by the compositor while Kanzi performs the composition, that is, between calls to beginComposition and blitComposition. More... | |
Public Types | |
enum | CompositingBits { CompositingBitUserTarget, CompositingBitBlend, CompositingBitCache, CompositingBitForce, CompositingBitOffscreen, CompositingBitBlendAndChildren, CompositingBitOpacityAndChildren, CompositingBitPerspective, CompositingBitRequest, CompositingBitEffect, CompositingBitCount } |
Enum for compositing bit flags. More... | |
enum | PotentialCompositingBits { PotentialCompositingBitCache, PotentialCompositingBitViewport, PotentialCompositingBitCount } |
Enum for compositing potential bit flags. More... | |
Public Member Functions | |
bool | beginComposition (Renderer3D &renderer, CompositionStack &compositionStack, CompositionManager *compositionManager, Vector2 requiredSize, bool alphaRequired, bool depthRequired, bool stencilRequired, bool drawFlagSet) |
Begins the composition. More... | |
void | blitComposition (Domain *domain, Renderer3D &renderer, CompositionStack &compositionStack, CompositionManager *compositionManager, QuadDescription &backgroundQuad, const Matrix3x3 &transform, Vector2 quadSize, const Matrix4x4 *perspectiveMatrix, const Matrix4x4 *projectionMatrix) |
Blits the composition. More... | |
void | disableCaching () |
Disable caching. More... | |
void | enableCaching (CachingMode mode) |
Enable caching. More... | |
void | endComposition (Renderer3D &renderer, CompositionStack &compositionStack, CompositionManager *compositionManager) |
End final composition. More... | |
const Geometry & | getBlitGeometry () const |
Gets the blit geometry. More... | |
CachingMode | getCachingMode () const |
Gets the caching mode stored in the compositor. More... | |
const Geometry & | getClearGeometry () const |
Gets the clear geometry. More... | |
BrushRenderer * | getCompositionBrushRenderer () const |
Access composition brush renderer. More... | |
TextureSharedPtr | getCompositionTarget () const |
Access managed composition target. More... | |
NodeEffect2D * | getEffect () const |
Gets the active effect or null pointer. More... | |
NodeEffectRenderer2D * | getEffectRenderer () const |
Gets the active effect renderer or null pointer if compositor has no active effect. More... | |
TextureSharedPtr | getManagedCompositionTarget () const |
Gets the managed composition target. More... | |
Vector2 | getUserCompositionTargetSize () const |
Gets the size of user composition target. More... | |
bool | hasCompositionBrushRenderer () const |
Indicates whether a composition brush renderer has been created. More... | |
bool | hasManagedCompositionTarget () const |
Indicates whether a managed composition target has been allocated. More... | |
bool | hasUserCompositionTarget () const |
Indicates whether user composition target is set. More... | |
void | invalidateCompositionBrush () |
Invalidate composition brush. More... | |
bool | isBlendCompositionRequested () const |
Indicates whether composition due to blending is requested. More... | |
bool | isBlendModeAndChildrenCompositionRequest () const |
Indicates whether composition due to blend mode and children is requested. More... | |
bool | isCacheValid () const |
Indicates whether or not the cache is valid. More... | |
bool | isCompositionPotentiallyRequired () const |
Indicates whether composition can potentially be required during rendering. More... | |
bool | isCompositionRequested () const |
Indicates whether composition is requested from code. More... | |
bool | isCompositionRequired () const |
Indicates whether compositing the node is required. More... | |
bool | isCompositionRequiredDuringRendering (const optional< Matrix3x3 > &transform, bool drawFlagSet) const |
Indicates whether compositing the node is required during rendering. More... | |
bool | isForceComposition () const |
Indicates whether force composition flag is set. More... | |
bool | isOffscreenRendering () const |
Indicates whether offscreen rendering is enabled. More... | |
bool | isOpacityAndChildrenCompositionRequest () const |
Indicates whether composition due to opacity is requested. More... | |
bool | isPerspectiveCompositionRequested () const |
Indicates whether composition due to perspective transform is requested. More... | |
bool | isPotentialCompositionBitViewport () const |
Indicates whether potential composition request flag is set. More... | |
void | onDetached () |
Kanzi calls this function when the node that owns the compositor becomes detached. More... | |
void | renderCompositionQuad (Domain *domain, Renderer &renderer, BrushRenderer &brushRenderer, const Texture &texture, QuadDescription &backgroundQuad, const Matrix4x4 &transform, Vector2 quadSize) |
Render composition quad. More... | |
void | resetBlitGeometry () |
Resets the blit geometry. More... | |
void | resetClearGeometry () |
Resets the clear geometry. More... | |
void | resizeUserCompositionTarget (Vector2 compositionSize) |
Resize automatic sizes in user composition target if necessary. More... | |
void | restoreResources (Renderer &renderer, Vector2 compositionSize) |
Restore resources. More... | |
void | setBlendCompositionRequested (bool enabled) |
Sets the blend composition request flag. More... | |
void | setBlendModeAndChildrenCompositionRequested (bool enabled) |
Sets the opacity composition request flag. More... | |
void | setBlitGeometry (Domain *domain, Renderer &renderer, const QuadDescription &quad) |
Sets the blit geometry for the compositor. More... | |
void | setCacheValid (bool valid) |
Set cache validity flag. More... | |
void | setClearGeometry (Domain *domain, Renderer &renderer, const QuadDescription &quad) |
Sets the clear geometry for the compositor. More... | |
void | setCompositionRequested (bool enabled) |
Sets the compositing request. More... | |
void | setEffect (NodeEffect2D *effect) |
Sets the active effect or clears the active effect with empty shared pointer. More... | |
void | setForceComposition (bool enabled) |
Sets force composition. More... | |
void | setOffscreenRendering (bool enabled) |
Sets the offscreen rendering flag. More... | |
void | setOpacityAndChildrenCompositionRequested (bool enabled) |
Sets the opacity composition request flag. More... | |
void | setPerspectiveCompositionRequested (bool enabled) |
Sets the perspective composition request flag. More... | |
void | setPotentialCompositionBitVierport (bool enabled) |
Sets the potential composition request flag. More... | |
void | setUserCompositionBrush (BrushSharedPtr brush) |
Sets user composition brush. More... | |
void | setUserCompositionTarget (TextureSharedPtr texture) |
Set user composition target. More... | |
void | updateRender (Node2D &node, Vector2 actualSize, bool alphaRequired, bool depthRequired, bool stencilRequired, optional< int > blendMode, float opacity, bool opaquenessHint, bool translucencyHint) |
Update for rendering, recreating composition targets and brush renderers as needed. More... | |
~NodeCompositor2D () | |
Destructor. More... | |
Static Public Member Functions | |
static unique_ptr< NodeCompositor2D > | create () |
Creates a NodeCompositor2D. More... | |
Protected Member Functions | |
TextureSharedPtr | beginFinalComposition (CompositionStack &compositionStack, CompositionManager *compositionManager, Vector2 requiredSize, bool alphaRequired, bool depthRequired, bool stencilRequired, bool needsRender) |
Begins the final composition. More... | |
void | blitFinalComposition (Domain *domain, Renderer3D &renderer, CompositionStack &compositionStack, CompositionManager *compositionManager, TextureSharedPtr renderTargetTexture, QuadDescription &backgroundQuad, const Matrix3x3 &transform, Vector2 quadSize, const Matrix4x4 *perspectiveMatrix, const Matrix4x4 *projectionMatrix) |
Blits the final composition. More... | |
void | endFinalComposition (CompositionStack &compositionStack) |
Ends the final composition. More... | |
bool | isRenderRequired (bool drawFlagSet) const |
Indicates whether node rendering is required. More... | |
NodeCompositor2D () | |
Default constructor. More... | |
bool | updatePersistentCompositionTarget (Node2D &node, TextureSharedPtr &managedCompositionTarget, Vector2 requiredSize, bool alphaRequired, bool depthRequired, bool stencilRequired) |
Update the managed composition target to match current requirements. More... | |
Protected Attributes | |
optional< int > | m_blendMode |
Saved blend mode. More... | |
GeometrySharedPtr | m_blitGeometry |
Geometry used to blit the composition. More... | |
QuadDescription | m_blitQuad |
Quad description used to blit the composition. More... | |
bool | m_brushRenderersDirty |
Brush renderer dirty flag. More... | |
bool | m_cacheValid |
Cache status flag. More... | |
CachingMode | m_cachingMode |
Caching mode setting. More... | |
GeometrySharedPtr | m_clearGeometry |
Geometry used to clear the composition if necessary. More... | |
QuadDescription | m_clearQuad |
Quad description used to clear the composition if necessary. More... | |
bitset< CompositingBitCount > | m_compositingMask |
Bit mask for states affecting whether or not the node should compose itself and its children. More... | |
BrushRendererPtr | m_compositionBrushRenderer |
Composition brush renderer. More... | |
NodeEffectRenderer2DUniquePtr | m_effectRenderer |
Effect renderer instance, or null if no effect is active. More... | |
bool | m_effectRequiresCompositionBlit |
Whether the effect blit needs to be followed with composition blit. More... | |
CompositionBrushSharedPtr | m_managedCompositionBrush |
Composition brush managed by node. More... | |
TextureSharedPtr | m_managedCompositionTarget |
Current framebuffer. More... | |
bool | m_opaquenessHint |
Saved opaqueness hint. More... | |
bitset< PotentialCompositingBitCount > | m_potentialCompositingMask |
Bit mask for states affecting whether or not the node should potentially compose itself and its children. More... | |
optional< CompositionState > | m_state |
Active composition state, or nullopt if the composition is not active. More... | |
bool | m_translucencyHint |
Saved tTranslucency hint. More... | |
BrushSharedPtr | m_userCompositionBrush |
User-set composition brush. More... | |
TextureSharedPtr | m_userCompositionTarget |
User-set composition target. More... | |
Composition functionality for 2D nodes.
Enum for compositing bit flags.
kanzi::NodeCompositor2D::~NodeCompositor2D | ( | ) |
Destructor.
|
explicitprotected |
Default constructor.
|
static |
Creates a NodeCompositor2D.
bool kanzi::NodeCompositor2D::beginComposition | ( | Renderer3D & | renderer, |
CompositionStack & | compositionStack, | ||
CompositionManager * | compositionManager, | ||
Vector2 | requiredSize, | ||
bool | alphaRequired, | ||
bool | depthRequired, | ||
bool | stencilRequired, | ||
bool | drawFlagSet | ||
) |
Begins the composition.
renderer | Renderer to use. |
compositionStack | Composition stack to use. |
compositionManager | Composition manager to use. |
requiredSize | Size required of the composition target. |
alphaRequired | Alpha requirement. |
depthRequired | Depth requirement. |
stencilRequired | Stencil requirement. |
drawFlagSet | Whether the draw flag is set for the node or any of its descendants. |
void kanzi::NodeCompositor2D::endComposition | ( | Renderer3D & | renderer, |
CompositionStack & | compositionStack, | ||
CompositionManager * | compositionManager | ||
) |
End final composition.
renderer | Renderer to use. |
compositionStack | Composition stack to use. |
compositionManager | Composition manager to use. |
void kanzi::NodeCompositor2D::blitComposition | ( | Domain * | domain, |
Renderer3D & | renderer, | ||
CompositionStack & | compositionStack, | ||
CompositionManager * | compositionManager, | ||
QuadDescription & | backgroundQuad, | ||
const Matrix3x3 & | transform, | ||
Vector2 | quadSize, | ||
const Matrix4x4 * | perspectiveMatrix, | ||
const Matrix4x4 * | projectionMatrix | ||
) |
Blits the composition.
domain | Domain to use. |
renderer | Renderer to use. |
compositionStack | Composition stack to use. |
compositionManager | Composition manager to use. |
backgroundQuad | Clip quad for background area. |
transform | Transform used for rendering. |
quadSize | Rendered quad size. |
perspectiveMatrix | Optional transform to use for perspective projection. |
projectionMatrix | Optional projection to use for perspective projection. |
void kanzi::NodeCompositor2D::renderCompositionQuad | ( | Domain * | domain, |
Renderer & | renderer, | ||
BrushRenderer & | brushRenderer, | ||
const Texture & | texture, | ||
QuadDescription & | backgroundQuad, | ||
const Matrix4x4 & | transform, | ||
Vector2 | quadSize | ||
) |
TextureSharedPtr kanzi::NodeCompositor2D::getCompositionTarget | ( | ) | const |
Access managed composition target.
void kanzi::NodeCompositor2D::resizeUserCompositionTarget | ( | Vector2 | compositionSize | ) |
Resize automatic sizes in user composition target if necessary.
compositionSize | Composition size to resize to. |
void kanzi::NodeCompositor2D::onDetached | ( | ) |
Kanzi calls this function when the node that owns the compositor becomes detached.
Restore resources.
Will restore all GL resources and resize render targets with automatic size.
renderer | Renderer to use. |
compositionSize | Composition size to resize to. |
void kanzi::NodeCompositor2D::updateRender | ( | Node2D & | node, |
Vector2 | actualSize, | ||
bool | alphaRequired, | ||
bool | depthRequired, | ||
bool | stencilRequired, | ||
optional< int > | blendMode, | ||
float | opacity, | ||
bool | opaquenessHint, | ||
bool | translucencyHint | ||
) |
Update for rendering, recreating composition targets and brush renderers as needed.
node | The node to which to attach. |
blendMode | Optional blend mode to select for the composition brush. |
actualSize | Size required of the composition target. |
alphaRequired | Alpha requirement. |
depthRequired | Depth requirement. |
stencilRequired | Stencil requirement. |
opacity | Opacity value that should be used for rendering. |
opaquenessHint | Whether to use opaque rendering. |
translucencyHint | Whether to use translucent rendering. |
blendMode
parameter added.
|
inline |
Access composition brush renderer.
|
inline |
Indicates whether a composition brush renderer has been created.
|
inline |
Sets user composition brush.
brush | Brush to use as the composition brush. |
Vector2 kanzi::NodeCompositor2D::getUserCompositionTargetSize | ( | ) | const |
Gets the size of user composition target.
|
inline |
Indicates whether user composition target is set.
|
inline |
Set user composition target.
|
inline |
Invalidate composition brush.
|
inline |
Gets the caching mode stored in the compositor.
|
inline |
Enable caching.
mode | New caching mode, must not be CachingModeDisabled. |
|
inline |
Disable caching.
|
inline |
Indicates whether or not the cache is valid.
|
inline |
Set cache validity flag.
valid | Cache status flag. |
|
inline |
Indicates whether compositing the node is required.
This query does not take draw flags into account.
|
inline |
Indicates whether composition can potentially be required during rendering.
This status is in addition to the obligatory requirement.
bool kanzi::NodeCompositor2D::isCompositionRequiredDuringRendering | ( | const optional< Matrix3x3 > & | transform, |
bool | drawFlagSet | ||
) | const |
Indicates whether compositing the node is required during rendering.
This status is in addition to the obligatory requirement.
transform | Local override transform for the node. |
drawFlagSet | Whether the draw flag is set for the node or any of its descendants. |
|
inline |
Indicates whether composition is requested from code.
|
inline |
Sets the compositing request.
enabled | New flag state. |
|
inline |
Indicates whether force composition flag is set.
|
inline |
Sets force composition.
enabled | New flag state. |
|
inline |
Indicates whether offscreen rendering is enabled.
|
inline |
Sets the offscreen rendering flag.
enabled | New flag state. |
|
inline |
Indicates whether composition due to blending is requested.
|
inline |
Sets the blend composition request flag.
enabled | New flag state. |
|
inline |
Indicates whether composition due to blend mode and children is requested.
|
inline |
Sets the opacity composition request flag.
enabled | New flag state. |
|
inline |
Indicates whether composition due to opacity is requested.
|
inline |
Sets the opacity composition request flag.
enabled | New flag state. |
|
inline |
Indicates whether composition due to perspective transform is requested.
|
inline |
Sets the perspective composition request flag.
enabled | New flag state. |
|
inline |
Indicates whether potential composition request flag is set.
|
inline |
Sets the potential composition request flag.
enabled | New flag state. |
|
inline |
Gets the managed composition target.
|
inline |
Indicates whether a managed composition target has been allocated.
void kanzi::NodeCompositor2D::setEffect | ( | NodeEffect2D * | effect | ) |
Sets the active effect or clears the active effect with empty shared pointer.
effect | Effect instance or empty shared pointer. |
NodeEffect2D* kanzi::NodeCompositor2D::getEffect | ( | ) | const |
Gets the active effect or null pointer.
|
inline |
Gets the active effect renderer or null pointer if compositor has no active effect.
|
inline |
Gets the clear geometry.
void kanzi::NodeCompositor2D::resetClearGeometry | ( | ) |
Resets the clear geometry.
void kanzi::NodeCompositor2D::setClearGeometry | ( | Domain * | domain, |
Renderer & | renderer, | ||
const QuadDescription & | quad | ||
) |
|
inline |
Gets the blit geometry.
void kanzi::NodeCompositor2D::resetBlitGeometry | ( | ) |
Resets the blit geometry.
void kanzi::NodeCompositor2D::setBlitGeometry | ( | Domain * | domain, |
Renderer & | renderer, | ||
const QuadDescription & | quad | ||
) |
|
protected |
Update the managed composition target to match current requirements.
If the composition target does not exist or the settings required from it have changed, it is (re)created.
node | Node to attach to. |
managedCompositionTarget | Existing composition target. |
requiredSize | Size required of the composition target. |
alphaRequired | Alpha requirement. |
depthRequired | Depth requirement. |
stencilRequired | Stencil requirement. |
|
protected |
Begins the final composition.
compositionStack | Composition stack to use. |
compositionManager | Composition manager to use. |
requiredSize | Size required of the composition target. |
alphaRequired | Alpha requirement. |
depthRequired | Depth requirement. |
stencilRequired | Stencil requirement. |
needsRender | Whether to perform node rendering. |
|
protected |
Ends the final composition.
compositionStack | Composition stack to use. |
|
protected |
Blits the final composition.
domain | Domain to use. |
renderer | Renderer to use. |
compositionStack | Composition stack to use. |
compositionManager | Composition manager to use. |
renderTargetTexture | Render target texture used. |
backgroundQuad | Clip quad for background area. |
transform | Transform used for rendering. |
quadSize | Rendered quad size. |
perspectiveMatrix | Optional transform to use for perspective projection. |
projectionMatrix | Optional projection to use for perspective projection. |
|
protected |
Indicates whether node rendering is required.
|
protected |
Current framebuffer.
|
protected |
Caching mode setting.
|
protected |
Cache status flag.
|
protected |
User-set composition brush.
|
protected |
User-set composition target.
|
protected |
Composition brush managed by node.
|
protected |
Composition brush renderer.
|
protected |
Quad description used to clear the composition if necessary.
|
protected |
Geometry used to clear the composition if necessary.
|
protected |
Quad description used to blit the composition.
|
protected |
Geometry used to blit the composition.
|
protected |
Saved blend mode.
|
protected |
Saved opaqueness hint.
|
protected |
Saved tTranslucency hint.
|
protected |
Brush renderer dirty flag.
|
protected |
Bit mask for states affecting whether or not the node should compose itself and its children.
|
protected |
Bit mask for states affecting whether or not the node should potentially compose itself and its children.
|
protected |
Active composition state, or nullopt if the composition is not active.
|
protected |
Effect renderer instance, or null if no effect is active.
|
protected |
Whether the effect blit needs to be followed with composition blit.