Skip to main content

LayerProperties

Struct LayerProperties 

Source
pub struct LayerProperties {
    pub display_rect: Option<RectU>,
    pub opacity: Option<f32>,
    pub blend_mode: Option<BlendMode2>,
    pub color: Option<ColorRgba>,
    pub sample_rect: Option<RectF>,
    pub transform: Option<FlipThenRotate>,
    pub hint_damage_rects: Option<Vec<RectU>>,
    pub hint_visible_rects: Option<Vec<RectU>>,
    pub composition_mode: Option<CompositionMode>,
    /* private fields */
}
Expand description

Stateful properties associated with a Layer.

All fields are sticky: [SetLayerProperties] merges the provided table into the layer’s stored properties, and stored values persist across [SetLayerImage] calls and across composition mode changes. Fields not used by the current composition mode keep their values, and take effect again when a mode that uses them is re-entered. Nothing is cleared implicitly; [ResetLayer] is the only operation that forgets stored properties.

Hints (Safety and Performance Semantics): Hints (such as [hint_damage_rects] and [hint_visible_rects]) are optional optimization details provided by the client.

  • Ignorable by Design: The implementation is free to ignore these hints. If ignored, rendering remains fully correct, though possibly less optimal.
  • Correct Hints: Yield the identical visual result but may improve performance (e.g., by allowing composition shortcuts or partial updates).
  • Incorrect Hints: May result in rendering artifacts, stale regions, or incorrect pixels on the display, as the implementation might optimize based on false assumptions.

Fields§

§display_rect: Option<RectU>

The rectangle where the layer content will be displayed in its local coordinate space.

For image layers, visual properties are applied in the following order:

  1. Sample: The region specified by sample_rect is extracted from the image.
  2. Transform: The sampled region is flipped and rotated as specified by transform.
  3. Scale/Fit: Transformed content is implicitly scaled to fit the display_rect.

Hardware image scaling is requested implicitly when the dimensions of the transformed sample_rect differ from the extent of the display_rect. Not all display hardware supports scaling, or may have limitations.

The dimensions of display_rect must account for image dimension changes caused by rotations to avoid implicit scaling or distortion. For example, rotating a 600x300 pixel region by 90 degrees would require specifying 300x600 dimensions here to maintain the aspect ratio.

Note: This rectangle is specified in the local space of the LayerStack (or the Transform the LayerStack is attached to). Any scaling applied by parent transforms in the Flatland scene graph will further affect the final size on the physical display.

Default: (0,0,0,0). The layer will not be visible until a rectangle with non-zero width and height is set.

§opacity: Option<f32>

The opacity of the layer, in the range [0..1].

Multiplies with opacity inherited from Transforms above the layer’s LayerStack (see [fuchsia.ui.composition/Flatland.SetOpacity]) to give the layer’s effective opacity. The layer renders as if its content’s own alpha (image pixels’ alpha, or color.alpha for a solid-color layer) were scaled by the effective opacity; since this requires blending, a REPLACE layer with effective opacity below 1.0 renders as PREMULTIPLIED_ALPHA (see [blend_mode]). A layer with effective opacity 0.0 is invisible.

Default: 1.0 (the content’s own alpha applies unmodified).

§blend_mode: Option<BlendMode2>

The blend mode used to composite the layer over the content beneath it.

REPLACE is honored only while the layer’s effective opacity is 1.0 (see [opacity]); at lower effective opacity the layer renders as PREMULTIPLIED_ALPHA, so that opacity always fades the layer. To write exact sub-unity alpha values into the output (e.g. punching a hole for an underlay), author them in the content itself (the image’s own pixels, or color.alpha for a solid-color layer) and leave opacity at 1.0.

STRAIGHT_ALPHA names a content encoding, and is meaningful for image content. A solid-color layer’s encoding is fixed by the API (color is straight RGBA regardless of blend_mode), so for solid-color content STRAIGHT_ALPHA is accepted and composites identically to PREMULTIPLIED_ALPHA.

Default: BlendMode2.REPLACE.

§color: Option<ColorRgba>

The color to fill the layer with, as straight (non-premultiplied) RGBA regardless of blend_mode. The compositor performs any conversion needed for rendering.

Default: opaque white (1.0, 1.0, 1.0, 1.0).

