Skip to main content

HdrMetadataCache

Struct HdrMetadataCache 

Source
pub struct HdrMetadataCache<B> { /* private fields */ }
Expand description

Per-CRTC HDR_OUTPUT_METADATA blobs, deduped by content.

Generic over the blob so the caching logic can be tested without a DRM device – see HdrBlob.

Implementations§

Source§

impl<B> HdrMetadataCache<B>

Source

pub fn new() -> Self

An empty cache.

Source

pub fn pending_destruction_count(&self) -> usize

Blobs waiting for a commit to land before they can be destroyed.

Source

pub fn acknowledge_committed(&mut self)

Destroy everything queued for destruction.

Call this after the atomic commit that references the new blob has landed. By then the connector property has moved off every older id, so letting them go is safe.

Source§

impl<B: HdrBlob> HdrMetadataCache<B>

Source

pub fn current_blob_id(&self, crtc_id: u32) -> u32

The blob id currently cached for crtc_id, or 0 if there is none.

Source

pub fn current_content_hash(&self, crtc_id: u32) -> u64

The content hash currently cached for crtc_id, or 0 if there is none.

A real hash of exactly zero is possible and vanishingly unlikely; use HdrMetadataCache::current_blob_id to ask whether anything is cached.

Source

pub fn set_with<E, F>( &mut self, crtc_id: u32, src: Option<&HdrSourceMetadata>, factory: F, ) -> Result<u32, E>
where F: FnOnce(&HdrSourceMetadata) -> Result<B, E>,

Set or clear the metadata for crtc_id, returning the blob id to write to the connector’s HDR_OUTPUT_METADATA property.

None clears: returns 0 and queues any cached blob. Some whose hash matches what is cached is a no-op that returns the cached id without touching the kernel. Otherwise factory builds a replacement and the outgoing blob is queued.

The factory runs only when a new blob is actually needed, so a caller can put the expensive part inside it.

§Errors

Whatever factory returns. A failing factory leaves the cache exactly as it was – the previous blob stays live and stays cached, because a caller that ignores the error and commits anyway should show the old metadata rather than a freed blob or none at all.

Source

pub fn clear_for_session_loss(&mut self)

Forget every blob without asking the kernel to destroy any of them.

For session loss – a libseat pause revokes the descriptor, and the kernel reclaimed every blob on it at that moment. Destroying them through the replacement descriptor would at best fail and at worst free an unrelated blob that was given the same id there.

Source

pub fn flush(&mut self)

Destroy every blob, cached and queued alike.

For rebinding to a different CRTC or connector on the same descriptor, where nothing references the old blobs any more and holding them until the descriptor closes would leak. Unlike HdrMetadataCache::clear_for_session_loss, this really does destroy them, so the descriptor has to still be live.

Source§

impl<'a> HdrMetadataCache<HdrMetadataBlob<'a>>

Source

pub fn set( &mut self, device: &'a Device, crtc_id: u32, src: Option<&HdrSourceMetadata>, ) -> CoreResult<u32>

Set or clear the metadata for crtc_id, building blobs on device.

HdrMetadataCache::set_with with the obvious factory.

§Errors

drmkit_core::CoreError if the kernel refuses to create the blob.

Trait Implementations§

Source§

impl<B: Debug> Debug for HdrMetadataCache<B>

Source§

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

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

impl<B> Default for HdrMetadataCache<B>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<B> Freeze for HdrMetadataCache<B>
where HashMap<u32, Entry<B>>: Freeze, Vec<B>: Freeze,

§

impl<B> RefUnwindSafe for HdrMetadataCache<B>
where HashMap<u32, Entry<B>>: RefUnwindSafe, Vec<B>: RefUnwindSafe,

§

impl<B> Send for HdrMetadataCache<B>
where HashMap<u32, Entry<B>>: Send, Vec<B>: Send,

§

impl<B> Sync for HdrMetadataCache<B>
where HashMap<u32, Entry<B>>: Sync, Vec<B>: Sync,

§

impl<B> Unpin for HdrMetadataCache<B>
where HashMap<u32, Entry<B>>: Unpin, Vec<B>: Unpin,

§

impl<B> UnsafeUnpin for HdrMetadataCache<B>
where HashMap<u32, Entry<B>>: UnsafeUnpin, Vec<B>: UnsafeUnpin,

§

impl<B> UnwindSafe for HdrMetadataCache<B>
where HashMap<u32, Entry<B>>: UnwindSafe, Vec<B>: UnwindSafe,

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.