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
impl Layer
Sourcepub fn set_property(&mut self, tag: PropTag, value: u64) -> &mut Self
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.
Sourcepub fn set_property_by_name(&mut self, name: &str, value: u64) -> bool
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.
Sourcepub fn property_by_name(&self, name: &str) -> Option<u64>
pub fn property_by_name(&self, name: &str) -> Option<u64>
The value of a property by canonical KMS name, if set.
Sourcepub fn properties(&self) -> impl Iterator<Item = (PropTag, u64)> + '_
pub fn properties(&self) -> impl Iterator<Item = (PropTag, u64)> + '_
Every set property, in tag order.
Sourcepub const fn property_count(&self) -> u32
pub const fn property_count(&self) -> u32
How many properties are set.
Sourcepub const fn snapshot(&self) -> PropertySnapshot
pub const fn snapshot(&self) -> PropertySnapshot
Snapshot the property state for diffing.
Sourcepub fn disable(&mut self) -> &mut Self
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.
Sourcepub fn property_hash(&self) -> u64
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.
Sourcepub fn set_force_composited(&mut self, composited: bool) -> &mut Self
pub fn set_force_composited(&mut self, composited: bool) -> &mut Self
Force this layer through composition rather than a plane.
Sourcepub const fn is_force_composited(&self) -> bool
pub const fn is_force_composited(&self) -> bool
Whether the caller pinned this layer to composition.
Sourcepub fn set_transient_composited(&mut self, composited: bool) -> &mut Self
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.
Sourcepub const fn is_transient_composited(&self) -> bool
pub const fn is_transient_composited(&self) -> bool
Whether the scene set the per-commit composition flag.
Sourcepub const fn needs_composition(&self) -> bool
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.
Sourcepub fn set_composition_layer(&mut self, is_composition: bool) -> &mut Self
pub fn set_composition_layer(&mut self, is_composition: bool) -> &mut Self
Mark this layer as the output of the composition pass itself.
Sourcepub const fn is_composition_layer(&self) -> bool
pub const fn is_composition_layer(&self) -> bool
Whether this layer is the composition pass’s own output.
Sourcepub const fn is_externally_bound(&self) -> bool
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.
Sourcepub fn set_externally_bound(&mut self, externally_bound: bool) -> &mut Self
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.
Sourcepub const fn is_pinned(&self) -> bool
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.
Sourcepub fn set_pinned(&mut self, pinned: bool) -> &mut Self
pub fn set_pinned(&mut self, pinned: bool) -> &mut Self
Mark this layer as pinned to a specific plane.
Sourcepub const fn assigned_plane(&self) -> Option<u32>
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.
Sourcepub fn set_assigned_plane(&mut self, plane_id: Option<u32>) -> &mut Self
pub fn set_assigned_plane(&mut self, plane_id: Option<u32>) -> &mut Self
Record the plane a pinned layer holds.
Sourcepub const fn content_type(&self) -> ContentType
pub const fn content_type(&self) -> ContentType
What this layer is showing.
Sourcepub fn set_content_type(&mut self, content_type: ContentType) -> &mut Self
pub fn set_content_type(&mut self, content_type: ContentType) -> &mut Self
Set what this layer is showing.
Sourcepub fn set_update_hint(&mut self, hz: u32) -> &mut Self
pub fn set_update_hint(&mut self, hz: u32) -> &mut Self
Set the expected update rate.
Sourcepub const fn app_priority(&self) -> u8
pub const fn app_priority(&self) -> u8
Application-level placement priority within a content class.
Sourcepub fn set_app_priority(&mut self, priority: u8) -> &mut Self
pub fn set_app_priority(&mut self, priority: u8) -> &mut Self
Set the application-level placement priority.
Sourcepub const fn is_dirty(&self) -> bool
pub const fn is_dirty(&self) -> bool
Whether the layer changed since the last mark_clean.
Sourcepub const fn mark_clean(&mut self)
pub const fn mark_clean(&mut self)
Clear the dirty flag.
Sourcepub const fn format(&self) -> Option<u32>
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.
Sourcepub const fn modifier(&self) -> u64
pub const fn modifier(&self) -> u64
The layout modifier, defaulting to LINEAR’s zero when unset.
Sourcepub const fn requires_scaling(&self) -> bool
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++.