pub trait Effect {
// Required methods
fn is_active(&self) -> bool;
fn activate(&mut self);
fn deactivate(&mut self);
fn tick(&mut self);
fn draw(&mut self, sink: &mut dyn EffectSink);
}Expand description
Lifecycle contract for a platform-level visual effect.
Boards (BSPs) drive effects through this trait: start one with
Effect::activate, advance per-frame state with Effect::tick,
describe the current frame with Effect::draw into an
EffectSink, and tear down with Effect::deactivate.
Effect::is_active gates whether the host needs to keep calling
tick / draw.
The trait is object-safe (no generics on any required method) so
hosts can polymorphism-dispatch over Box<dyn Effect> when they
want a pool of heterogeneous effects. The generic CPU convenience
EffectExt::paint lives on a supertrait to preserve that.
Required Methods§
Sourcefn is_active(&self) -> bool
fn is_active(&self) -> bool
Returns true while this effect is contributing work.
The effect is expected to drop to false of its own accord when
its animation cycle finishes (for example, a crawl scrolling
past its end). Hosts can also drive the flag down explicitly
via Effect::deactivate.
Sourcefn activate(&mut self)
fn activate(&mut self)
Prepare internal buffers and start a fresh animation cycle.
Re-activating an already-active effect resets it to the start of a new cycle.
Sourcefn deactivate(&mut self)
fn deactivate(&mut self)
Stop animating.
Subsequent Effect::tick calls are a no-op until
Effect::activate is called again.
Sourcefn tick(&mut self)
fn tick(&mut self)
Advance per-frame animation state by exactly one frame.
Hosts pace this from their frame clock (wall-clock or VSYNC) so that visible motion tracks the declared rate regardless of CPU load variations.
Sourcefn draw(&mut self, sink: &mut dyn EffectSink)
fn draw(&mut self, sink: &mut dyn EffectSink)
Emit the current frame’s render ops into sink.
The effect owns no framebuffer memory of its own. The sink owns
the destination surface (directly, in the case of
BlitterSink) or accumulates ops for later flushing (a
future Dma2dBatchSink).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".