Skip to main content

HardwareBufferFormat

Enum HardwareBufferFormat 

Source
#[non_exhaustive]
pub enum HardwareBufferFormat { Bgra8, Rgba8, Nv12, P010, }
Expand description

How a hardware buffer lays out its pixels: one plane of colour, as an app draws, or a video decoder’s own planes of brightness and colour difference, which the system’s decoders write and its compositor shows with no conversion. What the samples mean as colour (matrix, range) is the picture’s (VideoFrame::color), not the buffer’s.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Bgra8

8-bit blue, green, red and alpha in one plane: CoreVideo’s 32BGRA, DXGI’s B8G8R8A8_UNORM, DRM’s ARGB8888.

§

Rgba8

8-bit red, green, blue and alpha in one plane: Android’s R8G8B8A8_UNORM.

§

Nv12

8-bit 4:2:0 in two planes: brightness, then blue and red difference interleaved at half the size each way. CoreVideo’s 420v and 420f, DXGI’s and DRM’s NV12. Not Android’s Y8Cb8Cr8_420, whose planes lie as its allocator chooses.

§

P010

10-bit 4:2:0 laid out as Nv12, each sample in the high ten bits of sixteen: CoreVideo’s x420 and xf20, DXGI’s and DRM’s P010, Android’s YCbCr_P010.

Implementations§

Source§

impl HardwareBufferFormat

Source

pub fn plane_count(self) -> usize

How many planes it has: one, or two for Nv12 and P010.

Source

pub fn plane_format(self, plane: usize) -> Option<TextureFormat>

The texture format plane plane is sampled in: Bgra8Unorm or Rgba8Unorm for one plane; R8Unorm then Rg8Unorm for Nv12, as wgpu’s TextureFormat::NV12 aspects are; R16Unorm then Rg16Unorm for P010, which need Features::TEXTURE_FORMAT_16BIT_NORM. None past the last plane.

Source

pub fn plane_size(self, plane: usize, size: [u32; 2]) -> Option<[u32; 2]>

The size of plane plane of a buffer of size pixels: the whole for the first plane, and half each way, rounded up, for the colour plane of Nv12 and P010. None past the last plane.

Trait Implementations§

Source§

impl Clone for HardwareBufferFormat

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for HardwareBufferFormat

Source§

impl Debug for HardwareBufferFormat

Source§

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

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

impl Eq for HardwareBufferFormat

Source§

impl Hash for HardwareBufferFormat

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for HardwareBufferFormat

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for HardwareBufferFormat

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,