Skip to main content

LayerTree

Struct LayerTree 

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

Renderer-independent retained layer arena. Picture display lists are owned once and scene flattening only emits a transient linear command stream. This deliberately has no GPU resources or offscreen textures.

Implementations§

Source§

impl LayerTree

Source

pub fn new() -> Self

Source

pub fn diagnostics(&self) -> CompositorDiagnostics

Source

pub fn root(&self) -> Option<LayerId>

Source

pub fn layer(&self, id: LayerId) -> Option<(&LayerKind, &[LayerId])>

Read-only view of one layer’s kind and ordered children, for diagnostics and inspection tooling.

Source

pub fn set_root(&mut self, root: LayerId)

Source

pub fn scene_bounds(&self) -> Option<Rect>

Returns the retained scene’s conservative world-space visual bounds after compositor transforms, rectangular clipping, blur support, and drop-shadow support have been applied.

This is renderer-independent geometry. It is useful to embedders that need to size a native host around retained content without inspecting widget types or GPU commands.

Source

pub fn create_picture( &mut self, display_list: DisplayList, bounds: Rect, ) -> LayerId

Source

pub fn create_transform(&mut self, transform: Transform) -> LayerId

Source

pub fn create_clip_rect(&mut self, rect: Rect) -> LayerId

Source

pub fn create_clip_rrect(&mut self, rrect: RRect) -> LayerId

Creates a rounded-rectangle clip stage in local space; the world shape resolves at flatten time like Self::create_clip_rect.

Source

pub fn create_clip_oval(&mut self, rect: Rect) -> LayerId

Creates an oval clip stage in local space; the world shape resolves at flatten time like Self::create_clip_rect.

Source

pub fn create_clip_path( &mut self, path: Arc<Path>, fill_rule: FillRule, ) -> LayerId

Creates a path clip stage in local space; the world shape resolves at flatten time like Self::create_clip_rect.

Source

pub fn create_opacity(&mut self, alpha: f32) -> LayerId

Creates an isolated compositor group. Alpha is normalized at the renderer-neutral boundary so every backend observes identical values.

Source

pub fn create_blur(&mut self, blur: GaussianBlur) -> LayerId

Creates an isolated Gaussian-filtered compositor group.

Source

pub fn create_drop_shadow(&mut self, shadow: DropShadowEffect) -> LayerId

Creates an isolated arbitrary-subtree drop-shadow compositor group.

Source

pub fn create_color_filter(&mut self, filter: ColorFilter) -> LayerId

Creates an isolated color-matrix stage. Matrix changes are compositor updates and deliberately do not change the source generation.

Source

pub fn create_blend(&mut self, mode: BlendMode) -> LayerId

Creates a retained blend group whose source remains cached when only the discrete blend mode changes.

Source

pub fn create_shader_mask( &mut self, shader: Brush, blend_mode: BlendMode, mask_size: Size, mask_transform: Transform, ) -> LayerId

Creates an isolated shader-mask stage. The callback is evaluated by the retained widget during paint; this layer only owns the resolved, renderer-neutral shader description and its local coordinate space.

Source

pub fn create_backdrop_filter( &mut self, blur: GaussianBlur, blend_mode: BlendMode, enabled: bool, ) -> LayerId

Creates a backdrop-filter stage. Unlike Self::create_blur, this stage samples the already painted destination before its child is composited.

Source

pub fn update_backdrop_matrix( &mut self, id: LayerId, matrix: Option<Transform>, ) -> bool

Sets the matrix a backdrop-filter stage transforms its backdrop by (Flutter ImageFilter.matrix), or clears it for the blur.

Source

pub fn update_backdrop_key( &mut self, id: LayerId, key: Option<BackdropKey>, ) -> bool

Sets the backdrop a backdrop-filter stage shares with others (Flutter BackdropKey), or clears it.

Source

pub fn create_annotated_region( &mut self, annotation: Annotation, sized: bool, size: Size, ) -> LayerId

Source

pub fn create_leader(&mut self, link: LayerLink, size: Size) -> LayerId

Source

