kanzi::NodeCompositor2D Class Reference

Composition functionality for 2D nodes. More...

#include <kanzi/core.ui/node/node_compositor2d.hpp>

Classes

struct  ManagedCompositionTarget
 Managed composition target container. More...
 
struct  PerspectiveTransformParameters
 Perspective transform container. More...
 

Public Types

enum  ComposeChildrenBits { ChildrenCompositingBitCache, ChildrenCompositingBitRequest, ChildrenCompositingBitCount }
 Enum for children compositing bit flags. More...
 
enum  ComposeFinalBits {
  FinalCompositingBitCache, FinalCompositingBitForce, FinalCompositingBitOffscreen, FinalCompositingBitOpacity,
  FinalCompositingBitRequest, FinalCompositingBitCount
}
 Enum for final result compositing bit flags. More...
 
enum  ComposeSelfBits { SelfCompositingBitCache, SelfCompositingBitRequest, SelfCompositingBitCount }
 Enum for self compositing bit flags. More...
 

Public Member Functions

 NodeCompositor2D ()
 Constructor. More...
 
tuple< TextureSharedPtr, bool > beginFinalComposition (CompositionStack &compositionStack, CompositionManager *compositionManager, Vector2 requiredSize, bool alphaRequired, bool depthRequired, bool stencilRequired)
 Begin final composition. More...
 
void endFinalComposition (CompositionStack &compositionStack)
 End final composition. More...
 
void blitFinalComposition (Renderer3D &renderer, CompositionStack &compositionStack, CompositionManager *compositionManager, TextureSharedPtr renderTargetTexture, QuadDescription &backgroundQuad, const Matrix3x3 &transform, Vector2 quadSize)
 Blit final composition. More...
 
tuple< TextureSharedPtr, bool > beginSelfComposition (CompositionStack &compositionStack, Vector2 requiredSize)
 Begin self composition. More...
 
void endSelfComposition (CompositionStack &compositionStack)
 
void blitSelfComposition (Renderer3D &renderer, CompositionStack &compositionStack, Texture &texture, QuadDescription &backgroundQuad, const Matrix3x3 &transform, Vector2 quadSize)
 Blit self composition. More...
 
tuple< TextureSharedPtr, bool > beginChildrenComposition (CompositionStack &compositionStack, Vector2 requiredSize)
 Begin children composition. More...
 
void endChildrenComposition (CompositionStack &compositionStack)
 
void blitChildrenComposition (Renderer3D &renderer, CompositionStack &compositionStack, Texture &texture, QuadDescription &backgroundQuad, const Matrix3x3 &transform, Vector2 quadSize)
 Blit self composition. More...
 
void renderCompositionQuad (Renderer3D &renderer, BrushRenderer &brushRenderer, const Texture &texture, QuadDescription &backgroundQuad, const Matrix4x4 &transform, Vector2 quadSize)
 Render composition quad. More...
 
void createCompositionBrushRenderer (Node &node, Brush &brush, TextureSharedPtr texture)
 Create composition brush renderer. More...
 
TextureSharedPtr getCacheChildrenCompositionTarget () const
 Access cache composition target for Node2D's children. More...
 
TextureSharedPtr getCacheSelfCompositionTarget () const
 Access cache composition target for Node2D itself. More...
 
TextureSharedPtr getFinalCompositionTarget () const
 Access 'final' managed composition target. More...
 
void resizeUserCompositionTarget (Vector2 desiredSize)
 Resize automatic sizes in user composition target if necessary. More...
 
void onDetached ()
 Run when node owning the compositor becomes detached. More...
 
void restoreResources ()
 Restore resources. More...
 
void updateRender (Node2D &node, Vector2 actualSize, bool alphaRequired, bool depthRequired, bool stencilRequired, float opacity, bool opaquenessHint, bool translucencyHint)
 Update for rendering, recreating composition targets and brush renderers as needed. More...
 
BrushRenderergetCacheChildrenBrushRenderer () const
 Access cache children brush renderer. More...
 
BrushRenderergetCacheSelfBrushRenderer () const
 Access cache self brush renderer. More...
 