§sample_rect: Option<RectF>

Describes the region inside the image to sample from, in unnormalized coordinates (rect width/height match image width/height).

Default: (0,0,0,0), which is interpreted as the entire image region. A client can reset to the full image by setting this field to (0,0,0,0).

Must lie within the bounds of the bound image. This is checked during [fuchsia.ui.composition/Flatland.Present], and only for layers whose composition_mode is IMAGE, so the order of calls within a batch does not matter: a rect and an image of matching size may be set in either order, and a rect set while no image is bound (or while another mode is in effect) is stored without complaint. A violation at Present closes the connection with BAD_OPERATION.

§transform: Option<FlipThenRotate>

Specifies image transform.

Default: No transformation (identity).

§hint_damage_rects: Option<Vec<RectU>>

A hint describing the region of the source image that has changed since the last frame. Specified in the coordinate space of the source image (buffer).

Default: Empty vector (interpreted as the entire sample rect being damaged).

Refer to LayerProperties for the general safety and performance semantics of hints.

§hint_visible_rects: Option<Vec<RectU>>

A hint describing the visible region of the layer on the screen. Specified in the local coordinate space of the Layer (matching display_rect).

Default: Empty vector (interpreted as the entire display_rect being visible).

Refer to LayerProperties for the general safety and performance semantics of hints.

§composition_mode: Option<CompositionMode>

Selects which of the property groups above is in effect; see CompositionMode.

Default: CompositionMode.INVISIBLE.

Trait Implementations§

Source§

impl Clone for LayerProperties

Source§

fn clone(&self) -> LayerProperties

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LayerProperties

Source§

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

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

impl<D> Decode<LayerProperties, D> for LayerProperties
where D: ResourceDialect,

Source§

fn new_empty() -> LayerProperties

Creates a valid instance of Self. The specific value does not matter, since it will be overwritten by decode.
Source§

unsafe fn decode( &mut self, decoder: &mut Decoder<'_, D>, offset: usize, depth: Depth, ) -> Result<(), Error>

Decodes an object of type T from the decoder’s buffers into self. Read more
Source§

impl Default for LayerProperties

Source§

fn default() -> LayerProperties

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

impl<D> Encode<LayerProperties, D> for &LayerProperties
where D: ResourceDialect,

Source§

unsafe fn encode( self, encoder: &mut Encoder<'_, D>, offset: usize, depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl PartialEq for LayerProperties

Source§

fn eq(&self, other: &LayerProperties) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Persistable for LayerProperties

Source§

impl StructuralPartialEq for LayerProperties

Source§

impl TypeMarker for LayerProperties

Source§

type Owned = LayerProperties

The owned Rust type which this FIDL type decodes into.
Source§

fn inline_align(_context: Context) -> usize

Returns the minimum required alignment of the inline portion of the encoded object. It must be a (nonzero) power of two.
Source§

fn inline_size(_context: Context) -> usize

Returns the size of the inline portion of the encoded object, including padding for alignment. Must be a multiple of inline_align.
Source§

fn encode_is_copy() -> bool

Returns true if the memory layout of Self::Owned matches the FIDL wire format and encoding requires no validation. When true, we can optimize encoding arrays and vectors of Self::Owned to a single memcpy. Read more
Source§

fn decode_is_copy() -> bool

Returns true if the memory layout of Self::Owned matches the FIDL wire format and decoding requires no validation. When true, we can optimize decoding arrays and vectors of Self::Owned to a single memcpy.
Source§

impl ValueTypeMarker for LayerProperties

Source§

type Borrowed<'a> = &'a LayerProperties

The Rust type to use for encoding. This is a particular Encode<Self> type cheaply obtainable from &Self::Owned. There are three cases: Read more
Source§

fn borrow( value: &<LayerProperties as TypeMarker>::Owned, ) -> <LayerProperties as ValueTypeMarker>::Borrowed<'_>

Cheaply converts from &Self::Owned to Self::Borrowed.

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> Body for T
where T: Persistable,

Source§

type MarkerAtTopLevel = T

The marker type to use when the body is at the top-level.
Source§

type MarkerInResultUnion = T

The marker type to use when the body is nested in a result union.
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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<E> ErrorType for E

Source§

type Marker = E

The marker type.
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.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.