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:
- Sample: The region specified by
sample_rectis extracted from the image. - Transform: The sampled region is flipped and rotated as specified by
transform. - 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
impl Clone for LayerProperties
Source§fn clone(&self) -> LayerProperties
fn clone(&self) -> LayerProperties
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LayerProperties
impl Debug for LayerProperties
Source§impl<D> Decode<LayerProperties, D> for LayerPropertieswhere
D: ResourceDialect,
impl<D> Decode<LayerProperties, D> for LayerPropertieswhere
D: ResourceDialect,
Source§fn new_empty() -> LayerProperties
fn new_empty() -> LayerProperties
Self. The specific value does not matter,
since it will be overwritten by decode.Source§impl Default for LayerProperties
impl Default for LayerProperties
Source§fn default() -> LayerProperties
fn default() -> LayerProperties
Source§impl<D> Encode<LayerProperties, D> for &LayerPropertieswhere
D: ResourceDialect,
impl<D> Encode<LayerProperties, D> for &LayerPropertieswhere
D: ResourceDialect,
Source§impl PartialEq for LayerProperties
impl PartialEq for LayerProperties
impl Persistable for LayerProperties
impl StructuralPartialEq for LayerProperties
Source§impl TypeMarker for LayerProperties
impl TypeMarker for LayerProperties
Source§type Owned = LayerProperties
type Owned = LayerProperties
Source§fn inline_align(_context: Context) -> usize
fn inline_align(_context: Context) -> usize
Source§fn inline_size(_context: Context) -> usize
fn inline_size(_context: Context) -> usize
inline_align.Source§fn encode_is_copy() -> bool
fn encode_is_copy() -> bool
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 moreSource§fn decode_is_copy() -> bool
fn decode_is_copy() -> bool
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
impl ValueTypeMarker for LayerProperties
Source§type Borrowed<'a> = &'a LayerProperties
type Borrowed<'a> = &'a LayerProperties
Encode<Self>
type cheaply obtainable from &Self::Owned. There are three cases: Read moreSource§fn borrow(
value: &<LayerProperties as TypeMarker>::Owned,
) -> <LayerProperties as ValueTypeMarker>::Borrowed<'_>
fn borrow( value: &<LayerProperties as TypeMarker>::Owned, ) -> <LayerProperties as ValueTypeMarker>::Borrowed<'_>
&Self::Owned to Self::Borrowed.