Node effect renderer class. More...
#include <kanzi/core.ui/node/node_effect_renderer2d.hpp>
Classes | |
struct | EffectPass |
Effect pass configuration. More... | |
struct | EffectRenderState |
Render state configuration to use with an effect pass. More... | |
Public Member Functions | |
void | beginEffect (Renderer3D &renderer, CompositionStack &compositionStack, CompositionManager *compositionManager, const Matrix3x3 &worldTransform, Vector2 requiredSize, bool alphaRequired, bool depthRequired, bool stencilRequired) |
Begins the effect. More... | |
void | blitEffect (Renderer3D &renderer, CompositionStack &compositionStack, CompositionManager *compositionManager, QuadDescription &effectQuad, const Matrix3x3 &transform, const Matrix4x4 *perspectiveMatrix, const Matrix4x4 *projectionMatrix, int blendMode, bool needsClear) |
Blits the effect to the current framebuffer. More... | |
void | endEffect (Renderer3D &renderer, CompositionStack &compositionStack, CompositionManager *compositionManager) |
Ends the effect. More... | |
NodeEffect2DSharedPtr | getEffect () const |
Get NodeEffect2D instance where this renderer has been instantiated from. More... | |
size_t | getEffectPassCount () const |
Gets the number of effect passes. More... | |
void | restoreResources () |
Restores resources after the rendering context has been lost. More... | |
virtual | ~NodeEffectRenderer2D () |
Declare NodeEffectRenderer2D as not movable nor copyable. More... | |
Protected Types | |
using | EffectPassContainer = vector< EffectPass > |
Container for effect passes. More... | |
Protected Member Functions | |
EffectPass & | addEffectPass () |
Adds an effect pass and gets a reference to that pass. More... | |
virtual void | beginEffectOverride (Renderer3D &renderer, CompositionStack &compositionStack, CompositionManager *compositionManager, const Matrix3x3 &worldTransform, Vector2 requiredSize, bool alphaRequired, bool depthRequired, bool stencilRequired)=0 |
Begin effect. More... | |
void | beginInitialEffectPass (Renderer3D &renderer, CompositionStack &compositionStack, CompositionManager *compositionManager, bool alphaRequired, bool depthRequired, bool stencilRequired) |
Begins the initial effect pass (effect pass at index 0). More... | |
virtual void | blitEffectOverride (Renderer3D &renderer, CompositionStack &compositionStack, CompositionManager *compositionManager, QuadDescription &effectQuad, const Matrix3x3 &transform, const Matrix4x4 *perspectiveMatrix, const Matrix4x4 *projectionMatrix, int blendMode, bool needsClear)=0 |
Blit effect to current framebuffer. More... | |
void | blitFinalEffectPass (Renderer3D &renderer, CompositionStack &compositionStack, CompositionManager *compositionManager, QuadDescription &effectQuad, const Matrix3x3 &transform, const Matrix4x4 *perspectiveMatrix, const Matrix4x4 *projectionMatrix, int blendMode, bool needsClear) |
Blits the final effect pass, whose index is getEffectPassCount() - 1, and handles the perspective transform if necessary. More... | |
void | blitIntermediateEffectPass (int effectPassIndex, Renderer3D &renderer, CompositionStack &compositionStack, CompositionManager *compositionManager) |
Blits the intermediate effect pass. More... | |
void | clearRenderTarget (Renderer3D &renderer, CompositionStack &compositionStack, TextureSharedPtr texture, ColorRGBA clearColor) |
Clears the render target texture with a given color. More... | |
void | clearRenderTarget (Renderer3D &renderer, CompositionStack &compositionStack, NativeFramebufferHandle framebufferHandle, ColorRGBA clearColor) |
Clears the native framebuffer with a given color. More... | |
virtual void | endEffectOverride (Renderer3D &renderer, CompositionStack &compositionStack, CompositionManager *compositionManager)=0 |
End effect. More... | |
void | endInitialEffectPass (CompositionStack &compositionStack) |
Ends the initial effect pass, whose index is 0. More... | |
void | finalizeEffectPasses () |
Finalizes the effect passes. More... | |
Vector2 | getEffectInputTexelSize (int effectPassIndex, int inputIndex) |
Gets the texel size of the input effect pass texture in texture coordinates. More... | |
EffectPass & | getEffectPass (int index) |
Gets a reference to the effect pass at a given index. More... | |
int | getLastEffectPassIndex () const |
Gets the index of the last effect pass. More... | |
NodeEffectRenderer2D (NodeEffect2DSharedPtr nodeEffect) | |
Constructor. More... | |
void | releaseEffectPassInputRenderTargets (NodeEffectRenderer2D::EffectPass ¤tEffectPass, CompositionManager *compositionManager) |
Releases those temporary render targets used by input that have EffectPass::Input::releaseRenderTarget set to true. More... | |
void | removeAllEffectPasses () |
Removes all effect passes. More... | |
virtual void | restoreResourcesOverride ()=0 |
Restore resource after rendering context has been lost. More... | |
Node effect renderer class.
|
protected |
Container for effect passes.
|
virtual |
Declare NodeEffectRenderer2D as not movable nor copyable.
Destructor.
|
explicitprotected |
Constructor.
nodeEffect | NodeEffect2D instance associated with this renderer. |
NodeEffect2DSharedPtr kanzi::NodeEffectRenderer2D::getEffect | ( | ) | const |
Get NodeEffect2D instance where this renderer has been instantiated from.
void kanzi::NodeEffectRenderer2D::beginEffect | ( | Renderer3D & | renderer, |
CompositionStack & | compositionStack, | ||
CompositionManager * | compositionManager, | ||
const Matrix3x3 & | worldTransform, | ||
Vector2 | requiredSize, | ||
bool | alphaRequired, | ||
bool | depthRequired, | ||
bool | stencilRequired | ||
) |
Begins the effect.
Call this function before rendering the source content for the effect.
renderer | Renderer to use. |
compositionStack | CompositionStack to use. |
compositionManager | CompositionManager to use. |
worldTransform | 2D affine world transform used by the node. |
requiredSize | Required size of the source content to be used by the effect. |
alphaRequired | Whether the content requires alpha channel. |
depthRequired | Whether the content requires depth buffer. |
stencilRequired | Whether the content requires stencil buffer. |
void kanzi::NodeEffectRenderer2D::endEffect | ( | Renderer3D & | renderer, |
CompositionStack & | compositionStack, | ||
CompositionManager * | compositionManager | ||
) |
Ends the effect.
Call this function after rendering the source content for the effect.
renderer | Renderer to use. |
compositionStack | CompositionStack to use. |
compositionManager | CompositionManager to use. |
void kanzi::NodeEffectRenderer2D::blitEffect | ( | Renderer3D & | renderer, |
CompositionStack & | compositionStack, | ||
CompositionManager * | compositionManager, | ||
QuadDescription & | effectQuad, | ||
const Matrix3x3 & | transform, | ||
const Matrix4x4 * | perspectiveMatrix, | ||
const Matrix4x4 * | projectionMatrix, | ||
int | blendMode, | ||
bool | needsClear | ||
) |
Blits the effect to the current framebuffer.
Call this function after NodeEffectRenderer2D::endEffect when you want to blit the effect to screen. You can use this function to implement perspective projection, if you provide the relevant matrices.
renderer | Renderer to use. |
compositionStack | CompositionStack to use. |
compositionManager | CompositionManager to use. |
effectQuad | Potentially clipped effect quad honoring the NodeEffect2D::getEffectQuadPadding to use for rendering the effect. |
transform | 2D affine transform to use for rendering the effect quad. |
perspectiveMatrix | Optional perspective matrix to use. |
projectionMatrix | Optional projection matrix to use when rendering with perspective transform. |
blendMode | The blend mode to use for the effect blit. |
needsClear | Whether the current render target needs to be cleared before rendering. |
blendMode
parameter changed from GraphicsBlendMode to int. void kanzi::NodeEffectRenderer2D::restoreResources | ( | ) |
Restores resources after the rendering context has been lost.
size_t kanzi::NodeEffectRenderer2D::getEffectPassCount | ( | ) | const |
Gets the number of effect passes.
|
protectedpure virtual |
Begin effect.
Should be called before the source content for the effect is rendered.
renderer | Renderer to use. |
compositionStack | CompositionStack to use. |
compositionManager | CompositionManager to use. |
worldTransform | 2D affine world transform used by the node. |
requiredSize | Required size of the source content to be used by the effect. |
alphaRequired | Whether the content requires alpha channel. |
depthRequired | Whether the content requires depth buffer. |
stencilRequired | Whether the content requires stencil buffer. |
Implemented in kanzi::OutlineEffectRenderer2D.
|
protectedpure virtual |
End effect.
Should be called after the source content for the effect has been rendered.
renderer | Renderer to use. |
compositionStack | CompositionStack to use. |
compositionManager | CompositionManager to use. |
Implemented in kanzi::OutlineEffectRenderer2D.
|
protectedpure virtual |
Blit effect to current framebuffer.
Should after NodeEffectRenderer2D::endEffect when the effect should be blitted to screen. Can be used to implement perspective projection if relevant matrices are provided.
renderer | Renderer to use. |
compositionStack | CompositionStack to use. |
compositionManager | CompositionManager to use. |
effectQuad | Potentially clipped effect quad honoring the NodeEffect2D::getEffectQuadPadding to use for rendering the effect. |
transform | 2D affine transform to use for rendering the effect quad. |
perspectiveMatrix | Optional perspective matrix to use. |
projectionMatrix | Optional projection matrix to use when rendering with perspective transform. |
blendMode | The blend mode to use for the effect blit. |
needsClear | Whether the current render target needs to be cleared before rendering. |
blendMode
parameter changed from GraphicsBlendMode to int. Implemented in kanzi::OutlineEffectRenderer2D.
|
protectedpure virtual |
Restore resource after rendering context has been lost.
Implemented in kanzi::OutlineEffectRenderer2D.
|
protected |
Clears the render target texture with a given color.
renderer | Renderer3D to use. |
compositionStack | CompositionStack to use. |
texture | Render target texture to clear. |
clearColor | Color to use for the clear. |
|
protected |
Clears the native framebuffer with a given color.
renderer | Renderer3D to use. |
compositionStack | CompositionStack to use. |
framebufferHandle | Framebuffer handle to use. |
clearColor | Color to use for the clear. |
|
protected |
Adds an effect pass and gets a reference to that pass.
Adding an effect pass invalidates references to previously added effect passes. You must add at least two effect passes. The first pass renders the contents into a render target texture, and the last pass blits the effect result.
|
protected |
Gets the index of the last effect pass.
|
protected |
Gets a reference to the effect pass at a given index.
index | Index of the effect pass. |
|
protected |
Removes all effect passes.
|
protected |
Finalizes the effect passes.
Call this function after you have added and configured all effect passes. This function sets EffectPass::Input::releaseRenderTarget and in debug build checks whether all render pass outputs are in use.
|
protected |
Begins the initial effect pass (effect pass at index 0).
renderer | Renderer to use. |
compositionStack | CompositionStack to use. |
compositionManager | CompositionManager to use. |
alphaRequired | Whether the content requires alpha channel. |
depthRequired | Whether the content requires depth buffer. |
stencilRequired | Whether the content requires stencil buffer. |
|
protected |
Ends the initial effect pass, whose index is 0.
compositionStack | CompositionStack to use. |
|
protected |
Blits the intermediate effect pass.
If intermediate effect passes exist, blit them in order starting from index 1 to getEffectPassCount() - 2.
effectPassIndex | Index of the effect pass to use. |
renderer | Renderer to use. |
compositionStack | CompositionStack to use. |
compositionManager | CompositionManager to use. |
|
protected |
Blits the final effect pass, whose index is getEffectPassCount() - 1, and handles the perspective transform if necessary.
renderer | Renderer to use. |
compositionStack | CompositionStack to use. |
compositionManager | CompositionManager to use. |
effectQuad | Potentially clipped effect quad honoring the NodeEffect2D::getEffectQuadPadding to use for rendering the effect. |
transform | 2D affine transform to use for rendering the effect quad. |
perspectiveMatrix | Optional perspective matrix to use. |
projectionMatrix | Optional projection matrix to use when rendering with perspective transform. |
blendMode | The blend mode to use for the effect blit. |
needsClear | Whether the current render target needs to be cleared before rendering. |
blendMode
parameter changed from GraphicsBlendMode to int.
|
protected |
Gets the texel size of the input effect pass texture in texture coordinates.
You can call this function only after the source effect pass has obtained a valid render target.
effectPassIndex | Effect pass index. |
inputIndex | Input index. |
|
protected |
Releases those temporary render targets used by input that have EffectPass::Input::releaseRenderTarget set to true.
currentEffectPass | Reference to the effect pass whose referenced render targets to release if necessary. |
compositionManager | CompositionManager used to get the temporary render targets. |