Kanzi  3.9.4
Kanzi Engine API
kanzi::NodeVisual2D Class Reference

Data and functionality required for rendering Node2D visuals. More...

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

Public Member Functions

tuple< QuadDescription, unsigned int > calculateContentStretch (int contentStretch, Vector2 renderSize, Vector2 contentSize)
 Calculates foreground content stretch. More...
 
BrushRenderergetBackgroundBrushRenderer () const
 Gets background brush renderer. More...
 
const GeometrygetBackgroundGeometry () const
 Gets a pointer to the background geometry. More...
 
Vector2 getBackgroundTiling () const
 Gets background tiling from brush if present. More...
 
BrushRenderergetForegroundBrushRenderer () const
 Gets foreground brush renderer. More...
 
const GeometrygetForegroundGeometry () const
 Gets a pointer to the foreground geometry. More...
 
Vector2 getForegroundTiling () const
 Gets foreground tiling from brush if present. More...
 
bool isBackgroundGeometryValid () const
 Indicates whether background geometry is set and is valid. More...
 
bool isBackgroundOpaque () const
 Indicates whether background brush is present and is opaque. More...
 
bool isForegroundGeometryValid () const
 Indicates whether foreground geometry is set and is valid. More...
 
bool isForegroundOpaque () const
 Indicates whether foreground brush is present and is opaque. More...
 
void onDetached ()
 Kanzi calls this function when the node that owns the visual becomes detached. More...
 
void renderBackground (Renderer3D &renderer, const Geometry &geometry, const Matrix4x4 &transform)
 Renders using background brush. More...
 
void renderBackground (Renderer3D &renderer, const Geometry &geometry, const Matrix3x3 &transform)
 Render using background brush wrapper. More...
 
void renderBackground (Renderer3D &renderer, const Matrix4x4 &transform)
 Renders using background brush. More...
 
void renderBackground (Renderer3D &renderer, const Matrix3x3 &transform)
 Render using background brush wrapper. More...
 
void renderForeground (Renderer3D &renderer, const Matrix4x4 &transform)
 Renders using foreground brush. More...
 
void renderForeground (Renderer3D &renderer, const Matrix3x3 &transform)
 Renders using foreground brush wrapper. More...
 
void resetBackgroundBrush ()
 Resets background brush renderer. More...
 
void resetBackgroundGeometry ()
 Resets outside area quad. More...
 
void resetForegroundBrush ()
 Resets foreground brush renderer. More...
 
void resetForegroundGeometry ()
 Resets foreground geometry. More...
 
void restoreResources (Renderer &renderer)
 Restores resources to GPU, if applicable. More...
 
void setBackgroundBrush (Brush *brush, Node &node)
 Creates background brush renderer. More...
 
void setBackgroundGeometry (Domain *domain, const QuadDescription &quad)
 Creates a background quad. More...
 
void setBackgroundGeometry (Domain *domain, const FrameDescription &frame)
 Creates the outside area quad. More...
 
void setBackgroundGeometry (Domain *domain, const QuadDescription &bg, const QuadDescription &fg, unsigned int clippingResult)
 Creates the outside area quad. More...
 
void setForegroundBrushRenderer (Brush *brush, Node &node)
 Creates foreground brush renderer. More...
 
void setForegroundGeometry (Domain *domain, const QuadDescription &quad)
 Sets foreground quad with full data. More...
 
void storeRenderingParameters (optional< int > blendMode, float layoutOpacity, bool foregroundOpaquenessHint, bool foregroundTranslucencyHint)
 Stores rendering parameters for the brushes. More...
 
void updateBrushRenderers (bool selfInCompositionTarget)
 Updates brush renderers for rendering. More...
 
void updateContentTexture (TextureSharedPtr texture)
 Updates content texture in foreground brush renderer, if it exists. More...
 

Static Public Member Functions

static unique_ptr< NodeVisual2Dcreate ()
 Creates a NodeVisual2D. More...
 

Protected Member Functions

 NodeVisual2D ()=default
 Default constructor. More...
 

Protected Attributes