pub fn create_follower(&mut self, follower: FollowerLayer) -> LayerId

Source

pub fn remove(&mut self, id: LayerId)

Source

pub fn set_children(&mut self, id: LayerId, children: Vec<LayerId>)

Source

pub fn set_surface_partition( &mut self, id: LayerId, partition: Option<SurfacePartitionId>, )

Marks one retained layer subtree as detachable presentation content. The marker is renderer-neutral and does not alter layout, painting, or the retained layer topology.

Source

pub fn clear_surface_partitions(&mut self)

Clears every detachable-surface marker. WidgetTree reapplies markers for the currently visible transient portals before flattening each frame.

Source

pub fn update_picture( &mut self, id: LayerId, display_list: DisplayList, bounds: Rect, )

Source

pub fn update_picture_if_changed( &mut self, id: LayerId, display_list: &DisplayList, bounds: Rect, ) -> bool

Replaces a picture layer’s contents only when display_list or bounds differ from what it holds, copying the list in that case. A repaint that records the same picture keeps the retained one and its generation, so a caller can record into one reused buffer without allocating per layer. Returns whether the layer changed.

Source

pub fn update_transform(&mut self, id: LayerId, transform: Transform) -> bool

Source

pub fn update_clip(&mut self, id: LayerId, rect: Rect) -> bool

Source

pub fn update_clip_rrect(&mut self, id: LayerId, rrect: RRect) -> bool

Source

pub fn update_clip_oval(&mut self, id: LayerId, rect: Rect) -> bool

Source

pub fn update_clip_path( &mut self, id: LayerId, path: Arc<Path>, fill_rule: FillRule, ) -> bool

Source

pub fn update_opacity(&mut self, id: LayerId, alpha: f32) -> bool

Updates only the group alpha. This deliberately does not change the content generation, allowing a cached offscreen texture to be reused while an opacity animation is ticking.

Source

pub fn update_blur(&mut self, id: LayerId, blur: GaussianBlur) -> bool

Updates Gaussian parameters without changing the retained source generation. A backend recomputes only the filtered result.

Source

pub fn update_drop_shadow( &mut self, id: LayerId, shadow: DropShadowEffect, ) -> bool

Updates shadow presentation properties without changing source pixels. Sigma invalidates the filtered mask; offset/color remain composite-only in GPU backends.

Source

pub fn update_color_filter(&mut self, id: LayerId, filter: ColorFilter) -> bool

Source

pub fn update_blend(&mut self, id: LayerId, mode: BlendMode) -> bool

Source

pub fn update_shader_mask( &mut self, id: LayerId, shader: Brush, blend_mode: BlendMode, mask_size: Size, mask_transform: Transform, ) -> bool

Source

pub fn update_shader_mask_blend( &mut self, id: LayerId, blend_mode: BlendMode, ) -> bool

Source

pub fn update_backdrop_filter( &mut self, id: LayerId, blur: GaussianBlur, blend_mode: BlendMode, enabled: bool, ) -> bool

Source

pub fn update_annotated_region( &mut self, id: LayerId, annotation: Annotation, sized: bool, size: Size, ) -> bool

Source

pub fn update_leader( &mut self, id: LayerId, link: LayerLink, size: Size, ) -> bool

Source

pub fn update_leader_size(&mut self, id: LayerId, size: Size) -> bool

Source

pub fn update_follower(&mut self, id: LayerId, follower: FollowerLayer) -> bool

Source

pub fn flattened_pictures(&self) -> &[FlattenedPicture]

World-space logical bounds captured by the most recent Self::flatten call. This keeps coordinate diagnostics out of the renderer hot path.

Source

pub fn flattened_annotations(&self) -> &[FlattenedAnnotation]

Source

pub fn find_annotation<T: Any + Clone>(&self, point: Offset) -> Option<T>

Returns the front-most annotation of type T at point. Annotation lookup follows layer paint order, honours ancestor clips, and treats sized: false regions as covering the entire clipped subtree.

Source

pub fn find_annotations<T: Any + Clone>(&self, point: Offset) -> Vec<T>

Source

pub fn flatten(&mut self) -> DisplayList

