Skip to main content

Output

Struct Output 

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

The layers destined for one CRTC, in presentation order.

§Deviation: the composition layer is owned here

The C++ Output takes the composition layer by reference and owns only the rest, keeping a std::vector<std::unique_ptr<Layer>> alongside a std::vector<Layer*> view it can reorder independently.

Here every layer is owned by the Output and the composition layer is identified by LayerId. Holding a &mut Layer in the struct would infect every caller with a lifetime parameter for no benefit, and owning it removes the second vector — and with it the C++’s since-removed rebuild_layer_ptrs, which would have silently undone sort_layers_by_zpos had anything called it (drm-cxx#237).

Implementations§

Source§

impl Output

Source

pub const fn new(crtc_id: u32) -> Self

An output for crtc_id with no layers.

Source

pub const fn crtc_id(&self) -> u32

The CRTC this output drives.

Source

pub fn add_layer(&mut self) -> LayerId

Add an empty layer, returning its id.

Ids are never reused for the life of the output, which is what lets the allocator key its warm-start state on them safely.

Source

pub fn remove_layer(&mut self, id: LayerId) -> bool

Remove a layer. Returns whether it was there.

If it was the composition layer, the output is left with none.

Source

pub fn layer(&self, id: LayerId) -> Option<&Layer>

Borrow a layer.

Source

pub fn layer_mut(&mut self, id: LayerId) -> Option<&mut Layer>

Borrow a layer mutably.

Source

pub fn layers(&self) -> impl Iterator<Item = LayerRef<'_>> + '_

Every layer with its id, in presentation order.

Source

pub fn layer_refs(&self) -> Vec<LayerRef<'_>>

Every layer, as the slice the allocator takes.

Source

pub fn len(&self) -> usize

How many layers the output holds.

Source

pub fn is_empty(&self) -> bool

Whether the output holds no layers.

Source

pub fn set_composition_layer(&mut self, id: LayerId) -> bool

Designate a layer as the composition pass’s output.

Clears the flag on any previous composition layer, so exactly one layer carries it. Returns whether id names a layer of this output.

Source

pub const fn composition_layer(&self) -> Option<LayerId>

The composition layer’s id, if one is designated.

Source

pub fn any_layer_dirty(&self) -> bool

Whether any layer changed since the last mark_clean.

Source

pub fn changed_layers(&self) -> impl Iterator<Item = LayerRef<'_>> + '_

The layers that changed, in presentation order.

Source

pub fn mark_clean(&mut self)

Clear every layer’s dirty flag.

Source

pub fn sort_layers_by_zpos(&mut self)

Reorder layers by ascending zpos, treating an unset zpos as 0.

Stable, so layers sharing a zpos keep the order they were added in.

Trait Implementations§

Source§

impl Debug for Output

Source§

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

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

impl Default for Output

Source§

fn default() -> Self

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

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