Skip to main content

DisplayListBuilder

Struct DisplayListBuilder 

Source
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

Source

pub fn new() -> Self

new creates an empty display-list builder.

Source

pub fn save(&mut self)

save preserves the current transform and clip until the matching restore.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn restore(&mut self)

restore closes the most recent save, layer, or mask scope.

A restore at the base level, with no save to close, is ignored, as Flutter’s DisplayListBuilder::Restore and Skia’s canvas ignore it: a framework that ends a picture between a save and its restore, as Flutter’s does when a child composites, restores on the next picture’s fresh canvas.

Source

pub fn translate(&mut self, tx: f32, ty: f32)

translate offsets subsequent drawing and clipping operations.

Source

pub fn scale(&mut self, sx: f32, sy: f32)

scale scales subsequent drawing and clipping operations.

Source

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.

Source

pub fn concat(&mut self, local: &Matrix)

concat appends a transform for subsequent drawing and clipping operations.

Source

pub fn clip_rect(&mut self, rect: impl Into<Rect>, op: ClipOp, anti_alias: bool)

clip_rect applies a rectangular clip until the current scope ends.

anti_alias says whether the clip’s edge is anti-aliased, as Skia’s and Flutter’s doAntiAlias. An Intersect clip that is not, under a transform that only scales and moves, cuts at the nearest whole pixels wherever the rectangle lies, and costs the renderer nothing: what a scroll view’s or a page’s clip wants. An anti-aliased one covers the pixels its edges cross in part.

Source

pub fn clip_rrect( &mut self, rect: impl Into<Rect>, radius: f32, op: ClipOp, anti_alias: bool, )

clip_rrect applies a rounded-rectangle clip with one corner radius.

anti_alias is recorded and, for now, changes nothing: a rounded rectangle’s edge is anti-aliased either way, as in Impeller.

Source

pub fn clip_rrect_radii( &mut self, rect: impl Into<Rect>, radii: [f32; 4], op: ClipOp, anti_alias: bool, )

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]. anti_alias is as Self::clip_rrect’s.

Source

pub fn clip_rrect_radii_elliptical( &mut self, rect: impl Into<Rect>, radii: [[f32; 2]; 4], op: ClipOp, anti_alias: bool, )

clip_rrect_radii_elliptical applies per-corner elliptical radii.

Each clockwise corner is [x_radius, y_radius], starting at the top-left. anti_alias is as Self::clip_rrect’s.

Source

pub fn clip_path( &mut self, path: &Arc<Path>, fill_rule: FillRule, op: ClipOp, anti_alias: bool, )

clip_path applies a path clip until the current scope ends.

anti_alias says whether the clip’s edge is anti-aliased. It changes what is drawn only for a path that is an axis-aligned rectangle, as Self::clip_rect says; any other shape’s edge is anti-aliased either way, for now, as in Impeller.

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.

Source

pub fn draw_paint(&mut self, paint: &Paint)

draw_paint fills the whole clip with paint, as Flutter’s Canvas.drawPaint: a background, a tint over everything drawn so far, or, with a blend such as crate::BlendMode::Clear or crate::BlendMode::Src, a change to every pixel the clip lets through, which a shape could not reach.

The paint always fills, and its mask blur is dropped, as Flutter’s display list records a paint for this draw; its colour, shader, filters and blend apply. Where no clip bounds it, the list’s bounds become unbounded, and a save layer around it covers its own clip.

Source

pub fn draw_shadow( &mut self, path: &Arc<Path>, fill_rule: FillRule, color: Color, elevation: f32, transparent_occluder: bool, device_pixel_ratio: f32, )

draw_shadow records the shadow an occluder of path’s shape, filled by fill_rule and painted color, casts from elevation logical pixels above the canvas, in a view whose device pixel ratio is device_pixel_ratio: Flutter’s Canvas.drawShadow, which material elevation draws.

The shadow is resolved when it is drawn, as Impeller resolves it: the path moves down by the occluder’s height, device_pixel_ratio × elevation device pixels, and fills with a toned, lighter color under a blur whose radius is that height over the vertical scale of the whole transform it is drawn under, scales of the lists and layers around it included. transparent_occluder is recorded and changes nothing drawn, as in Impeller. A shadow takes no group opacity, as in Flutter’s display list.

Source

pub fn draw_rect(&mut self, rect: impl Into<Rect>, paint: &Paint)

draw_rect records a filled or stroked rectangle.

Source

pub fn draw_path( &mut self, path: &Arc<Path>, fill_rule: FillRule, paint: &Paint, )

draw_path records a filled or stroked path.

Source

pub fn draw_circle( &mut self, center: impl Into<Point>, radius: f32, paint: &Paint, )

draw_circle records a filled or stroked circle.

Source

pub fn draw_rrect(&mut self, rect: impl Into<Rect>, radius: f32, paint: &Paint)

draw_rrect records a rounded rectangle with one corner radius.

Source

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].

Source

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.

Source

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.

Source

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.

Source

pub fn draw_glyph_run( &mut self, font: RunFont, paint: &Paint, glyphs: Arc<Vec<GlyphPos>>, text: Option<RunText>, local_bounds: Rect, )

draw_glyph_run records positioned glyphs drawn with font.

local_bounds must enclose the glyph ink in local coordinates, the font’s synthesis included. text is the text the glyphs show, which only a PDF reads back; None draws the same, its text just can’t be copied. Valo retains the supplied font and glyph positions in the display list.

Source

pub fn replay(&mut self, op: &Op)

replay records op again, as the call that recorded it: Flutter’s display list dispatching to a builder. Drawing a recorded part of a list on its own, such as a shadow an exporter draws as pixels, replays its ops between the transforms and clips around them.

Source

pub fn draw_display_list(&mut self, list: &Arc<DisplayList>)

draw_display_list records a nested display list by shared reference.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Default for DisplayListBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,