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.

An unmatched restore is ignored in release builds and triggers a debug assertion.

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)

clip_rect applies a rectangular clip until the current scope ends.

Source

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.

Source

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

Source

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.

Source

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.

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

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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,