Skip to main content

Command

Enum Command 

Source
pub enum Command {
Show 17 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, }, PopClip, Image { data: ImageData, dest: Rect, transform: Affine, }, BlurredRoundedRect { rect: Rect, radii: CornerRadii, std_dev: f64, color: Color, 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, }, PushSnapshot { key: u64, rect: Rect, alpha: f32, scale: f64, transform: Affine, }, PopSnapshot, SceneTexture { id: u64, dest: Rect, 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. An arbitrary-path clip is deliberately not modelled yet — extend here (and in frust-render::convert) if one is ever needed.

Fields

§rect: Rect
§radii: CornerRadii

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

§transform: Affine
§

PopClip

Pop the most recently pushed clip.

§

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
§color: Color
§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
§

PushSnapshot

Marks the start of a cacheable “snapshot” bracket, under a transform.

The commands between this and the matching Command::PopSnapshot 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 implements snapshots MAY rasterize the body once and draw it as an image 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::PopSnapshot is ignored, the same policy Command::PopLayer follows.

Fields

§key: u64

Cache key identifying this bracket’s body across frames.

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

Uniform scale, applied about rect’s center.

§transform: Affine
§

PopSnapshot

Pop the most recently pushed snapshot bracket (see Command::PushSnapshot).

§

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

Trait Implementations§

Source§

impl Clone for Command

Source§

fn clone(&self) -> Self

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

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<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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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