Skip to main content

Command

Enum Command 

Source
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.

Fields

§rect: Rect
§brush: Brush
§transform: Affine
§

RoundedRect

Fill an axis-aligned rectangle with rounded corners.

Fields

§rect: Rect
§radii: CornerRadii

Per-corner radii, in the pre-transform coordinate space; a uniform radius arrives here as CornerRadii::uniform.

§brush: Brush
§transform: Affine
§

Line

Stroke a straight line segment from p0 to p1.

Fields

§width: f64

Stroke width, in the pre-transform coordinate space.

§brush: Brush
§transform: Affine
§

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.

Fields

§rect: Rect
§transform: Affine
§

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

§rect: Rect
§radii: CornerRadii

Per-corner radii, in the pre-transform coordinate space.

§transform: Affine
§

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.

Fields

§path: BezPath
§transform: Affine
§

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.

Fields

§dest: Rect
§transform: Affine
§

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.

Fields

§rect: Rect
§std_dev: f64
§transform: Affine
§

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).

Fields

§rect: Rect
§alpha: f32
§transform: Affine
§

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.

Fields

§rect: Rect
§transform: Affine
§

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).

Fields

§path: BezPath
§brush: Brush
§transform: Affine
§

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.

Fields

§dest: Rect
§transform: Affine
§time: f32
§

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

§key: u64

Key identifying this bracket’s body across frames.

§rect: Rect
§alpha: f32
§scale: f64

Uniform scale, applied about rect’s center.

§transform: Affine
§

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).

Fields

§key: u64
§rect: Rect
§transform: Affine
§alpha: f32
§scale: f64
§

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.

Fields

§id: u64
§dest: Rect
§transform: Affine
§

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).

Fields

§rect: Rect
§radius: f64

The blur’s standard deviation, in the pre-transform coordinate space.

§transform: Affine

Implementations§

Source§

impl Command

Source

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§

Source§

impl Clone for Command

Source§

fn clone(&self) -> Command

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Command

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T> StorageAccess<T> for T

Source§

fn as_borrowed(&self) -> &T

Borrows the value.
Source§

fn into_taken(self) -> T

Takes the value.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more