pub struct SceneBuilder<'a> { /* private fields */ }Expand description
Records paint commands into a Scene, maintaining a transform stack.
Widgets call SceneBuilder::push_transform/SceneBuilder::pop_transform
around their subtree’s paint calls to compose local offsets/scales with the
ancestor transform, mirroring nested widget placement.
Implementations§
Source§impl<'a> SceneBuilder<'a>
impl<'a> SceneBuilder<'a>
Sourcepub fn new(scene: &'a mut Scene) -> Self
pub fn new(scene: &'a mut Scene) -> Self
Wraps scene for recording, starting with an identity transform.
The transform stack’s backing allocation lives on scene itself
so it’s reused across every call
instead of reallocating a fresh Vec per frame — reset here to
[Affine::IDENTITY], identical to a freshly allocated stack.
Sourcepub fn current_transform(&self) -> Affine
pub fn current_transform(&self) -> Affine
The transform currently in effect (composition of all pushed transforms).
Sourcepub fn push_transform(&mut self, transform: Affine)
pub fn push_transform(&mut self, transform: Affine)
Pushes a transform, composed with the current one, onto the stack.
Subsequent paint calls use the composed transform until the matching
SceneBuilder::pop_transform.
Sourcepub fn pop_transform(&mut self)
pub fn pop_transform(&mut self)
Pops the most recently pushed transform, restoring the previous one.
A no-op if called without a matching push_transform (the base identity
transform is never popped).
Sourcepub fn fill_rect(&mut self, rect: Rect, brush: Brush)
pub fn fill_rect(&mut self, rect: Rect, brush: Brush)
Records a filled rectangle under the current transform.
Sourcepub fn fill_rounded_rect(&mut self, rect: Rect, radius: f64, brush: Brush)
pub fn fill_rounded_rect(&mut self, rect: Rect, radius: f64, brush: Brush)
Records a filled rounded rectangle (uniform corner radius) under the
current transform.
The uniform-radius spelling of SceneBuilder::fill_rounded_rect_radii
— kept verbatim so every existing call site is unaffected by per-corner
radii.
Sourcepub fn fill_rounded_rect_radii(
&mut self,
rect: Rect,
radii: CornerRadii,
brush: Brush,
)
pub fn fill_rounded_rect_radii( &mut self, rect: Rect, radii: CornerRadii, brush: Brush, )
Records a filled rounded rectangle with per-corner radii under the
current transform.
Sourcepub fn stroke_line(&mut self, p0: Point, p1: Point, width: f64, brush: Brush)
pub fn stroke_line(&mut self, p0: Point, p1: Point, width: f64, brush: Brush)
Records a stroked line segment from p0 to p1 under the current
transform.
Sourcepub fn draw_glyph_run(&mut self, glyph_run: GlyphRun)
pub fn draw_glyph_run(&mut self, glyph_run: GlyphRun)
Records a glyph run, composing its own transform with the current one.
Sourcepub fn push_clip(&mut self, rect: Rect)
pub fn push_clip(&mut self, rect: Rect)
Pushes a rectangular clip onto the render backend’s clip stack, recording the current transform so the clip is applied in the same space as the draws it encloses.
Sourcepub fn push_clip_rounded(&mut self, rect: Rect, radius: f64)
pub fn push_clip_rounded(&mut self, rect: Rect, radius: f64)
Pushes a clip with uniformly rounded corners (radius, in the
pre-transform coordinate space) onto the render backend’s clip stack,
recording the current transform so the clip is applied in the same space
as the draws it encloses.
Popped by SceneBuilder::pop_clip — the same method that pops a
rectangular SceneBuilder::push_clip, since both share one clip stack
(see Command::PushClipRounded).
Sourcepub fn push_clip_rounded_radii(&mut self, rect: Rect, radii: CornerRadii)
pub fn push_clip_rounded_radii(&mut self, rect: Rect, radii: CornerRadii)
Pushes a clip with per-corner radii onto the render backend’s clip
stack, recording the current transform — the per-corner spelling of
SceneBuilder::push_clip_rounded, popped by the same
SceneBuilder::pop_clip.
Sourcepub fn draw_image(&mut self, data: &ImageData, dest: Rect)
pub fn draw_image(&mut self, data: &ImageData, dest: Rect)
Records a decoded image, scaled to fill dest, under the current
transform.
data is cloned into the command — cheap, since ImageData’s
Blob<u8> is reference-counted internally (see Command::Image).
Sourcepub fn draw_blurred_rounded_rect(
&mut self,
rect: Rect,
radius: f64,
std_dev: f64,
color: Color,
)
pub fn draw_blurred_rounded_rect( &mut self, rect: Rect, radius: f64, std_dev: f64, color: Color, )
Records a gaussian-blurred rounded-rectangle shadow (uniform corner
radius) under the current transform (see
Command::BlurredRoundedRect).
Sourcepub fn draw_blurred_rounded_rect_radii(
&mut self,
rect: Rect,
radii: CornerRadii,
std_dev: f64,
color: Color,
)
pub fn draw_blurred_rounded_rect_radii( &mut self, rect: Rect, radii: CornerRadii, std_dev: f64, color: Color, )
Records a gaussian-blurred rounded-rectangle shadow with per-corner
radii under the current transform.
Neither render tier has a per-corner blurred primitive, so a non-uniform
shadow lowers through CornerRadii::largest at encode time — see
Command::BlurredRoundedRect for why the largest corner and not the
smallest.
Sourcepub fn push_layer(&mut self, rect: Rect, alpha: f32)
pub fn push_layer(&mut self, rect: Rect, alpha: f32)
Pushes a translucent layer onto the render backend’s layer stack,
recording the current transform (see Command::PushLayer).
Sourcepub fn clear_rect(&mut self, rect: Rect)
pub fn clear_rect(&mut self, rect: Rect)
Records a rectangle cleared to full transparency (alpha 0) under the
current transform (see Command::ClearRect) — the platform-view
hole-punch. Unlike SceneBuilder::fill_rect with a transparent brush
(which composites transparent over the backdrop, a no-op), this erases
whatever was already drawn beneath the rect.
Sourcepub fn fill_path(&mut self, path: BezPath, brush: Brush)
pub fn fill_path(&mut self, path: BezPath, brush: Brush)
Records a filled arbitrary vector path (e.g. an arc) under the current transform, using the nonzero winding rule.
Sourcepub fn stroke_path(&mut self, path: BezPath, width: f64, brush: Brush)
pub fn stroke_path(&mut self, path: BezPath, width: f64, brush: Brush)
Records a stroked arbitrary vector path (e.g. an arc), with round caps/joins, under the current transform.
Sourcepub fn stroke_path_dashed(
&mut self,
path: BezPath,
width: f64,
dash: DashPattern,
brush: Brush,
)
pub fn stroke_path_dashed( &mut self, path: BezPath, width: f64, dash: DashPattern, brush: Brush, )
Records a dashed stroked path under the current transform: the same
stroke SceneBuilder::stroke_path records, carrying a DashPattern
the render crate expands into dash segments at encode time.
Sourcepub fn push_snapshot(&mut self, key: u64, rect: Rect, alpha: f32, scale: f64)
pub fn push_snapshot(&mut self, key: u64, rect: Rect, alpha: f32, scale: f64)
Pushes a snapshot bracket, recording the current transform (see
Command::PushSnapshot) and incrementing the scene’s snapshot
depth so the matching SceneBuilder::pop_snapshot knows a bracket
is open. key identifies the body’s cache entry across frames;
rect/alpha/scale are the presentation parameters a renderer may
apply on top of the body as a whole.
Sourcepub fn pop_snapshot(&mut self)
pub fn pop_snapshot(&mut self)
Pops the most recently pushed snapshot bracket. A no-op — matching
Command::PopClip/Command::PopLayer’s unbalanced-pop policy —
when no bracket is open.
Sourcepub fn draw_shader(&mut self, program: &ShaderProgram, dest: Rect, time: f32)
pub fn draw_shader(&mut self, program: &ShaderProgram, dest: Rect, time: f32)
Records a fragment-shader-filled rectangle, scaled to fill dest,
under the current transform (see Command::ShaderQuad).
The engine renders the fragment program in a pre-pass into an offscreen
target and draws it over dest. Output is treated as premultiplied
alpha. The rendering is disabled by FRUST_ENGINE_NO_SHADER_EFFECTS.
program is cloned into the command — cheap, since ShaderProgram
clones its id and its Arc<str> source handle, never the source
text. time is seconds, app-supplied.
Sourcepub fn scene_texture(&mut self, id: u64, dest: Rect)
pub fn scene_texture(&mut self, id: u64, dest: Rect)
Records an externally owned GPU texture, scaled to fill dest, under
the current transform (see Command::SceneTexture).
id is opaque scene-layer data — only the render backend resolves it
against textures registered with the GPU context; an unregistered id
draws nothing.