Skip to main content

SceneBuilder

Struct SceneBuilder 

Source
pub struct SceneBuilder { /* private fields */ }
Expand description

Builds a Scene containing the given visuals.

A Scene can then be rendered using crate::View::present.

To draw graphical operations onto a Scene, first create a Canvas, record into it, and add the resulting Picture with add_picture. Each push_* opens a compositing scope that pop closes; unbalanced scopes are a bug the builder asserts on.

Implementations§

Source§

impl SceneBuilder

Source

pub fn new() -> SceneBuilder

Creates an empty SceneBuilder object.

Source

pub fn push_transform(&mut self, matrix4: &Matrix4)

Pushes a transform operation onto the operation stack.

The objects are transformed by the given matrix before rasterization.

Source

pub fn push_offset(&mut self, dx: f64, dy: f64)

Pushes an offset operation onto the operation stack.

This is equivalent to push_transform with a matrix with only translation.

Source

pub fn push_clip_rect(&mut self, rect: Rect, clip_behavior: Clip)

Pushes a rectangular clip operation onto the operation stack.

Rasterization outside the given rectangle is discarded.

Source

pub fn push_clip_rrect(&mut self, rrect: RRect, clip_behavior: Clip)

Pushes a rounded-rectangular clip operation onto the operation stack.

Rasterization outside the given rounded rectangle is discarded.

Source

pub fn push_clip_path(&mut self, path: &Arc<Path>, clip_behavior: Clip)

Pushes a path clip operation onto the operation stack.

Rasterization outside the given path is discarded.

Source

pub fn push_opacity(&mut self, alpha: i32, offset: Offset)

Pushes an opacity operation onto the operation stack.

The given alpha value is blended into the alpha value of the objects’ rasterization. An alpha value of 0 makes the objects entirely invisible. An alpha value of 255 has no effect (i.e., the objects retain the current opacity).

Source

pub fn push_backdrop_filter( &mut self, filter: &ImageFilter, blend_mode: BlendMode, backdrop_id: Option<u64>, )

Pushes a backdrop filter operation onto the operation stack.

The given filter is applied to the current contents of the scene as far back as the most recent save layer and rendered back to the scene using the indicated blend_mode prior to rasterizing the child layers.

Filters sharing a backdrop_id sample one backdrop, as Flutter’s BackdropKey groups them. valo’s backdrop is a blur: a colour filter in filter contributes nothing (see the host’s PORTING.md).

Source

pub fn pop(&mut self)

Ends the effect of the most recently pushed operation.

§Panics

In debug builds, if nothing is pushed.

Source

pub fn add_picture( &mut self, offset: Offset, picture: &Arc<Picture>, is_complex_hint: bool, will_change_hint: bool, )

Adds a Picture to the scene.

The picture is rasterized at the given offset. The hints are for a raster cache valo does not have; they are accepted so a layer can pass what Flutter passes.

Source

pub fn build(self) -> Scene

Finishes building the scene.

§Panics

In debug builds, if a pushed operation was not popped.

Trait Implementations§

Source§

impl Debug for SceneBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SceneBuilder

Source§

fn default() -> SceneBuilder

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,