BrushRenderergetCompositionBrushRenderer () const
 Access composition brush renderer. More...
 
bool hasCompositionBrushRenderer () const
 Tell if composition brush renderer has been created. More...
 
bool hasManagedCompositionTargetFinal () const
 Tell if managed composition target has been created. More...
 
void setUserCompositionBrush (BrushSharedPtr brush)
 Set user composition brush. More...
 
Vector2 getUserCompositionTargetSize () const
 Get size of user composition target. More...
 
void setUserCompositionTarget (TextureSharedPtr texture)
 Set user composition target. More...
 
bool isCacheChildren () const
 Tell if cache children has been set. More...
 
void setCacheChildren (bool enabled)
 Set cache children state. More...
 
bool isCacheResult () const
 Tell if cache result has been set. More...
 
void setCacheResult (bool enabled)
 Set cache result state. More...
 
bool isCacheSelf () const
 Tell if cache self has been set. More...
 
void setCacheSelf (bool enabled)
 Set cache self state. More...
 
void invalidateCompositionBrush ()
 Invalidate composition brush. More...
 
bool isCacheChildrenValid () const
 Tell if children cache is valid. More...
 
void setCacheChildrenValid (bool valid)
 Mark self cache as valid. More...
 
bool isCacheFinalValid () const
 Tell if final cache is valid. More...
 
void setCacheFinalValid (bool valid)
 Mark final cache as valid. More...
 
bool isCacheSelfValid () const
 Tell if self cache is valid. More...
 
void setCacheSelfValid (bool valid)
 Mark self cache as valid. More...
 
bool isChildrenCompositionRequired () const
 Tell if compositing children is required. More...
 
bool isFinalCompositionRequired () const
 Tell if compositing final result is required. More...
 
bool isSelfCompositionRequired () const
 Tell if compositing self is required. More...
 
bool isFinalCompositionRequested () const
 Is compositing requested from code? More...
 
void setFinalCompositionRequested (bool enabled)
 Set compositing request. More...
 
bool isForceComposition () const
 Is force composition on? More...
 
void setForceComposition (bool enabled)
 Set force composition. More...
 
bool isOffscreenRendering () const
 Is offscreen rendering on? More...
 
void setOffscreenRendering (bool enabled)
 Set offscreen rendering flag. More...
 
bool isOpacityCompositionRequest () const
 Is Opacity composition request flag on? More...
 
void setOpacityCompositionRequested (bool enabled)
 Set opacity composition request flag. More...
 
void resetManagedCompositionTargetCacheChildren ()
 Reset cache children managed composition target. More...
 
void resetManagedCompositionTargetCacheSelf ()
 Reset cache self managed composition target. More...
 
void resetManagedCompositionTargetFinal ()
 Reset final managed composition target. More...
 
const Matrix4x4getPerspectiveTransform () const
 Access perspective transform. More...
 
void resetPerspectiveTransform ()
 Reset perspective transform. More...
 
void setPerspectiveTransform (const Matrix4x4 &transform)
 Set perspective transform. More...
 
const Vector4getWorldPerspectiveOffset () const
 Access world perspective transform. More...
 
void resetWorldPerspectiveOffset ()
 Reset world perspective transform. More...
 
void setWorldPerspectiveOffset (const Vector4 &offset)
 Set world perspective transform. More...
 

Protected Member Functions

bool updatePersistentCompositionTarget (Node2D &node, ManagedCompositionTarget &managedCompositionTarget, Vector2 requiredSize, bool alphaRequired, bool depthRequired, bool stencilRequired)
 Update a managed composition target to match current requirements. More...
 

Protected Attributes

ManagedCompositionTarget m_finalCompositionTarget
 Managed composition target for complete node composition. More...
 
ManagedCompositionTarget m_cacheChildrenCompositionTarget
 Managed composition target for caching children. More...
 
ManagedCompositionTarget m_cacheSelfCompositionTarget
 Managed composition target for caching node contents. More...
 
BrushSharedPtr m_userCompositionBrush
 User-set composition brush. More...
 
TextureSharedPtr m_userCompositionTarget
 User-set composition target. More...
 