Brushm_backgroundBrush
 Brush for background. More...
 
BrushRendererPtr m_backgroundBrushRenderer
 Brush renderer for background. More...
 
GeometrySharedPtr m_backgroundGeometry
 Background geometry. More...
 
optional< int > m_blendMode
 Saved blend mode parameter. More...
 
bool m_brushRenderersDirty
 Brush renderer dirty flag. More...
 
Brushm_foregroundBrush
 Brush for foreground. More...
 
BrushRendererPtr m_foregroundBrushRenderer
 Brush renderer for foreground. More...
 
GeometrySharedPtr m_foregroundGeometry
 Foreground geometry. More...
 
bool m_foregroundOpaquenessHint
 Saved opaqueness hint. More...
 
bool m_foregroundTranslucencyHint
 Saved translucency hint. More...
 
bool m_geometryDirty
 Geometry dirty flag that implies the geometry has to be uploaded again. More...
 
float m_layoutOpacity
 Saved opacity parameter. More...
 
bool m_selfInCompositionTarget
 Flag that indicates whether the node is rendered to a composition target. More...
 

Detailed Description

Data and functionality required for rendering Node2D visuals.

Constructor & Destructor Documentation

◆ NodeVisual2D()

kanzi::NodeVisual2D::NodeVisual2D ( )
explicitprotecteddefault

Default constructor.

Member Function Documentation

◆ create()

static unique_ptr<NodeVisual2D> kanzi::NodeVisual2D::create ( )
static

Creates a NodeVisual2D.

Returns
NodeCompositor2D unique pointer.

◆ onDetached()

void kanzi::NodeVisual2D::onDetached ( )

Kanzi calls this function when the node that owns the visual becomes detached.

◆ calculateContentStretch()

tuple<QuadDescription, unsigned int> kanzi::NodeVisual2D::calculateContentStretch ( int  contentStretch,
Vector2  renderSize,
Vector2  contentSize 
)

Calculates foreground content stretch.

Parameters
contentStretchContent stretch mode of type Node2D::ContentStretch.
renderSizeRender size.
contentSizeContent size.
Returns
Tuple of foreground quad and clipping result mask.

◆ renderBackground() [1/4]

void kanzi::NodeVisual2D::renderBackground ( Renderer3D renderer,
const Geometry geometry,
const Matrix4x4 transform 
)

Renders using background brush.

Parameters
rendererRenderer to use.
geometryQuad to render.
transformTransform for the quad.

◆ renderBackground() [2/4]

void kanzi::NodeVisual2D::renderBackground ( Renderer3D renderer,
const Geometry geometry,
const Matrix3x3 transform 
)
inline

Render using background brush wrapper.

◆ renderBackground() [3/4]

void kanzi::NodeVisual2D::renderBackground ( Renderer3D renderer,
const Matrix4x4 transform 
)

Renders using background brush.

Uses background quad from visual.

Parameters
rendererRenderer to use.
transformTransform for the quad.

◆ renderBackground() [4/4]

void kanzi::NodeVisual2D::renderBackground ( Renderer3D renderer,
const Matrix3x3 transform 
)
inline

Render using background brush wrapper.

◆ renderForeground() [1/2]

void kanzi::NodeVisual2D::renderForeground ( Renderer3D renderer,
const Matrix4x4 transform 
)

Renders using foreground brush.

Parameters
rendererRenderer to use.
transformTransform for the quad.

◆ renderForeground() [2/2]

void kanzi::NodeVisual2D::renderForeground ( Renderer3D renderer,
const Matrix3x3 transform 
)
inline

Renders using foreground brush wrapper.

◆ restoreResources()

void kanzi::NodeVisual2D::restoreResources ( Renderer renderer)

Restores resources to GPU, if applicable.

Parameters
rendererRenderer to use.

◆ storeRenderingParameters()

void kanzi::NodeVisual2D::storeRenderingParameters ( optional< int >  blendMode,
float  layoutOpacity,
bool  foregroundOpaquenessHint,
bool  foregroundTranslucencyHint 
)

