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

An opaque reference to a compositing layer owned by the canvas. More...

#include <canvas.hpp>

Public Member Functions

constexpr bool operator== (const LayerHandle &o) const
constexpr bool operator!= (const LayerHandle &o) const
constexpr operator bool () const

Public Attributes

uint64_t id = 0

Detailed Description

An opaque reference to a compositing layer owned by the canvas.

A HANDLE, not a scope. save_layer(...) / restore() is a statement PAIR: the layer exists only between the two calls and is composited exactly once, at the restore. That shape cannot express the thing a retained compositor actually needs — rendering a subtree into a texture ONCE and reusing that texture on later frames, or drawing it several times at different transforms. A handle can:

// Frame N and every frame after:
if (!canvas.layer_valid(cached_)) {          // survives across frames
    canvas.begin_layer(bounds, /*cacheable=*&zwj;/true);
    draw_expensive_contents(canvas);
    cached_ = canvas.end_layer();            // seals it
}
canvas.draw_layer(cached_, alpha);           // cheap, every frame
...
canvas.invalidate_layer(cached_);            // when contents change

id == 0 is the null handle, which every operation ignores.

Member Function Documentation

◆ operator bool()

pulp::canvas::Canvas::LayerHandle::operator bool ( ) const
inlineexplicitconstexpr

◆ operator!=()

bool pulp::canvas::Canvas::LayerHandle::operator!= ( const LayerHandle & o) const
inlineconstexpr

◆ operator==()

bool pulp::canvas::Canvas::LayerHandle::operator== ( const LayerHandle & o) const
inlineconstexpr

Member Data Documentation

◆ id

uint64_t pulp::canvas::Canvas::LayerHandle::id = 0

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