pub enum DrawCommand {
Show 14 variants
FillRect {
rect: Rect,
color: Color,
},
StrokeRect {
rect: Rect,
color: Color,
width: f32,
},
FillRRect {
rect: Rect,
radius: f32,
color: Color,
},
StrokeRRect {
rect: Rect,
radius: f32,
color: Color,
width: f32,
},
FillCircle {
center: Point,
radius: f32,
color: Color,
},
FillGradient {
rect: Rect,
radius: f32,
from: Color,
to: Color,
vertical: bool,
},
FillArc {
center: Point,
radius: f32,
thickness: f32,
start_deg: f32,
sweep_deg: f32,
color: Color,
},
DrawText {
text: String,
origin: Point,
color: Color,
px: f32,
weight: FontWeight,
},
DrawShadow {
rect: Rect,
radius: f32,
color: Color,
blur: f32,
},
BlitRgba {
pixels: Arc<Vec<u8>>,
src_width: u32,
src_height: u32,
dest_rect: Rect,
opacity: f32,
},
PushClip {
rect: Rect,
},
PopClip,
BackdropBlur {
rect: Rect,
radius: f32,
blur: f32,
tint: Color,
},
ShaderFill {
pipeline_id: u64,
rect: Rect,
uniforms: Vec<u8>,
animate_time: bool,
},
}Expand description
A single drawing instruction recorded during the paint pass.
Widgets push these into a [PictureRecorder] instead of writing pixels
directly. The compositor later replays them onto whatever backend is active
(currently [SkiaCanvas], eventually wgpu).
Variants§
FillRect
StrokeRect
FillRRect
Filled rounded rectangle — a single anti-aliased path.
StrokeRRect
Rounded rectangle outline — matches the FillRRect geometry so borders hug rounded fills instead of framing them with square corners.
FillCircle
FillGradient
Two-stop linear gradient fill of a (rounded) rect. vertical picks
the axis; radius rounds corners (0 = square).
FillArc
A ring segment: stroke of thickness thickness along the circle of
radius centered at center, from start_deg sweeping sweep_deg
clockwise (0° = 3 o’clock). Powers progress rings and spinners.
DrawText
DrawShadow
Gaussian-approximate drop shadow. radius rounds the shadow’s source
shape to match rounded widgets — a square shadow behind a rounded fill
leaks dark corner triangles.
BlitRgba
Raw pre-decoded RGBA pixel blit. pixels must be width × height × 4 bytes.
opacity (0.0-1.0) scales the blit’s alpha — D108/Phase 26 Step 4’s
image load-in fade; 1.0 is the previous, fully-opaque behavior.
PushClip
Push a clip rect — subsequent commands are confined to rect (intersected
with any already-active clip). Must be paired with DrawCommand::PopClip.
PopClip
Restore the clip rect that was active before the matching DrawCommand::PushClip.
BackdropBlur
Frosted-glass panel (D-DEF-012 backdrop blur): everything already
drawn beneath rect is blurred and tinted behind a rounded panel.
GPU-composited targets only; the CPU fallback renders a translucent
tint (no blur) — honest degradation, not silence. blur is the
Gaussian strength in logical px; tint’s alpha is the tint mix.
ShaderFill
Fill rect with a registered GPU shader pipeline (D109/Phase 27).
pipeline_id is the raw value of a rosace-shader PipelineId
(this Layer-4 crate cannot import the Layer-5 typed id). uniforms
are WGSL-uniform-layout bytes produced by #[derive(ShaderUniforms)]
— opaque here. This command has NO CPU rasterization path by design:
SkiaCanvas::play_picture collects it (see take_shader_quads) for
the compositor to execute on the GPU at present time.
animate_time (D109 maturity, 2026-07-18): when true, the platform
patches the first 4 uniform bytes with a live clock at every present
(the standard time-first uniform convention) — continuous shader
animation then costs one 16-byte GPU buffer write per frame instead
of a full CPU tree repaint. The widget records this command ONCE;
no per-frame repaint, no request_animation loop.
Implementations§
Source§impl DrawCommand
impl DrawCommand
Sourcepub fn offset(&self, dx: f32, dy: f32) -> Self
pub fn offset(&self, dx: f32, dy: f32) -> Self
Return a copy of this command translated by (dx, dy) in logical pixels (D088).
Sourcepub fn morph(
&self,
src_origin: Point,
dst_origin: Point,
sx: f32,
sy: f32,
) -> Self
pub fn morph( &self, src_origin: Point, dst_origin: Point, sx: f32, sy: f32, ) -> Self
Return a copy of this command remapped from a src-rect-relative
coordinate space to a dst one — translating AND scaling, unlike
Self::offset which only translates. Backs Hero/shared-element
transitions (D108/Phase 26 Step 5): a captured crate::Picture
recorded at a widget’s rect on one screen is replayed at a
different-sized rect on the other screen’s tag match, morphing
between the two. Non-rect geometry (circle/arc radius, stroke/blur
width, font size) has no independent x/y scale of its own, so it
scales uniformly by the average of sx/sy.
Trait Implementations§
Source§impl Clone for DrawCommand
impl Clone for DrawCommand
Source§fn clone(&self) -> DrawCommand
fn clone(&self) -> DrawCommand
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more