Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::canvas::SkslPostEffect Struct Reference

Arbitrary-SkSL view post-effect. More...

#include <view_effect.hpp>

Public Member Functions

void configure_layer (Canvas &canvas, float x, float y, float w, float h) override
 Push the compositing layer(s) this effect needs, configured with its opacity, image filters, blend mode, etc.
virtual int layer_count () const
 How many layers configure_layer() pushes.
virtual bool needs_layer () const
 Whether this effect requires a compositing layer (most do).
virtual void paint_overlay (Canvas &canvas, float x, float y, float w, float h)
 Paint an overlay on TOP of the already-painted subtree, but still INSIDE the effect's compositing layer(s) (called by View::paint_all just before the layers are popped).

Public Attributes

std::string sksl
float value = 0.0f
 bound to the shader's value uniform when present
float time = 0.0f
 bound to the shader's time uniform when present
std::vector< Canvas::NamedUniform > uniforms
 Arbitrary named uniforms (name → float/vec) the shader declares — the real user-facing surface.
Canvas::BlendMode blend_mode = Canvas::BlendMode::normal
 How the finished post-effect layer composites onto its parent.
float sample_radius = 0.0f
 Max neighbor-sampling distance (px) for content.eval offsets.

Detailed Description

Arbitrary-SkSL view post-effect.

Runs a child-shader over the finished subtree via Canvas::save_layer_with_sksl_post_effect; the SkSL must declare uniform shader content (sampled with content.eval(xy)). The JS bridge (setViewEffect) compiles/validates the source at install time and rejects a bad shader with its error, so a broken shader never installs silently. On non-Skia backends the compositor falls back to a plain layer.

Member Function Documentation

◆ configure_layer()

void pulp::canvas::SkslPostEffect::configure_layer ( Canvas & canvas,
float x,
float y,
float w,
float h )
inlineoverridevirtual

Push the compositing layer(s) this effect needs, configured with its opacity, image filters, blend mode, etc.

The subtree paints into the layer(s); the caller pops them once the subtree is done.

An implementation MUST push exactly layer_count() layers. The caller (View::paint_all) pops that many, so an effect that saves a different number than it reports unbalances the canvas save stack for the rest of the frame.

Implements pulp::canvas::ViewEffect.

◆ layer_count()

virtual int pulp::canvas::ViewEffect::layer_count ( ) const
inlinevirtualinherited

How many layers configure_layer() pushes.

One for a simple effect; EffectChain reports the sum across its children.

Reimplemented in pulp::canvas::EffectChain.

◆ needs_layer()

virtual bool pulp::canvas::ViewEffect::needs_layer ( ) const
inlinevirtualinherited

Whether this effect requires a compositing layer (most do).

Reimplemented in pulp::canvas::EffectChain.

◆ paint_overlay()

virtual void pulp::canvas::ViewEffect::paint_overlay ( Canvas & canvas,
float x,
float y,
float w,
float h )
inlinevirtualinherited

Paint an overlay on TOP of the already-painted subtree, but still INSIDE the effect's compositing layer(s) (called by View::paint_all just before the layers are popped).

This is how an effect that darkens or tints the finished content — a vignette drawing a radial gradient — is implemented, instead of the wrong "reduce the whole layer's opacity" approximation. Default: nothing.

Limitation: the overlay draws into the innermost still-open layer. That is correct for a single effect (the only non-chain path today), but in a multi-effect EffectChain (e.g. [vignette, blur]) an earlier effect's overlay lands in a later effect's layer and is filtered by it. See the View::paint_all call site — revisit if overlays-in-chains are needed.

Reimplemented in pulp::canvas::EffectChain, and pulp::canvas::VignetteEffect.

Member Data Documentation

◆ blend_mode

Canvas::BlendMode pulp::canvas::SkslPostEffect::blend_mode = Canvas::BlendMode::normal

How the finished post-effect layer composites onto its parent.

BlendMode::lighter = additive glow. Default source-over.

◆ sample_radius

float pulp::canvas::SkslPostEffect::sample_radius = 0.0f

Max neighbor-sampling distance (px) for content.eval offsets.

◆ sksl

std::string pulp::canvas::SkslPostEffect::sksl

◆ time

float pulp::canvas::SkslPostEffect::time = 0.0f

bound to the shader's time uniform when present

◆ uniforms

std::vector<Canvas::NamedUniform> pulp::canvas::SkslPostEffect::uniforms

Arbitrary named uniforms (name → float/vec) the shader declares — the real user-facing surface.

Bound guarded by findUniform.

◆ value

float pulp::canvas::SkslPostEffect::value = 0.0f

bound to the shader's value uniform when present


The documentation for this struct was generated from the following file:
  • /home/runner/work/pulp/pulp/core/canvas/include/pulp/canvas/view_effect.hpp