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.
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. An
arbitrary-path clip is deliberately not modelled yet — extend here (and
in frust-render::convert) if one is ever needed.
Fields
radii: CornerRadiiPer-corner radii, in the pre-transform coordinate space.
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.
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.
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
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.