Skip to main content

Layer

Struct Layer 

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

One layer the scene wants on screen.

A layer is a property bag plus the flags the allocator consults when deciding whether — and where — to place it.

The flags stay separate bools rather than a bitfield: they are set and read independently by different owners — the caller, the scene, and the allocator — and the C++ keeps them separate for the same reason. Packing them would save a few bytes on a type allocated a handful of times per frame and cost the ability to name each one.

Implementations§

Source§

impl Layer

Source

pub const fn new() -> Self

A layer with no properties set.

Source

pub fn set_property(&mut self, tag: PropTag, value: u64) -> &mut Self

Set a property. The hot path — no string lookup.

Writing a property’s existing value is a no-op: the layer is not marked dirty and the memoized hash is not invalidated. That is not just tidiness — the steady-state path rewrites the same geometry every frame, so invalidating on a no-op would recompute the hash each time and defeat the memoization the FB-only fast path leans on.

Source

pub fn set_property_by_name(&mut self, name: &str, value: u64) -> bool

Set a property by canonical KMS name.

Returns false, and sets nothing, for an unrecognized name, rather than silently ignoring it as the C++ does: the kernel would reject it anyway, and a caller that mistyped a name wants to know.

Source

pub const fn property(&self, tag: PropTag) -> Option<u64>

The value of a property, if set.

Source

pub fn property_by_name(&self, name: &str) -> Option<u64>

The value of a property by canonical KMS name, if set.

Source

pub fn properties(&self) -> impl Iterator<Item = (PropTag, u64)> + '_

Every set property, in tag order.

Source

pub const fn property_count(&self) -> u32

How many properties are set.

Source

pub const fn snapshot(&self) -> PropertySnapshot

Snapshot the property state for diffing.

Source

pub fn disable(&mut self) -> &mut Self

Disable the layer by detaching its framebuffer.

Sets FB_ID to 0 and leaves everything else alone. Geometry, format, and stacking stay put, which is what lets a re-enabled layer keep its placement — and, because FB_ID is a content property, what keeps a disable from moving property_hash.

Source

pub fn property_hash(&self) -> u64

Order-independent hash of the layer’s placement properties.

§Invariant 4 (corollary)

This is what isolates content from placement. Every PropClass::Placement property moves the hash; every PropClass::Content property is skipped, because it changes each frame and says nothing about whether the plane can scan the buffer out.

A frame whose hash is unchanged has only new content on already-placed layers, so the allocator reuses the cached assignment and skips the redundant TEST_ONLY. Misclassifying a placement property as content would let a real geometry change skip validation — which is why the classification lives in PropTag::class’s exhaustive match rather than in an if here.

Memoized; invalidated whenever a property value changes.

Source

pub fn set_force_composited(&mut self, composited: bool) -> &mut Self

Force this layer through composition rather than a plane.

Source

pub const fn is_force_composited(&self) -> bool

Whether the caller pinned this layer to composition.

Source

pub fn set_transient_composited(&mut self, composited: bool) -> &mut Self

Set the per-commit composition flag.

The allocator treats this exactly like set_force_composited, but the scene sets and clears it per commit rather than at layer creation. It lets scene-level constraints — an EGL Streams Exclusive mixing mode forcing FB-backed layers through composition when a stream layer shares the CRTC — coexist with a caller’s own choice without conflating the two. Nothing in this tree’s scene sets it yet: the streams tier it exists for is not ported.

Source

pub const fn is_transient_composited(&self) -> bool

Whether the scene set the per-commit composition flag.

Source

pub const fn needs_composition(&self) -> bool

Whether the caller or the scene has sent this layer to composition.

Upstream’s allocator also sets this on every layer it could not place. Here the allocator holds layers by shared reference and reports that verdict in Allocation::composited instead, which covers these layers too.

Source

pub fn set_composition_layer(&mut self, is_composition: bool) -> &mut Self

Mark this layer as the output of the composition pass itself.

Source

pub const fn is_composition_layer(&self) -> bool

Whether this layer is the composition pass’s own output.

Source

pub const fn is_externally_bound(&self) -> bool

Whether the scene pinned this layer to a plane whose binding a driver owns.

The allocator must skip such a layer during assignment, scoring, and test commits. EGL stream sources establish their plane state out of band, so an allocator test commit would reject a stream-bound plane for lacking the kernel-internal FB_ID those extensions set up.

Source

pub fn set_externally_bound(&mut self, externally_bound: bool) -> &mut Self

Mark this layer as driver-bound. Set by the scene when a source reports DriverOwnsBinding.

Source

pub const fn is_pinned(&self) -> bool

Whether the scene pinned this layer to a caller-chosen plane.

Like is_externally_bound, the allocator skips it. Unlike that flag, the layer keeps its FB_ID in the property bag — it is a normal source, not a driver-owned one — so this must not gate the FB_ID write.

Source

pub fn set_pinned(&mut self, pinned: bool) -> &mut Self

Mark this layer as pinned to a specific plane.

Source

pub const fn assigned_plane(&self) -> Option<u32>

The plane a pinned layer holds, as the scene recorded it.

Upstream’s allocator records its placements here too; this one reports them in Allocation::assignment.

Source

pub fn set_assigned_plane(&mut self, plane_id: Option<u32>) -> &mut Self

Record the plane a pinned layer holds.

Source

pub const fn content_type(&self) -> ContentType

What this layer is showing.

Source

pub fn set_content_type(&mut self, content_type: ContentType) -> &mut Self

Set what this layer is showing.

Source

pub const fn update_hz(&self) -> u32

The layer’s expected update rate in Hz, or 0 if unknown.

Source

pub fn set_update_hint(&mut self, hz: u32) -> &mut Self

Set the expected update rate.

Source

pub const fn app_priority(&self) -> u8

Application-level placement priority within a content class.

Source

pub fn set_app_priority(&mut self, priority: u8) -> &mut Self

Set the application-level placement priority.

Source

pub const fn is_dirty(&self) -> bool

Whether the layer changed since the last mark_clean.

Source

pub const fn mark_clean(&mut self)

Clear the dirty flag.

Source

pub const fn format(&self) -> Option<u32>

The FourCC, if set.

The narrowing casts in this block are the KMS ABI’s shape: CRTC_*, pixel_format, and the integer part of a 16.16 SRC_* are all 32-bit fields carried in the property bag’s u64 slots. A value too wide to fit came from a caller writing something the kernel would reject.

Source

pub const fn modifier(&self) -> u64

The layout modifier, defaulting to LINEAR’s zero when unset.

Source

pub const fn rotation(&self) -> u64

The rotate/reflect bitmask, or 0.

Source

pub const fn width(&self) -> u32

Destination width in pixels.

Source

pub const fn height(&self) -> u32

Destination height in pixels.

Source

pub const fn crtc_rect(&self) -> Rect

The destination rectangle.

Source

pub const fn requires_scaling(&self) -> bool

Whether the plane would have to scale.

SRC_* are 16.16 fixed point; CRTC_* are whole pixels. A layer missing any of the four is treated as unscaled, matching the C++.

Trait Implementations§

Source§

impl Clone for Layer

Source§

fn clone(&self) -> Self

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 Layer

Source§

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

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

impl Default for Layer

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl !Freeze for Layer

§

impl !RefUnwindSafe for Layer

§

impl !Sync for Layer

§

impl Send for Layer

§

impl Unpin for Layer

§

impl UnsafeUnpin for Layer

§

impl UnwindSafe for Layer

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<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> 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> 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.