pub struct DisplayListBuilder { /* private fields */ }Expand description
DisplayListBuilder records drawing commands into an immutable display list.
Recording is GPU-free and may run on any thread. The builder resolves bounds, clips, layer extents, and ordering metadata so rendering does not need to rediscover them.
Implementations§
Source§impl DisplayListBuilder
impl DisplayListBuilder
Sourcepub fn save(&mut self)
pub fn save(&mut self)
save preserves the current transform and clip until the matching restore.
Sourcepub fn save_count(&self) -> usize
pub fn save_count(&self) -> usize
save_count returns the current canvas save-stack depth.
A new builder starts at one. Each save or save-layer operation
increments the count, and each matched restore decrements it. Hosts
can use the value to verify that callbacks leave shared canvas state balanced.
Sourcepub fn save_layer(&mut self, bounds_hint: Option<Rect>, paint: &Paint)
pub fn save_layer(&mut self, bounds_hint: Option<Rect>, paint: &Paint)
save_layer begins an offscreen layer composited with paint at restore.
bounds_hint is a local-space crop, not merely an allocation hint;
content outside it is discarded. Pass None to derive bounds from the
recorded children and active clip.
Sourcepub fn save_layer_mask(&mut self, bounds_hint: Option<Rect>, kind: MaskKind)
pub fn save_layer_mask(&mut self, bounds_hint: Option<Rect>, kind: MaskKind)
save_layer_mask begins a mask layer closed by restore.
The layer’s pixels become luminance or alpha coverage according to
kind, retaining enclosing content only where the mask has coverage.
bounds_hint crops the mask in local space.
Sourcepub fn save_layer_backdrop(
&mut self,
bounds_hint: Option<Rect>,
paint: &Paint,
backdrop: Backdrop,
)
pub fn save_layer_backdrop( &mut self, bounds_hint: Option<Rect>, paint: &Paint, backdrop: Backdrop, )
save_layer_backdrop begins a layer that OPENS pre-filled with the
Backdrop-filtered scene beneath it (frosted glass). Children
paint over that glass, and restore composites glass + children as
one image with paint — so a group alpha fades them together
(Flutter’s saveLayer(bounds, paint, backdrop)).
Without bounds_hint the layer covers the active clip — a backdrop
reads everything beneath it, so a hint-less, clip-less list records
unbounded bounds; hint the layer when the list will be embedded.
Sourcepub fn restore(&mut self)
pub fn restore(&mut self)
restore closes the most recent save, layer, or mask scope.
An unmatched restore is ignored in release builds and triggers a debug assertion.
Sourcepub fn translate(&mut self, tx: f32, ty: f32)
pub fn translate(&mut self, tx: f32, ty: f32)
translate offsets subsequent drawing and clipping operations.
Sourcepub fn scale(&mut self, sx: f32, sy: f32)
pub fn scale(&mut self, sx: f32, sy: f32)
scale scales subsequent drawing and clipping operations.
Sourcepub fn rotate(&mut self, radians: f32)
pub fn rotate(&mut self, radians: f32)
rotate rotates subsequent drawing and clipping operations clockwise.
Positive angles rotate clockwise in Valo’s y-down coordinate system.
Sourcepub fn concat(&mut self, local: &Matrix)
pub fn concat(&mut self, local: &Matrix)
concat appends a transform for subsequent drawing and clipping operations.
Sourcepub fn clip_rect(&mut self, rect: impl Into<Rect>, op: ClipOp)
pub fn clip_rect(&mut self, rect: impl Into<Rect>, op: ClipOp)
clip_rect applies a rectangular clip until the current scope ends.
Sourcepub fn clip_rrect(&mut self, rect: impl Into<Rect>, radius: f32, op: ClipOp)
pub fn clip_rrect(&mut self, rect: impl Into<Rect>, radius: f32, op: ClipOp)
clip_rrect applies a rounded-rectangle clip with one corner radius.
Sourcepub fn clip_rrect_radii(
&mut self,
rect: impl Into<Rect>,
radii: [f32; 4],
op: ClipOp,
)
pub fn clip_rrect_radii( &mut self, rect: impl Into<Rect>, radii: [f32; 4], op: ClipOp, )
clip_rrect_radii applies a rounded-rectangle clip with per-corner radii.
radii is ordered clockwise as [top-left, top-right, bottom-right, bottom-left].
Sourcepub fn clip_rrect_radii_elliptical(
&mut self,
rect: impl Into<Rect>,
radii: [[f32; 2]; 4],
op: ClipOp,
)
pub fn clip_rrect_radii_elliptical( &mut self, rect: impl Into<Rect>, radii: [[f32; 2]; 4], op: ClipOp, )
clip_rrect_radii_elliptical applies per-corner elliptical radii.
Each clockwise corner is [x_radius, y_radius], starting at the top-left.
Sourcepub fn clip_path(&mut self, path: &Arc<Path>, fill_rule: FillRule, op: ClipOp)
pub fn clip_path(&mut self, path: &Arc<Path>, fill_rule: FillRule, op: ClipOp)
clip_path applies a path clip until the current scope ends.
Clips do NOT forfeit an enclosing layer’s elision (Flutter’s opacity distribution ignores clips too): a depth clip records its own expiry slot and works identically whether the group’s children draw in a layer or in the parent, and child bounds are already clip-cropped when the disjointness check reads them. The Cupertino dialog depends on this — fade → clip → backdrop must keep the fade elidable or the glass snapshots a cleared offscreen.
Sourcepub fn draw_rect(&mut self, rect: impl Into<Rect>, paint: &Paint)
pub fn draw_rect(&mut self, rect: impl Into<Rect>, paint: &Paint)
draw_rect records a filled or stroked rectangle.
Sourcepub fn draw_path(
&mut self,
path: &Arc<Path>,
fill_rule: FillRule,
paint: &Paint,
)
pub fn draw_path( &mut self, path: &Arc<Path>, fill_rule: FillRule, paint: &Paint, )
draw_path records a filled or stroked path.
Sourcepub fn draw_circle(
&mut self,
center: impl Into<Point>,
radius: f32,
paint: &Paint,
)
pub fn draw_circle( &mut self, center: impl Into<Point>, radius: f32, paint: &Paint, )
draw_circle records a filled or stroked circle.
Sourcepub fn draw_rrect(&mut self, rect: impl Into<Rect>, radius: f32, paint: &Paint)
pub fn draw_rrect(&mut self, rect: impl Into<Rect>, radius: f32, paint: &Paint)
draw_rrect records a rounded rectangle with one corner radius.
Sourcepub fn draw_rrect_radii(
&mut self,
rect: impl Into<Rect>,
radii: [f32; 4],
paint: &Paint,
)
pub fn draw_rrect_radii( &mut self, rect: impl Into<Rect>, radii: [f32; 4], paint: &Paint, )
draw_rrect_radii records a rounded rectangle with per-corner radii.
radii is ordered clockwise as [top-left, top-right, bottom-right, bottom-left].
Sourcepub fn draw_rrect_radii_elliptical(
&mut self,
rect: impl Into<Rect>,
radii: [[f32; 2]; 4],
paint: &Paint,
)
pub fn draw_rrect_radii_elliptical( &mut self, rect: impl Into<Rect>, radii: [[f32; 2]; 4], paint: &Paint, )
draw_rrect_radii_elliptical records per-corner elliptical radii.
Each clockwise corner is [x_radius, y_radius], starting at the top-left.
Sourcepub fn draw_image(&mut self, image: &Image, dst: Rect, paint: &Paint)
pub fn draw_image(&mut self, image: &Image, dst: Rect, paint: &Paint)
draw_image records the whole image into dst.
It uses linear filtering and clamps at the image edges.
Sourcepub fn draw_image_rect(
&mut self,
image: &Image,
src: Rect,
dst: Rect,
sampling: Sampling,
paint: &Paint,
)
pub fn draw_image_rect( &mut self, image: &Image, src: Rect, dst: Rect, sampling: Sampling, paint: &Paint, )
draw_image_rect records a source region into dst with explicit sampling.
src is measured in source pixels. Tiling applies when src extends
beyond the image bounds.
Sourcepub fn draw_glyph_run(
&mut self,
font: Arc<Font>,
size: f32,
paint: &Paint,
glyphs: Arc<Vec<GlyphPos>>,
local_bounds: Rect,
)
pub fn draw_glyph_run( &mut self, font: Arc<Font>, size: f32, paint: &Paint, glyphs: Arc<Vec<GlyphPos>>, local_bounds: Rect, )
draw_glyph_run records positioned glyphs from one font and size.
local_bounds must enclose the glyph ink in local coordinates. Valo
retains the supplied font and glyph positions in the display list.
Sourcepub fn draw_display_list(&mut self, list: &Arc<DisplayList>)
pub fn draw_display_list(&mut self, list: &Arc<DisplayList>)
draw_display_list records a nested display list by shared reference.
Sourcepub fn draw_display_list_cached(&mut self, list: &Arc<DisplayList>)
pub fn draw_display_list_cached(&mut self, list: &Arc<DisplayList>)
draw_display_list_cached records a nested list as a raster-cache candidate.
Use it for stable, repeatedly drawn lists whose recording is expensive. The renderer may still replay the list directly when caching is unsuitable.
Sourcepub fn build(self) -> DisplayList
pub fn build(self) -> DisplayList
build consumes the builder and returns its immutable display list.
Any unmatched save scopes are closed before the list is finalized.