Republishes leader links from current layer state for readers that run before flatten (notably semantic collection, which the frame runs pre-paint). Same pass flatten runs, so follower visibility reflects this frame’s layout instead of the previous paint; genuinely hidden leaders still stay unpublished. Idempotent.

Source

pub fn debug_tree(&self) -> String

Trait Implementations§

Source§

impl Default for LayerTree

Source§

fn default() -> Self

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

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: Real + Zero + Arithmetics + Clone, Swp: WhitePoint<T>, Dwp: WhitePoint<T>, D: AdaptFrom<S, Swp, Dwp, T>,

Source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<T>,

👎Deprecated since 0.7.7:

replaced by palette::chromatic_adaptation::AdaptIntoUnclamped

Convert the source color to the destination color using the specified method.
Source§

fn adapt_into(self) -> D

👎Deprecated since 0.7.7:

replaced by palette::chromatic_adaptation::AdaptIntoUnclamped

Convert the source color to the destination color using the bradford method by default.
Source§

impl<T, C> AdaptIntoUnclamped<T> for C
where T: AdaptFromUnclamped<C>,

Source§

type Scalar = <T as AdaptFromUnclamped<C>>::Scalar

The number type that’s used as the color’s components.
Source§

fn adapt_into_unclamped_with<M>(self) -> T

Adapt a color of type Self into a color of type T, using the custom matrix M. Read more
Source§

fn adapt_into_unclamped(self) -> T
where Bradford: LmsToXyz<Self::Scalar> + XyzToLms<Self::Scalar>,

Adapt a color of type Self into a color of type T, using the Bradford matrix. Read more
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, C> ArraysFrom<C> for T
where C: IntoArrays<T>,

Source§

fn arrays_from(colors: C) -> T

Cast a collection of colors into a collection of arrays.
Source§

impl<T, C> ArraysInto<C> for T
where C: FromArrays<T>,

Source§

fn arrays_into(self) -> C

Cast this collection of arrays into a collection of colors.
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<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for U
where T: FromCam16Unclamped<WpParam, U>,

Source§

type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<T, C> ComponentsFrom<C> for T
where C: IntoComponents<T>,

Source§

fn components_from(colors: C) -> T

Cast a collection of colors into a collection of color components.
Source§

impl<T, C> ComponentsInto<C> for T

Source§

fn components_into(self) -> C

Cast this collection of color components into a collection of colors. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromAngle<T> for T

Source§

fn from_angle(angle: T) -> T

Performs a conversion from angle.
Source§

impl<T, U> FromStimulus<U> for T
where U: IntoStimulus<T>,

Source§

fn from_stimulus(other: U) -> T

Converts other into Self, while performing the appropriate scaling, rounding and clamping.
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, U> IntoAngle<U> for T
where U: FromAngle<T>,

Source§

fn into_angle(self) -> U

Performs a conversion into T.
Source§

impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for U
where T: Cam16FromUnclamped<WpParam, U>,

Source§

type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<T, U> IntoColor<U> for T
where U: FromColor<T>,

Source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
Source§

impl<T, U> IntoColorUnclamped<U> for T
where U: FromColorUnclamped<T>,

Source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoStimulus<T> for T

Source§

fn into_stimulus(self) -> T

Converts self into T, while performing the appropriate scaling, rounding and clamping.
Source§

impl<T, C> TryComponentsInto<C> for T
where C: TryFromComponents<T>,

Source§

type Error = <C as TryFromComponents<T>>::Error

The error for when try_into_colors fails to cast.
Source§

fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>

Try to cast this collection of color components into a collection of colors. Read more
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, U> TryIntoColor<U> for T
where U: TryFromColor<T>,

Source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
Source§

impl<C, U> UintsFrom<C> for U
where C: IntoUints<U>,

Source§

fn uints_from(colors: C) -> U

Cast a collection of colors into a collection of unsigned integers.
Source§

impl<C, U> UintsInto<C> for U
where C: FromUints<U>,

Source§

fn uints_into(self) -> C

Cast this collection of unsigned integers into a collection of colors.