#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u8)]
#[non_exhaustive]
pub enum PropTag {
FbId,
FbModifier,
CrtcId,
CrtcX,
CrtcY,
CrtcW,
CrtcH,
SrcX,
SrcY,
SrcW,
SrcH,
Rotation,
Alpha,
Zpos,
PixelFormat,
InFenceFd,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[non_exhaustive]
pub enum PropClass {
Content,
Placement,
}
pub const NUM_PROPS: usize = PropTag::ALL.len();
impl PropTag {
pub const ALL: [Self; 16] = [
Self::FbId,
Self::FbModifier,
Self::CrtcId,
Self::CrtcX,
Self::CrtcY,
Self::CrtcW,
Self::CrtcH,
Self::SrcX,
Self::SrcY,
Self::SrcW,
Self::SrcH,
Self::Rotation,
Self::Alpha,
Self::Zpos,
Self::PixelFormat,
Self::InFenceFd,
];
#[must_use]
pub const fn index(self) -> usize {
self as usize
}
#[must_use]
pub const fn name(self) -> &'static str {
match self {
Self::FbId => "FB_ID",
Self::FbModifier => "FB_MODIFIER",
Self::CrtcId => "CRTC_ID",
Self::CrtcX => "CRTC_X",
Self::CrtcY => "CRTC_Y",
Self::CrtcW => "CRTC_W",
Self::CrtcH => "CRTC_H",
Self::SrcX => "SRC_X",
Self::SrcY => "SRC_Y",
Self::SrcW => "SRC_W",
Self::SrcH => "SRC_H",
Self::Rotation => "rotation",
Self::Alpha => "alpha",
Self::Zpos => "zpos",
Self::PixelFormat => "pixel_format",
Self::InFenceFd => "IN_FENCE_FD",
}
}
#[must_use]
pub const fn class(self) -> PropClass {
match self {
Self::FbId | Self::InFenceFd => PropClass::Content,
Self::FbModifier
| Self::CrtcId
| Self::CrtcX
| Self::CrtcY
| Self::CrtcW
| Self::CrtcH
| Self::SrcX
| Self::SrcY
| Self::SrcW
| Self::SrcH
| Self::Rotation
| Self::Alpha
| Self::Zpos
| Self::PixelFormat => PropClass::Placement,
}
}
#[must_use]
pub fn from_name(name: &str) -> Option<Self> {
Self::ALL.into_iter().find(|tag| tag.name() == name)
}
}