pub enum Command {
Show 20 variants
FillRect {
rect: Rect,
brush: Brush,
transform: Affine,
},
RoundedRect {
rect: Rect,
radii: CornerRadii,
brush: Brush,
transform: Affine,
},
Line {
p0: Point,
p1: Point,
width: f64,
brush: Brush,
transform: Affine,
},
GlyphRun(GlyphRun),
PushClip {
rect: Rect,
transform: Affine,
},
PushClipRounded {
rect: Rect,
radii: CornerRadii,
transform: Affine,
},
PushClipPath {
path: BezPath,
transform: Affine,
},
PopClip,
Image {
data: ImageData,
dest: Rect,
transform: Affine,
},
BlurredRoundedRect {
rect: Rect,
radii: CornerRadii,
std_dev: f64,
color: AlphaColor<Srgb>,
transform: Affine,
},
PushLayer {
rect: Rect,
alpha: f32,
transform: Affine,
},
PopLayer,
ClearRect {
rect: Rect,
transform: Affine,
},
Path {
path: BezPath,
style: PathStyle,
brush: Brush,
transform: Affine,
},
ShaderQuad {
program: ShaderProgram,
dest: Rect,
transform: Affine,
time: f32,
},
PushRetained {
key: u64,
rect: Rect,
alpha: f32,
scale: f64,
transform: Affine,
},
PopRetained,
DrawRetained {
key: u64,
rect: Rect,
transform: Affine,
alpha: f32,
scale: f64,
},
SceneTexture {
id: u64,
dest: Rect,
transform: Affine,
},
BackdropBlur {
rect: Rect,
radius: f64,
transform: Affine,
},
}Expand description
A single paint operation recorded into a Scene.
This is the renderer-agnostic vocabulary the render crate (layer 4)
translates into backend draw calls. No vello/wgpu types appear here.
Variants§
FillRect
Fill an axis-aligned rectangle with a brush, under a transform.
RoundedRect
Fill an axis-aligned rectangle with rounded corners.
Fields
radii: CornerRadiiPer-corner radii, in the pre-transform coordinate space; a uniform
radius arrives here as CornerRadii::uniform.
Line
Stroke a straight line segment from p0 to p1.
Fields
GlyphRun(GlyphRun)
Draw a positioned run of glyphs.
PushClip
Push a rectangular clip onto the render backend’s clip stack, under a
transform. Subsequent draws are clipped to it until the matching
Command::PopClip.
PushClipRounded
Push a clip with rounded corners onto the render backend’s clip stack,
under a transform. Subsequent draws are clipped to the rounded shape
until the matching Command::PopClip.
Popped by the same Command::PopClip a Command::PushClip uses —
there is one clip stack, not a separate rounded one. The motivating
consumer is a radiused mask over a bitmap (an avatar/thumbnail), which a
rectangular clip cannot express.
Carried as a Rect + CornerRadii, mirroring
Command::RoundedRect rather than naming a kurbo::RoundedRect; the
render crate reconstitutes the concrete shape at encode time. A clip
to an arbitrary outline is Command::PushClipPath.
Fields
radii: CornerRadiiPer-corner radii, in the pre-transform coordinate space.
PushClipPath
Push a clip to an arbitrary closed outline onto the render backend’s
clip stack, under a transform. Subsequent draws are clipped to the
path’s interior (nonzero winding rule) until the matching
Command::PopClip.
Popped by the same Command::PopClip every other clip uses — one
clip stack. path is positioned in the same coordinate space as every
other command (the caller has translated it to the widget’s origin
before recording), exactly as Command::Path’s is; open subpaths are
closed implicitly, as a fill closes them.
Lowered as a coverage mask, no layer page: the outline is
rasterized once into coverage the draws inside it are generated
against, the way a rounded clip is — never an offscreen layer. Because
it is a mask, a retained body under it is never retained: a
Command::PushRetained bracket opened inside a path clip always
paints inline, as one inside a rounded clip does.
PopClip
Pop the most recently pushed clip, whichever of Command::PushClip,
Command::PushClipRounded or Command::PushClipPath pushed it.
Image
Draw a decoded image (natural pixel size data.widthxdata.height),
scaled to fill dest, under a transform.
data is cloned from the widget’s cached ImageSource each frame;
peniko::ImageData’s Blob<u8> is reference-counted internally, so
this is a cheap handle clone, never a pixel copy or re-decode.
BlurredRoundedRect
Draw a rounded rectangle with a gaussian-blurred elevation shadow (an
approximation of a CSS box-shadow), under a transform.
radii are the rectangle’s corner radii, std_dev the blur’s standard
deviation, both in the pre-transform coordinate space. Maps onto vello
0.9’s Scene::draw_blurred_rounded_rect, whose brush parameter is a
concrete peniko::Color (not a Brush) — a blurred shadow has no
gradient support in this vello version — and which takes a single
radius, as does the CPU tier’s fill_blurred_rounded_rect. A per-corner
shadow therefore lowers through CornerRadii::largest at encode time
(see frust-render::convert); the field carries all four corners so
this command shares one radii vocabulary with its rounded siblings and
gains per-corner blur for free if a backend ever grows it.
PushLayer
Push a translucent layer onto the render backend’s layer stack, under
a transform. Subsequent draws are composited at alpha until the
matching Command::PopLayer.
Semantically a generalization of Command::PushClip (which is
PushLayer with alpha: 1.0) — kept as a distinct variant rather than
folded into it so existing PushClip/PopClip consumers are
unaffected (see frust-render::convert).
PopLayer
Pop the most recently pushed layer.
ClearRect
Clear an axis-aligned rectangle to full transparency (alpha 0) under a transform, erasing everything already drawn beneath it in this scene — a real destination-clearing composite, not a skipped paint.
The platform-view hole-punch is the sole v1 producer (see
frust-core’s PaintScene::clear_rect): a translucent-surface (Mode B)
slot punches its rect so an opaque app backdrop painted below it (the
catalog’s AppBackground) doesn’t seal the hole the hosted native view
shows through. frust-render::convert lowers this to a destination-out
composite (an opaque fill erasing color and alpha wherever it covers),
hoisted to the scene root past any enclosing clip/opacity group so a
nested slot’s punch isn’t confined to its own group’s content — the
exact composite mode and hoist mechanics are frust-render’s to name
(scene-layer purity: no vello types here). The clear only becomes
visible on a surface that actually carries an alpha channel; on an
opaque surface the transparency is disregarded (vello’s surface
contract), which is why the producer gates it on the translucent flag
rather than punching always.
Path
Fill or stroke an arbitrary vector path (e.g. an arc), under a transform.
path is a kurbo::BezPath already positioned in the same
coordinate space as every other command (the caller has translated it
to the widget’s origin before recording); style selects fill vs.
stroke (see PathStyle).
ShaderQuad
Draw a fragment-shader-filled rectangle, scaled to fill dest, under
a transform.
program is compiled (and cache-keyed on ShaderProgram::id) by
frust-engine’s effects module. Output is treated as premultiplied
alpha. time is seconds, app-supplied (from PaintCtx::frame_time at
the widget layer), threaded into the shader’s uniform buffer. This
command lives at the scene layer to preserve purity: the render backend
interprets the compiled shader output.
PushRetained
Marks the start of a retained-layer bracket, under a transform.
The commands between this and the matching Command::PopRetained are
the BODY, recorded in the ordinary composed transform space (i.e. not
pre-multiplied by scale). rect is the body’s bounds in the local
space of transform — the same convention Command::PushLayer’s
rect/alpha/transform use.
alpha (0.0..=1.0) and scale (uniform, about rect’s center) are
PRESENTATION parameters applied to the body as a whole — deliberately
NOT baked into the body’s own commands, so a renderer can reuse a
rasterized body while they animate.
A renderer that retains MAY rasterize the body once under key and
later honour a Command::DrawRetained with the same key from that
page, drawing it with transform * scale_about(rect.center(), scale)
inside an alpha layer. A renderer that does not MUST paint the body
inline wrapped exactly as if the recorder had emitted
push_transform(scale_about(rect.center(), scale)) (when scale != 1.0) then push_layer(rect, alpha) (when alpha < 1.0) — pops
reversed (see frust-render::convert’s miss path).
Syntactic nesting is allowed, but only the OUTERMOST bracket needs
honouring — an inner bracket’s own alpha/scale may be ignored by a
non-implementing renderer. An unbalanced Command::PopRetained is
ignored, the same policy Command::PopLayer follows.
Fields
PopRetained
Pop the most recently pushed retained bracket (see
Command::PushRetained).
DrawRetained
Draw a previously retained body from its cached page, with the same
key, rect, transform, alpha and scale meanings as
Command::PushRetained.
A DrawRetained only appears in a scene when the resident-key ledger
said the key is resident, so a renderer that does not retain never sees
one: it MUST treat it as a renderer error (the CPU oracle panics in
tests; the engine logs once, skips the frame and clears its store).
SceneTexture
Draw an externally owned GPU texture scaled to fill dest under
transform.
id is opaque scene-layer data (precedent: ShaderProgram’s opaque
id, shader.rs) — only the render backend resolves it against
textures registered with the GPU context; an unregistered id draws
nothing.
BackdropBlur
Blur whatever is already painted beneath rect, under a transform —
a frosted-glass backdrop (CSS backdrop-filter: blur(radius)).
Everything the scene recorded before this command, in painter order,
is the backdrop: the pixels under rect are replaced by a Gaussian
blur of standard deviation radius (in the pre-transform coordinate
space, scaled into device space by transform the way a blurred
rounded rect’s std_dev is) of what was painted there, drawn through
any clip open around the command — a rounded or path clip masks the
blurred region exactly as it masks a fill. Commands recorded after
this one paint over the blurred region as usual. The blur reads
transparent black past the edge of the frame. A radius at or below
zero blurs nothing and draws nothing.
The backdrop is the frame’s own target: a backdrop blur recorded
inside an isolated (translucent) layer has no frame beneath it to
sample and draws nothing, and a Command::PushRetained body that
carries one is never retained — a page rasterized offscreen cannot
sample what is painted beneath it. A renderer bounds how many it serves
per frame (frust-engine refuses a frame recording more than four).
Implementations§
Source§impl Command
impl Command
Sourcepub fn is_drawing(&self) -> bool
pub fn is_drawing(&self) -> bool
Whether this command puts pixels on the target (a drawing command) rather than only opening or closing a group around other commands (a structural one).
Drawing: Command::FillRect, Command::RoundedRect,
Command::Line, Command::GlyphRun, Command::Image,
Command::BlurredRoundedRect, Command::ClearRect,
Command::Path, Command::ShaderQuad, Command::DrawRetained,
Command::SceneTexture and Command::BackdropBlur. Structural:
the clip pushes (Command::PushClip, Command::PushClipRounded,
Command::PushClipPath) and Command::PopClip, the layer bracket
(Command::PushLayer/Command::PopLayer) and the retained bracket
(Command::PushRetained/Command::PopRetained) — the same split
the render backend’s compile step applies implicitly (pushes open
groups, pops close them, everything else draws).
The platform-view differ uses it to decide whether a run of commands painted above a native slot carries any frust content worth an overlay. The match is exhaustive on purpose: a new variant must be classified here before it compiles.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Command
impl !UnwindSafe for Command
impl Freeze for Command
impl Send for Command
impl Sync for Command
impl Unpin for Command
impl UnsafeUnpin for Command
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.