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>
impl<B> HdrMetadataCache<B>
Sourcepub fn pending_destruction_count(&self) -> usize
pub fn pending_destruction_count(&self) -> usize
Blobs waiting for a commit to land before they can be destroyed.
Sourcepub fn acknowledge_committed(&mut self)
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>
impl<B: HdrBlob> HdrMetadataCache<B>
Sourcepub fn current_blob_id(&self, crtc_id: u32) -> u32
pub fn current_blob_id(&self, crtc_id: u32) -> u32
The blob id currently cached for crtc_id, or 0 if there is none.
Sourcepub fn current_content_hash(&self, crtc_id: u32) -> u64
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.
Sourcepub fn set_with<E, F>(
&mut self,
crtc_id: u32,
src: Option<&HdrSourceMetadata>,
factory: F,
) -> Result<u32, E>
pub fn set_with<E, F>( &mut self, crtc_id: u32, src: Option<&HdrSourceMetadata>, factory: F, ) -> Result<u32, 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.
Sourcepub fn clear_for_session_loss(&mut self)
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.
Sourcepub fn flush(&mut self)
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>>
impl<'a> HdrMetadataCache<HdrMetadataBlob<'a>>
Sourcepub fn set(
&mut self,
device: &'a Device,
crtc_id: u32,
src: Option<&HdrSourceMetadata>,
) -> CoreResult<u32>
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.