CompositionBrushSharedPtr m_cacheChildrenBrush
 Brush used to render cached children. More...
 
BrushRendererPtr m_cacheChildrenBrushRenderer
 Cache children brush renderer. More...
 
CompositionBrushSharedPtr m_cacheSelfBrush
 Brush used to render cached node itself. More...
 
BrushRendererPtr m_cacheSelfBrushRenderer
 Cache self brush renderer. More...
 
CompositionBrushSharedPtr m_managedCompositionBrush
 Composition brush managed by node. More...
 
BrushRendererPtr m_compositionBrushRenderer
 Composition brush renderer. More...
 
unique_ptr< PerspectiveTransformParametersm_perspective
 Perspective components. More...
 
bitset< ChildrenCompositingBitCountm_childrenComposeMask
 Bit mask for states affecting whether or not the node should compose its children. More...
 
bitset< FinalCompositingBitCountm_finalComposeMask
 Bit mask for states affecting whether or not the node should compose itself and its children. More...
 
bitset< SelfCompositingBitCountm_selfComposeMask
 Bit mask for states affecting whether or not the node should compose itself. More...
 

Detailed Description

Composition functionality for 2D nodes.

Member Enumeration Documentation

Enum for children compositing bit flags.

Enumerator
ChildrenCompositingBitCache 

Caching.

ChildrenCompositingBitRequest 

Request from code.

ChildrenCompositingBitCount 

Number of options.

Enum for final result compositing bit flags.

Enumerator
FinalCompositingBitCache 

Caching.

FinalCompositingBitForce 

Force composition from property.

FinalCompositingBitOffscreen 

Offscreen rendering.

FinalCompositingBitOpacity 

Composition due to opacity and children.

FinalCompositingBitRequest 

Request from code.

FinalCompositingBitCount 

Number of options.

Enum for self compositing bit flags.

Enumerator
SelfCompositingBitCache 

Caching.

SelfCompositingBitRequest 

Request from code.

SelfCompositingBitCount 

Number of options.

Constructor & Destructor Documentation

kanzi::NodeCompositor2D::NodeCompositor2D ( )
inline

Constructor.

Member Function Documentation

bool kanzi::NodeCompositor2D::updatePersistentCompositionTarget ( Node2D node,
ManagedCompositionTarget managedCompositionTarget,
Vector2  requiredSize,
bool  alphaRequired,
bool  depthRequired,
bool  stencilRequired 
)
protected

Update a managed composition target to match current requirements.

If the composition target does not exist or the settings required from it have been changed, it is (re)created.

Parameters
nodeNode to attach to.
managedCompositionTargetExisting composition target container.
requiredSizeSize required of the composition target.
alphaRequiredAlpha requirement.
depthRequiredDepth requirement.
stencilRequiredStencil requirement.
Returns
True if composition target was updated, false if not.
tuple<TextureSharedPtr, bool> kanzi::NodeCompositor2D::beginFinalComposition ( CompositionStack compositionStack,
CompositionManager compositionManager,
Vector2  requiredSize,
bool  alphaRequired,
bool  depthRequired,
bool  stencilRequired 
)

Begin final composition.

Parameters
compositionStackComposition stack to use.
compositionManagerComposition manager to use.
requiredSizeSize required of the composition target.
alphaRequiredAlpha requirement.
depthRequiredDepth requirement.
stencilRequiredStencil requirement.
Returns
Tuple of render target to use and whether or not to perform actual render.
void kanzi::NodeCompositor2D::endFinalComposition ( CompositionStack compositionStack)

End final composition.

Parameters
compositionStackComposition stack to use.
void kanzi::NodeCompositor2D::blitFinalComposition ( Renderer3D renderer,
CompositionStack compositionStack,
CompositionManager compositionManager,
TextureSharedPtr  renderTargetTexture,
QuadDescription backgroundQuad,
const Matrix3x3 transform,
Vector2  quadSize 
)

Blit final composition.