Stores rendering parameters for the brushes.

Kanzi calls this function during updateRender(). If the parameters differ, Kanzi marks the brush renderers dirty. Kanzi updates the brush renderers during rendering based on the composition status.

Parameters
blendModeBlend mode specified for the node. nullopt if the node is composited.
layoutOpacityLayout opacity of the node.
foregroundOpaquenessHintIf you want the node foreground to use opaque render mode if possible, pass true.
foregroundTranslucencyHintIf you want the node foreground to use translucent render mode if opaque render mode is not used, pass true.
Since
Kanzi 3.9.1 added blendMode parameter.

◆ updateBrushRenderers()

void kanzi::NodeVisual2D::updateBrushRenderers ( bool  selfInCompositionTarget)

Updates brush renderers for rendering.

If no settings have changed, this call is a NOP.

Parameters
selfInCompositionTargetWhether the node is rendered to a composition target.

◆ getBackgroundBrushRenderer()

BrushRenderer* kanzi::NodeVisual2D::getBackgroundBrushRenderer ( ) const
inline

Gets background brush renderer.

◆ setBackgroundBrush()

void kanzi::NodeVisual2D::setBackgroundBrush ( Brush brush,
Node node 
)
inline

Creates background brush renderer.

Parameters
nodeThe node to which to attach.
brushThe brush from which to create the renderer.
Since
Kanzi 3.9.1 data type of brush parameter changed from BrushSharedPtr to Brush*.

◆ resetBackgroundBrush()

void kanzi::NodeVisual2D::resetBackgroundBrush ( )
inline

Resets background brush renderer.

◆ getForegroundBrushRenderer()

BrushRenderer* kanzi::NodeVisual2D::getForegroundBrushRenderer ( ) const
inline

Gets foreground brush renderer.

◆ setForegroundBrushRenderer()

void kanzi::NodeVisual2D::setForegroundBrushRenderer ( Brush brush,
Node node 
)
inline

Creates foreground brush renderer.

Parameters
nodeThe node to which to attach.
brushThe brush from which to create the renderer.
Since
Kanzi 3.9.1 data type of brush parameter changed from BrushSharedPtr to Brush*.

◆ resetForegroundBrush()

void kanzi::NodeVisual2D::resetForegroundBrush ( )
inline

Resets foreground brush renderer.

◆ getForegroundGeometry()

const Geometry& kanzi::NodeVisual2D::getForegroundGeometry ( ) const
inline

Gets a pointer to the foreground geometry.

Call this function only if you know that foreground geometry is valid.

See also
isForegroundGeometryValid()
Returns
Pointer to valid foreground geometry or nullptr.

◆ isForegroundGeometryValid()

bool kanzi::NodeVisual2D::isForegroundGeometryValid ( ) const

Indicates whether foreground geometry is set and is valid.

Returns
If foreground geometry is set and valid, true, otherwise false.

◆ setForegroundGeometry()

void kanzi::NodeVisual2D::setForegroundGeometry ( Domain domain,
const QuadDescription quad 
)

Sets foreground quad with full data.

Parameters
domainDomain to use.
quadThe quad to set.

◆ resetForegroundGeometry()

void kanzi::NodeVisual2D::resetForegroundGeometry ( )

Resets foreground geometry.

◆ getBackgroundTiling()

Vector2 kanzi::NodeVisual2D::getBackgroundTiling ( ) const
inline

Gets background tiling from brush if present.

◆ getForegroundTiling()

Vector2 kanzi::NodeVisual2D::getForegroundTiling ( ) const
inline

Gets foreground tiling from brush if present.

◆ isBackgroundOpaque()

bool kanzi::NodeVisual2D::isBackgroundOpaque ( ) const
inline

Indicates whether background brush is present and is opaque.

◆ isForegroundOpaque()

bool kanzi::NodeVisual2D::isForegroundOpaque ( ) const
inline

Indicates whether foreground brush is present and is opaque.

◆ getBackgroundGeometry()

const Geometry& kanzi::NodeVisual2D::getBackgroundGeometry ( ) const
inline

