Enum PixelFormat
#[repr(u32)]pub enum PixelFormat {
Bgra8 = 0,
Yuy2 = 1,
Nv12 = 2,
Yv12 = 3,
R8G8B8A8 = 4,
}
Expand description
Specifies how pixels are represented in the image buffer.
Variants§
Bgra8 = 0
BGRA_8
A 32-bit four-component unsigned integer format.
Byte order: B, G, R, A (little-endian ARGB packed 32-bit word).
Equivalent to Skia kBGRA_8888_SkColorType
color type.
Equivalent to Zircon ARGB_8888
pixel format on little-endian arch.
Yuy2 = 1
YUY2
4:2:2 (2x down-sampled UV horizontally; full res UV vertically)
A 32-bit component that contains information for 2 pixels: Byte order: Y1, U, Y2, V Unpacks to 2 RGB pixels, where RGB1 = func(Y1, U, V) and RGB2 = func(Y2, U, V) Equivalent to YUV422
Nv12 = 2
NV12
4:2:0 (2x down-sampled UV in both directions)
Offset 0: 8 bit per pixel Y plane with bytes YYY. Offset height * stride: 8 bit UV data interleaved bytes as UVUVUV.
Y plane has line stride >= width.
In this context, both width and height are required to be even.
The UV data is separated into “lines”, with each “line” having same byte width as a line of Y data, and same “line” stride as Y data’s line stride. The UV data has height / 2 “lines”.
In converting to RGB, the UV data gets up-scaled by 2x in both directions overall. This comment is intentionally silent on exactly how UV up-scaling phase/filtering/signal processing works, as it’s a complicated topic that can vary by implementation, typically trading off speed and quality of the up-scaling. See comments in relevant conversion code for approach taken by any given convert path. The precise relative phase of the UV data is not presently conveyed.
Yv12 = 3
YV12
Like I420, except with V and U swapped.
4:2:0 (2x down-sampled UV in both directions)
Offset 0: 8 bit per pixel Y plane with bytes YYY. Offset height * stride: 8 bit V data with uv_stride = stride / 2 Offset height * stride + uv_stride * height / 2: 8 bit U data with uv_stride = stride / 2
Y plane has line stride >= width.
Both width and height are required to be even.
R8G8B8A8 = 4
R8G8B8A8
A 32-bit four-component unsigned integer format.
Byte order: R, G, B, A (little-endian ABGR packed 32-bit word).
Equivalent to Skia kRGBA_8888_SkColorType
color type.
Equivalent to Zircon ABGR_8888
pixel format on little-endian arch.
This format can only be used with VK_DEVICE_MEMORY.
Implementations§
§impl PixelFormat
impl PixelFormat
pub fn from_primitive(prim: u32) -> Option<PixelFormat>
pub const fn into_primitive(self) -> u32
pub fn is_unknown(&self) -> bool
is_unknown
Trait Implementations§
§impl Clone for PixelFormat
impl Clone for PixelFormat
§fn clone(&self) -> PixelFormat
fn clone(&self) -> PixelFormat
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for PixelFormat
impl Debug for PixelFormat
§impl<D> Decode<PixelFormat, D> for PixelFormatwhere
D: ResourceDialect,
impl<D> Decode<PixelFormat, D> for PixelFormatwhere
D: ResourceDialect,
§fn new_empty() -> PixelFormat
fn new_empty() -> PixelFormat
Self
. The specific value does not matter,
since it will be overwritten by decode
.§impl<D> Encode<PixelFormat, D> for PixelFormatwhere
D: ResourceDialect,
impl<D> Encode<PixelFormat, D> for PixelFormatwhere
D: ResourceDialect,
§impl Hash for PixelFormat
impl Hash for PixelFormat
§impl Ord for PixelFormat
impl Ord for PixelFormat
§impl PartialEq for PixelFormat
impl PartialEq for PixelFormat
§impl PartialOrd for PixelFormat
impl PartialOrd for PixelFormat
§impl TypeMarker for PixelFormat
impl TypeMarker for PixelFormat
§type Owned = PixelFormat
type Owned = PixelFormat
§fn inline_align(_context: Context) -> usize
fn inline_align(_context: Context) -> usize
§fn inline_size(_context: Context) -> usize
fn inline_size(_context: Context) -> usize
inline_align
.§fn encode_is_copy() -> bool
fn encode_is_copy() -> bool
Self::Owned
matches the FIDL wire
format and encoding requires no validation. When true, we can optimize
encoding arrays and vectors of Self::Owned
to a single memcpy. Read more§fn decode_is_copy() -> bool
fn decode_is_copy() -> bool
Self::Owned
matches the FIDL wire
format and decoding requires no validation. When true, we can optimize
decoding arrays and vectors of Self::Owned
to a single memcpy.§impl ValueTypeMarker for PixelFormat
impl ValueTypeMarker for PixelFormat
§type Borrowed<'a> = PixelFormat
type Borrowed<'a> = PixelFormat
Encode<Self>
type cheaply obtainable from &Self::Owned
. There are three cases: Read more§fn borrow(
value: &<PixelFormat as TypeMarker>::Owned,
) -> <PixelFormat as ValueTypeMarker>::Borrowed<'_>
fn borrow( value: &<PixelFormat as TypeMarker>::Owned, ) -> <PixelFormat as ValueTypeMarker>::Borrowed<'_>
&Self::Owned
to Self::Borrowed
.