Parameters
rendererRenderer to use.
compositionStackComposition stack to use.
compositionManagerComposition manager to use.
renderTargetTextureRender target texture used.
backgroundQuadClip quad for background area.
transformTransform used for rendering.
quadSizeRendered quad size.
tuple<TextureSharedPtr, bool> kanzi::NodeCompositor2D::beginSelfComposition ( CompositionStack compositionStack,
Vector2  requiredSize 
)

Begin self composition.

Parameters
compositionStackComposition stack to use.
requiredSizeSize required of the composition target.
Returns
Tuple of render target to use and whether or not to perform actual render.
void kanzi::NodeCompositor2D::endSelfComposition ( CompositionStack compositionStack)
Parameters
compositionStackComposition stack to use. Begin self composition.
void kanzi::NodeCompositor2D::blitSelfComposition ( Renderer3D renderer,
CompositionStack compositionStack,
Texture texture,
QuadDescription backgroundQuad,
const Matrix3x3 transform,
Vector2  quadSize 
)

Blit self composition.

Parameters
rendererRenderer to use.
compositionStackComposition stack to use.
textureTexture used.
backgroundQuadClip quad for background area.
transformTransform used for rendering.
quadSizeRendered quad size.
tuple<TextureSharedPtr, bool> kanzi::NodeCompositor2D::beginChildrenComposition ( CompositionStack compositionStack,
Vector2  requiredSize 
)

Begin children composition.

Parameters
compositionStackComposition stack to use.
requiredSizeSize required of the composition target.
Returns
Tuple of render target to use and whether or not to perform actual render.
void kanzi::NodeCompositor2D::endChildrenComposition ( CompositionStack compositionStack)
Parameters
compositionStackComposition stack to use. Begin self composition.
void kanzi::NodeCompositor2D::blitChildrenComposition ( Renderer3D renderer,
CompositionStack compositionStack,
Texture texture,
QuadDescription backgroundQuad,
const Matrix3x3 transform,
Vector2  quadSize 
)

Blit self composition.

Parameters
rendererRenderer to use.
compositionStackComposition stack to use.
textureTexture used.
backgroundQuadClip quad for background area.
transformTransform used for rendering.
quadSizeRendered quad size.
void kanzi::NodeCompositor2D::renderCompositionQuad ( Renderer3D renderer,
BrushRenderer brushRenderer,
const Texture texture,
QuadDescription backgroundQuad,
const Matrix4x4 transform,
Vector2  quadSize 
)

Render composition quad.

Parameters
rendererRenderer to use.
compositionStackComposition stack to use.
textureTexture used.
backgroundQuadClip quad for background area.
renderTransformTransform used for rendering.
quadSizeRendered quad size.
void kanzi::NodeCompositor2D::createCompositionBrushRenderer ( Node node,
Brush brush,
TextureSharedPtr  texture 
)

Create composition brush renderer.

Parameters
nodeNode to attach to.
brushBrush to create from.
textureTexture to use.
TextureSharedPtr kanzi::NodeCompositor2D::getCacheChildrenCompositionTarget ( ) const

Access cache composition target for Node2D's children.

Will only function if Node2D has been transformed. Will deploy the composition target if necessary.

Returns
Render target pointer.
TextureSharedPtr kanzi::NodeCompositor2D::getCacheSelfCompositionTarget ( ) const

Access cache composition target for Node2D itself.

Will only function if Node2D has been transformed. Will deploy the composition target if necessary.

Returns
Render target pointer.
TextureSharedPtr kanzi::NodeCompositor2D::getFinalCompositionTarget ( ) const

Access 'final' managed composition target.

Will deploy the composition target if necessary.

void kanzi::NodeCompositor2D::resizeUserCompositionTarget ( Vector2  desiredSize)

Resize automatic sizes in user composition target if necessary.

Parameters
desiredSizeDesired size to resize to.
void kanzi::NodeCompositor2D::onDetached ( )

Run when node owning the compositor becomes detached.

void kanzi::NodeCompositor2D::restoreResources ( )

Restore resources.

void kanzi::NodeCompositor2D::updateRender ( Node2D node,
Vector2  actualSize,
bool  alphaRequired,
bool  depthRequired,
bool  stencilRequired,
float  opacity,
bool  opaquenessHint,
bool  translucencyHint 
)