Gets a pointer to the background geometry.

Call this function only if you know that background geometry is valid.

Returns
Pointer to valid background geometry or nullptr.
See also
isBackgroundGeometryValid()

◆ isBackgroundGeometryValid()

bool kanzi::NodeVisual2D::isBackgroundGeometryValid ( ) const

Indicates whether background geometry is set and is valid.

Returns
If background geometry is set and valid, true, otherwise false.

◆ setBackgroundGeometry() [1/3]

void kanzi::NodeVisual2D::setBackgroundGeometry ( Domain domain,
const QuadDescription quad 
)

Creates a background quad.

Parameters
domainDomain to use.
quadQuad description.

◆ setBackgroundGeometry() [2/3]

void kanzi::NodeVisual2D::setBackgroundGeometry ( Domain domain,
const FrameDescription frame 
)

Creates the outside area quad.

Creates a frame that does not include the foreground area.

Parameters
domainDomain to use.
frameThe frame description to use.

◆ setBackgroundGeometry() [3/3]

void kanzi::NodeVisual2D::setBackgroundGeometry ( Domain domain,
const QuadDescription bg,
const QuadDescription fg,
unsigned int  clippingResult 
)

Creates the outside area quad.

Creates a frame that does not include the foreground area.

Parameters
domainDomain to use.
bgWhole background area quad.
fgWhole foreground area quad.
clippingResultClipping result.

◆ resetBackgroundGeometry()

void kanzi::NodeVisual2D::resetBackgroundGeometry ( )

Resets outside area quad.

◆ updateContentTexture()

void kanzi::NodeVisual2D::updateContentTexture ( TextureSharedPtr  texture)
inline

Updates content texture in foreground brush renderer, if it exists.

Member Data Documentation

◆ m_backgroundGeometry

GeometrySharedPtr kanzi::NodeVisual2D::m_backgroundGeometry
protected

Background geometry.

◆ m_foregroundGeometry

GeometrySharedPtr kanzi::NodeVisual2D::m_foregroundGeometry
protected

Foreground geometry.

◆ m_geometryDirty

bool kanzi::NodeVisual2D::m_geometryDirty
protected

Geometry dirty flag that implies the geometry has to be uploaded again.

◆ m_backgroundBrush

Brush* kanzi::NodeVisual2D::m_backgroundBrush
protected

Brush for background.

Not owned by the visual.

Since
Kanzi 3.9.1 data type changed from BrushSharedPtr to Brush*.

◆ m_foregroundBrush

Brush* kanzi::NodeVisual2D::m_foregroundBrush
protected

Brush for foreground.

Not owned by the visual.

Since
Kanzi 3.9.1 data type changed from BrushSharedPtr to Brush*.

◆ m_backgroundBrushRenderer

BrushRendererPtr kanzi::NodeVisual2D::m_backgroundBrushRenderer
protected

Brush renderer for background.

◆ m_foregroundBrushRenderer

BrushRendererPtr kanzi::NodeVisual2D::m_foregroundBrushRenderer
protected

Brush renderer for foreground.

◆ m_blendMode

optional<int> kanzi::NodeVisual2D::m_blendMode
protected

Saved blend mode parameter.

Affects brush selection unless the node is composited.

Since
Kanzi 3.9.1

◆ m_layoutOpacity

float kanzi::NodeVisual2D::m_layoutOpacity
protected

Saved opacity parameter.

◆ m_foregroundOpaquenessHint

bool kanzi::NodeVisual2D::m_foregroundOpaquenessHint
protected

Saved opaqueness hint.

◆ m_foregroundTranslucencyHint

bool kanzi::NodeVisual2D::m_foregroundTranslucencyHint
protected

Saved translucency hint.

◆ m_selfInCompositionTarget

bool kanzi::NodeVisual2D::m_selfInCompositionTarget
protected

Flag that indicates whether the node is rendered to a composition target.

◆ m_brushRenderersDirty

bool kanzi::NodeVisual2D::m_brushRenderersDirty
protected

Brush renderer dirty flag.


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