Skip to main content

Module effect

Module effect 

Source
Expand description

Platform-level visual effect primitives (Effect trait, CrawlParams struct). Platform-level effect primitives.

An Effect is a stateful, cooperative renderer that contributes pixels to a target Surface over one or more frames. Concrete effect implementations — star crawls, audio scopes, event overlays — live in higher-level crates. This module fixes the lifecycle contract a BSP needs to drive one (activate / tick / draw / deactivate), the EffectSink op vocabulary an effect emits its frame description through, and the shared parameter shape for scroll-style crawls.

§Why a sink, not a blitter

An earlier shape of this trait took paint<B: Blitter>(&mut self, blitter, dst). That binds the effect to a specific rendering path and makes it impossible to batch or reorder the per-frame work. Effect::draw instead takes &mut dyn EffectSink: the effect describes its frame as a sequence of ops (EffectSink::fill, EffectSink::blit, EffectSink::blend_a8_row) and the sink decides how to execute them. The shipped sink BlitterSink flushes each op synchronously through any Blitter (software CPU loops, DMA2D, WGPU); a future Dma2dBatchSink can accumulate ops and fuse adjacent fills into a single DMA2D transaction, or spread work across ERIF back porches. None of that leaks into the effect itself — this is the same command-list / backend split GStreamer uses for its graph execution.

The trait is object-safe (Effect::draw uses &mut dyn EffectSink), so hosts can store Box<dyn Effect> when they want polymorphism across effect flavours. For CPU callers who already hold a Blitter, the EffectExt::paint convenience wraps the blitter in a BlitterSink and calls draw in one shot.

See CrawlParams for the shared tuning knobs that any text-style crawl (Star Wars crawl, news ticker, credits roll) can consume.

Structs§

BlitterSink
Synchronous EffectSink that executes each op through a Blitter against a caller-supplied destination Surface.
CrawlParams
Common tuning parameters for a text-style scroll crawl.
SubSink
Offset + bounded wrapper around another EffectSink.

Traits§

Effect
Lifecycle contract for a platform-level visual effect.
EffectExt
CPU-convenience extension trait: bridge a Blitter into a throwaway BlitterSink and call Effect::draw in one step.
EffectSink
Render-op vocabulary an Effect emits into each frame.

Functions§

blend_a8_row_inline
CPU implementation of EffectSink::blend_a8_row.