Update for rendering, recreating composition targets and brush renderers as needed.

Parameters
nodeNode to attach to.
actualSizeSize required of the composition target.
alphaRequiredAlpha requirement.
depthRequiredDepth requirement.
stencilRequiredStencil requirement.
opacityOpacity value that should be used for rendering.
opaquenessHintShould opaque rendering especially be used?
translucencyHintShould translucent rendering especially be used?
BrushRenderer* kanzi::NodeCompositor2D::getCacheChildrenBrushRenderer ( ) const
inline

Access cache children brush renderer.

BrushRenderer* kanzi::NodeCompositor2D::getCacheSelfBrushRenderer ( ) const
inline

Access cache self brush renderer.

BrushRenderer* kanzi::NodeCompositor2D::getCompositionBrushRenderer ( ) const
inline

Access composition brush renderer.

bool kanzi::NodeCompositor2D::hasCompositionBrushRenderer ( ) const
inline

Tell if composition brush renderer has been created.

bool kanzi::NodeCompositor2D::hasManagedCompositionTargetFinal ( ) const
inline

Tell if managed composition target has been created.

void kanzi::NodeCompositor2D::setUserCompositionBrush ( BrushSharedPtr  brush)
inline

Set user composition brush.

Vector2 kanzi::NodeCompositor2D::getUserCompositionTargetSize ( ) const
inline

Get size of user composition target.

Returns
Size of composition target or zero vector.
void kanzi::NodeCompositor2D::setUserCompositionTarget ( TextureSharedPtr  texture)
inline

Set user composition target.

bool kanzi::NodeCompositor2D::isCacheChildren ( ) const
inline

Tell if cache children has been set.

void kanzi::NodeCompositor2D::setCacheChildren ( bool  enabled)
inline

Set cache children state.

Parameters
enabledNew cache children state.
bool kanzi::NodeCompositor2D::isCacheResult ( ) const
inline

Tell if cache result has been set.

void kanzi::NodeCompositor2D::setCacheResult ( bool  enabled)
inline

Set cache result state.

Parameters
enabledNew cache result state.
bool kanzi::NodeCompositor2D::isCacheSelf ( ) const
inline

Tell if cache self has been set.

void kanzi::NodeCompositor2D::setCacheSelf ( bool  enabled)
inline

Set cache self state.

Parameters
enabledNew cache children state.
void kanzi::NodeCompositor2D::invalidateCompositionBrush ( )
inline

Invalidate composition brush.

bool kanzi::NodeCompositor2D::isCacheChildrenValid ( ) const
inline

Tell if children cache is valid.

void kanzi::NodeCompositor2D::setCacheChildrenValid ( bool  valid)
inline

Mark self cache as valid.

Parameters
validNew validity status.
bool kanzi::NodeCompositor2D::isCacheFinalValid ( ) const
inline

Tell if final cache is valid.

void kanzi::NodeCompositor2D::setCacheFinalValid ( bool  valid)
inline

Mark final cache as valid.

Parameters
validNew validity status.
bool kanzi::NodeCompositor2D::isCacheSelfValid ( ) const
inline

Tell if self cache is valid.

void kanzi::NodeCompositor2D::setCacheSelfValid ( bool  valid)
inline

Mark self cache as valid.

Parameters
validNew validity status.
bool kanzi::NodeCompositor2D::isChildrenCompositionRequired ( ) const
inline

Tell if compositing children is required.

bool kanzi::NodeCompositor2D::isFinalCompositionRequired ( ) const
inline

Tell if compositing final result is required.

bool kanzi::NodeCompositor2D::isSelfCompositionRequired ( ) const
inline

Tell if compositing self is required.

bool kanzi::NodeCompositor2D::isFinalCompositionRequested ( ) const
inline

Is compositing requested from code?

void kanzi::NodeCompositor2D::setFinalCompositionRequested ( bool  enabled)
inline

Set compositing request.

bool kanzi::NodeCompositor2D::isForceComposition ( ) const
inline

Is force composition on?

