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_* starts a container that pop builds into an EngineLayer;
unbalanced pushes are a bug the builder asserts on.
Implementations§
Source§impl SceneBuilder
impl SceneBuilder
Sourcepub fn new() -> SceneBuilder
pub fn new() -> SceneBuilder
Creates an empty SceneBuilder object.
Sourcepub fn push_transform(&mut self, matrix4: &Matrix4)
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.
Sourcepub fn push_offset(&mut self, dx: f64, dy: f64)
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.
Sourcepub fn push_clip_rect(&mut self, rect: Rect, clip_behavior: Clip)
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.
Sourcepub fn push_clip_rrect(&mut self, rrect: RRect, clip_behavior: Clip)
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.
Sourcepub fn push_clip_path(&mut self, path: &Arc<Path>, clip_behavior: Clip)
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.
Sourcepub fn push_opacity(&mut self, alpha: i32, offset: Offset)
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).
Sourcepub fn push_backdrop_filter(
&mut self,
filter: &ImageFilter,
blend_mode: BlendMode,
backdrop_id: Option<u64>,
)
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.
Sourcepub fn pop(&mut self) -> EngineLayer
pub fn pop(&mut self) -> EngineLayer
Ends the effect of the most recently pushed operation.
The container built is the EngineLayer returned, a child of the one beneath it: the
layer that pushed keeps it and hands it to add_retained while its
subtree stays unchanged. dart:ui returns the engine layer from the push; a container here
is built, and shared, at its pop.
§Panics
If nothing is pushed.
Sourcepub fn add_embedded_layer(
&mut self,
layer: Arc<dyn CompositionLayer>,
rect: Rect,
)
pub fn add_embedded_layer( &mut self, layer: Arc<dyn CompositionLayer>, rect: Rect, )
Places a composition layer the host composites, at rect in the coordinates of the
container being built: Flutter’s addPlatformView. It draws nothing; whoever composites
the scene makes room for it at its place in paint order.
Sourcepub fn add_video(&mut self, reader: Arc<dyn VideoFrameReader>, rect: Rect)
pub fn add_video(&mut self, reader: Arc<dyn VideoFrameReader>, rect: Rect)
Draws reader’s video into rect, in the coordinates of the container being built, at its
place in paint order: what Flutter’s addTexture does for a texture id. Whoever draws the
scene asks the reader for the frame then.
Sourcepub fn add_retained(&mut self, retained_layer: &EngineLayer)
pub fn add_retained(&mut self, retained_layer: &EngineLayer)
Adds a retained EngineLayer subtree from a previous frame.
All the engine layers that are in the subtree of the retained layer will be automatically appended to the current engine layer tree: the same node, in the container being built.
Sourcepub fn add_picture(
&mut self,
offset: Offset,
picture: &Arc<Picture>,
is_complex_hint: bool,
will_change_hint: bool,
)
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.