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) -> SceneBuilder<'a>
pub fn new(scene: &'a mut Scene) -> SceneBuilder<'a>
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: AlphaColor<Srgb>,
)
pub fn draw_blurred_rounded_rect( &mut self, rect: Rect, radius: f64, std_dev: f64, color: AlphaColor<Srgb>, )
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: AlphaColor<Srgb>,
)
pub fn draw_blurred_rounded_rect_radii( &mut self, rect: Rect, radii: CornerRadii, std_dev: f64, color: AlphaColor<Srgb>, )
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.
Trait Implementations§
Source§impl PaintScene for SceneBuilder<'_>
Bridges the provisional PaintScene boundary onto the real
frust_scene::SceneBuilder.
impl PaintScene for SceneBuilder<'_>
Bridges the provisional PaintScene boundary onto the real
frust_scene::SceneBuilder.
Widgets paint through &mut dyn PaintScene; the desktop shell
hands them a SceneBuilder, so filled rectangles and shaped glyph runs land
in the display list under the builder’s current transform. Unshaped
PaintScene::draw_text is intentionally dropped here — text must be shaped
(by frust-text) into glyph runs before it can be drawn.
Source§fn fill_rect(&mut self, origin: Point, size: Size, color: AlphaColor<Srgb>)
fn fill_rect(&mut self, origin: Point, size: Size, color: AlphaColor<Srgb>)
origin with size, filled with
the solid color.Source§fn fill_rounded_rect(
&mut self,
origin: Point,
size: Size,
radius: f64,
color: AlphaColor<Srgb>,
)
fn fill_rounded_rect( &mut self, origin: Point, size: Size, radius: f64, color: AlphaColor<Srgb>, )
Source§fn fill_rounded_rect_radii(
&mut self,
origin: Point,
size: Size,
radii: CornerRadii,
color: AlphaColor<Srgb>,
)
fn fill_rounded_rect_radii( &mut self, origin: Point, size: Size, radii: CornerRadii, color: AlphaColor<Srgb>, )
radii — the
shape a uniform PaintScene::fill_rounded_rect cannot express (a
bottom-anchored sheet with only its top corners rounded, a segmented
control’s end caps). Read moreSource§fn stroke_line(
&mut self,
p0: Point,
p1: Point,
width: f64,
color: AlphaColor<Srgb>,
)
fn stroke_line( &mut self, p0: Point, p1: Point, width: f64, color: AlphaColor<Srgb>, )
Source§fn push_clip(&mut self, origin: Point, size: Size)
fn push_clip(&mut self, origin: Point, size: Size)
origin/size) onto the backend clip stack;
subsequent draws are clipped to it until the matching PaintScene::pop_clip. Read moreSource§fn push_clip_rounded(&mut self, origin: Point, size: Size, radius: f64)
fn push_clip_rounded(&mut self, origin: Point, size: Size, radius: f64)
origin/size, corner
radius) onto the backend clip stack; subsequent draws are clipped to
the rounded shape until the matching PaintScene::pop_clip — the same
pop PaintScene::push_clip uses, since there is one clip stack. Read moreSource§fn push_clip_rounded_radii(
&mut self,
origin: Point,
size: Size,
radii: CornerRadii,
)
fn push_clip_rounded_radii( &mut self, origin: Point, size: Size, radii: CornerRadii, )
radii onto the backend clip stack, popped
by the same PaintScene::pop_clip as every other push. Read moreSource§fn pop_clip(&mut self)
fn pop_clip(&mut self)
PaintScene::push_clip.Source§fn draw_text(&mut self, _origin: Point, _text: &str)
fn draw_text(&mut self, _origin: Point, _text: &str)
origin. Read moreSource§fn draw_glyph_run(&mut self, run: GlyphRun)
fn draw_glyph_run(&mut self, run: GlyphRun)
Source§fn draw_image(&mut self, data: &ImageData, dest: Rect)
fn draw_image(&mut self, data: &ImageData, dest: Rect)
data.widthxdata.height) size to fill the absolute dest rect. Read moreSource§fn draw_shader(&mut self, program: &ShaderProgram, dest: Rect, time: f32)
fn draw_shader(&mut self, program: &ShaderProgram, dest: Rect, time: f32)
dest. Read moreSource§fn draw_scene_texture(&mut self, id: u64, dest: Rect)
fn draw_scene_texture(&mut self, id: u64, dest: Rect)
ExternalPass)
into the scene. Read moreSource§fn draw_shadow(
&mut self,
origin: Point,
size: Size,
radius: f64,
std_dev: f64,
color: AlphaColor<Srgb>,
)
fn draw_shadow( &mut self, origin: Point, size: Size, radius: f64, std_dev: f64, color: AlphaColor<Srgb>, )
box-shadow) at origin/size. Read moreSource§fn fill_rect_brush(&mut self, origin: Point, size: Size, brush: &Brush)
fn fill_rect_brush(&mut self, origin: Point, size: Size, brush: &Brush)
origin with size, filled
with an arbitrary brush (solid color or gradient). Read moreSource§fn fill_rounded_rect_brush(
&mut self,
origin: Point,
size: Size,
radius: f64,
brush: &Brush,
)
fn fill_rounded_rect_brush( &mut self, origin: Point, size: Size, radius: f64, brush: &Brush, )
brush (solid color or gradient). Read moreSource§fn push_layer(&mut self, origin: Point, size: Size, alpha: f32)
fn push_layer(&mut self, origin: Point, size: Size, alpha: f32)
origin/size) onto the backend layer
stack; subsequent draws are composited at alpha until the matching
PaintScene::pop_layer. Read moreSource§fn pop_layer(&mut self)
fn pop_layer(&mut self)
PaintScene::push_layer.Source§fn clear_rect(&mut self, origin: Point, size: Size)
fn clear_rect(&mut self, origin: Point, size: Size)
origin/size) to full
transparency (alpha 0), erasing everything already painted below it in
this scene — a real destination-clearing composite, not merely skipping
paint over the region. Read moreSource§fn fill_path(&mut self, origin: Point, path: &BezPath, brush: &Brush)
fn fill_path(&mut self, origin: Point, path: &BezPath, brush: &Brush)
frust_scene::arc_path) at origin, using the nonzero winding
rule and brush. Read moreSource§fn stroke_path(
&mut self,
origin: Point,
path: &BezPath,
width: f64,
brush: &Brush,
)
fn stroke_path( &mut self, origin: Point, path: &BezPath, width: f64, brush: &Brush, )
origin with width
and round caps/joins, using brush. Read moreSource§fn stroke_path_dashed(
&mut self,
origin: Point,
path: &BezPath,
width: f64,
dash: DashPattern,
brush: &Brush,
)
fn stroke_path_dashed( &mut self, origin: Point, path: &BezPath, width: f64, dash: DashPattern, brush: &Brush, )
origin as a dashed line: the same
stroke PaintScene::stroke_path paints, broken into dash’s on/off
runs by the render crate at encode time. Read moreSource§fn push_transform(&mut self, transform: Affine)
fn push_transform(&mut self, transform: Affine)
transform, composed with the current one, onto the
backend transform stack; subsequent draws are transformed until the
matching PaintScene::pop_transform. Read moreSource§fn pop_transform(&mut self)
fn pop_transform(&mut self)
PaintScene::push_transform.Source§fn push_snapshot(
&mut self,
key: u64,
origin: Point,
size: Size,
alpha: f32,
scale: f64,
)
fn push_snapshot( &mut self, key: u64, origin: Point, size: Size, alpha: f32, scale: f64, )
key across frames. The alpha and scale are presentation parameters
applied to the whole cached body (alpha blending, uniform scale). Read moreSource§fn pop_snapshot(&mut self)
fn pop_snapshot(&mut self)
PaintScene::push_snapshot’s default: pop layer, then transform.
Recorders that don’t override both may see unbalanced stacks if only one
is overridden; the default pair is provided for source compatibility.Auto Trait Implementations§
impl<'a> !RefUnwindSafe for SceneBuilder<'a>
impl<'a> !UnwindSafe for SceneBuilder<'a>
impl<'a> Freeze for SceneBuilder<'a>
impl<'a> Send for SceneBuilder<'a>
impl<'a> Sync for SceneBuilder<'a>
impl<'a> Unpin for SceneBuilder<'a>
impl<'a> UnsafeUnpin for SceneBuilder<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.