void kanzi::NodeCompositor2D::setForceComposition ( bool  enabled)
inline

Set force composition.

bool kanzi::NodeCompositor2D::isOffscreenRendering ( ) const
inline

Is offscreen rendering on?

void kanzi::NodeCompositor2D::setOffscreenRendering ( bool  enabled)
inline

Set offscreen rendering flag.

bool kanzi::NodeCompositor2D::isOpacityCompositionRequest ( ) const
inline

Is Opacity composition request flag on?

void kanzi::NodeCompositor2D::setOpacityCompositionRequested ( bool  enabled)
inline

Set opacity composition request flag.

void kanzi::NodeCompositor2D::resetManagedCompositionTargetCacheChildren ( )
inline

Reset cache children managed composition target.

void kanzi::NodeCompositor2D::resetManagedCompositionTargetCacheSelf ( )
inline

Reset cache self managed composition target.

void kanzi::NodeCompositor2D::resetManagedCompositionTargetFinal ( )
inline

Reset final managed composition target.

const Matrix4x4* kanzi::NodeCompositor2D::getPerspectiveTransform ( ) const
inline

Access perspective transform.

Returns
Perspective transform set, may be null if not set.
void kanzi::NodeCompositor2D::resetPerspectiveTransform ( )
inline

Reset perspective transform.

void kanzi::NodeCompositor2D::setPerspectiveTransform ( const Matrix4x4 transform)
inline

Set perspective transform.

Parameters
transformPerspective transform to use.
const Vector4* kanzi::NodeCompositor2D::getWorldPerspectiveOffset ( ) const
inline

Access world perspective transform.

Returns
Perspective transform set, may be null if not set.
void kanzi::NodeCompositor2D::resetWorldPerspectiveOffset ( )
inline

Reset world perspective transform.

void kanzi::NodeCompositor2D::setWorldPerspectiveOffset ( const Vector4 offset)
inline

Set world perspective transform.

Parameters
transformWorld perspective transform to use.

Member Data Documentation

ManagedCompositionTarget kanzi::NodeCompositor2D::m_finalCompositionTarget
protected

Managed composition target for complete node composition.

ManagedCompositionTarget kanzi::NodeCompositor2D::m_cacheChildrenCompositionTarget
protected

Managed composition target for caching children.

ManagedCompositionTarget kanzi::NodeCompositor2D::m_cacheSelfCompositionTarget
protected

Managed composition target for caching node contents.

BrushSharedPtr kanzi::NodeCompositor2D::m_userCompositionBrush
protected

User-set composition brush.

TextureSharedPtr kanzi::NodeCompositor2D::m_userCompositionTarget
protected

User-set composition target.

CompositionBrushSharedPtr kanzi::NodeCompositor2D::m_cacheChildrenBrush
protected

Brush used to render cached children.

BrushRendererPtr kanzi::NodeCompositor2D::m_cacheChildrenBrushRenderer
protected

Cache children brush renderer.

CompositionBrushSharedPtr kanzi::NodeCompositor2D::m_cacheSelfBrush
protected

Brush used to render cached node itself.

BrushRendererPtr kanzi::NodeCompositor2D::m_cacheSelfBrushRenderer
protected

Cache self brush renderer.

CompositionBrushSharedPtr kanzi::NodeCompositor2D::m_managedCompositionBrush
protected

Composition brush managed by node.

BrushRendererPtr kanzi::NodeCompositor2D::m_compositionBrushRenderer
protected

Composition brush renderer.

unique_ptr<PerspectiveTransformParameters> kanzi::NodeCompositor2D::m_perspective
protected

Perspective components.

bitset<ChildrenCompositingBitCount> kanzi::NodeCompositor2D::m_childrenComposeMask
protected

Bit mask for states affecting whether or not the node should compose its children.

bitset<FinalCompositingBitCount> kanzi::NodeCompositor2D::m_finalComposeMask
protected

Bit mask for states affecting whether or not the node should compose itself and its children.

bitset<SelfCompositingBitCount> kanzi::NodeCompositor2D::m_selfComposeMask
protected

Bit mask for states affecting whether or not the node should compose itself.


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