pub enum AlphaChannel {
None,
Straight,
Padding,
}Expand description
What a PixelFormat’s fourth component means — the contract a
consumer must honour before it reads lane 3 of a packed layout (or the
fourth plane of a planar one).
This exists because “4 channels” and “has alpha” are not the same
statement, and treating them as one is an easy mistake to make.
The X-padded desktop layouts (BGRX / RGBX — FFmpeg bgr0 / rgb0,
DXGI B8G8R8X8_UNORM, DRM XRGB8888, AHardwareBuffer
R8G8B8X8_UNORM) are byte-for-byte identical to their alpha-carrying
twins, so nothing about the layout can tell them apart — the
distinction is semantic, and therefore has to live in the type. Prose
alone does not stop av_hwframe_transfer_data handing a compositor a
frame of all-zero padding bytes that it reads as “fully transparent”.
Variants§
None
The format has no fourth component at all (NV12, YUV420P,
UYVY422, RgbU16, the scalar fields, …). There is nothing to read.
Straight
A real, straight (non-premultiplied) alpha: lane 3 / plane 3
carries opacity, full-range by definition (code 0 → transparent,
max code → opaque), and a compositor MUST honour it.
Padding
A padding lane. The bits exist in memory and carry no
information: a producer may write anything into them (a decoded
FFV1 bgr0 frame writes 0x00; a D3D B8G8R8X8 render target
writes whatever the last shader left), and every reader MUST
substitute full opacity rather than sampling them.
Practically that means: never multiply by lane 3, never use it as a
composite weight, never propagate it into an alpha-carrying
destination. A format that answers Padding is opaque —
PixelFormat::has_alpha is false for it, which is what a
compositor’s alpha gate keys on.
Trait Implementations§
Source§impl Clone for AlphaChannel
impl Clone for AlphaChannel
impl Copy for AlphaChannel
Source§impl Debug for AlphaChannel
impl Debug for AlphaChannel
Source§impl<'de> Deserialize<'de> for AlphaChannel
Available on crate feature serde only.
impl<'de> Deserialize<'de> for AlphaChannel
serde only.Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for AlphaChannel
Source§impl Hash for AlphaChannel
impl Hash for AlphaChannel
Source§impl PartialEq for AlphaChannel
impl PartialEq for AlphaChannel
Source§impl Serialize for AlphaChannel
Available on crate feature serde only.
impl Serialize for AlphaChannel
serde only.impl StructuralPartialEq for AlphaChannel
Auto Trait Implementations§
impl Freeze for AlphaChannel
impl RefUnwindSafe for AlphaChannel
impl Send for AlphaChannel
impl Sync for AlphaChannel
impl Unpin for AlphaChannel
impl UnsafeUnpin for AlphaChannel
impl UnwindSafe for AlphaChannel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.