|
@@ -15,19 +15,38 @@ pub enum PixelFormat {
|
|
|
pub(crate) const NUM_PIXEL_FORMATS: usize = 7;
|
|
|
pub(crate) const MAX_PIXEL_WIDTH: usize = 4;
|
|
|
|
|
|
+// pub struct PackedLocation(Option<u8>);
|
|
|
#[derive(Clone, PartialEq, Debug, Default)]
|
|
|
-pub struct PackedLocation(Option<u8>);
|
|
|
+pub enum PackedLocation {
|
|
|
+ #[default]
|
|
|
+ None,
|
|
|
+ Select(u8),
|
|
|
+ Clear(u8)
|
|
|
+}
|
|
|
|
|
|
impl PackedLocation {
|
|
|
const fn empty() -> Self {
|
|
|
- Self(None)
|
|
|
+ Self::None
|
|
|
}
|
|
|
const fn select_byte(index: u8) -> Self {
|
|
|
- Self(Some(index))
|
|
|
+ Self::Select(index)
|
|
|
+ }
|
|
|
+ const fn clear_byte(index: u8) -> Self {
|
|
|
+ Self::Clear(index)
|
|
|
}
|
|
|
|
|
|
pub const fn index(&self) -> Option<u8> {
|
|
|
- self.0
|
|
|
+ match self {
|
|
|
+ Self::None => None,
|
|
|
+ Self::Select(ndx) => Some(*ndx),
|
|
|
+ Self::Clear(_) => None
|
|
|
+ }
|
|
|
+ }
|
|
|
+ pub const fn clear_index(&self) -> Option<u8> {
|
|
|
+ match self {
|
|
|
+ Self::Clear(ndx) => Some(*ndx),
|
|
|
+ _ => None
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -135,10 +154,10 @@ impl PixelFormatSpec for Bgr32 {
|
|
|
|
|
|
const NAME: &'static str = "Bgr32";
|
|
|
|
|
|
- const RED_PACK: PackedLocation = PackedLocation::select_byte(2);
|
|
|
+ const RED_PACK: PackedLocation = PackedLocation::select_byte(0);
|
|
|
const GREEN_PACK: PackedLocation = PackedLocation::select_byte(1);
|
|
|
- const BLUE_PACK: PackedLocation = PackedLocation::select_byte(0);
|
|
|
- const ALPHA_PACK: PackedLocation = PackedLocation::empty();
|
|
|
+ const BLUE_PACK: PackedLocation = PackedLocation::select_byte(2);
|
|
|
+ const ALPHA_PACK: PackedLocation = PackedLocation::clear_byte(3);
|
|
|
}
|
|
|
|
|
|
/// 24bpp colour densly packed into 24-bit words
|
|
@@ -188,7 +207,7 @@ impl PixelFormatSpec for Rgb32 {
|
|
|
const RED_PACK: PackedLocation = PackedLocation::select_byte(2);
|
|
|
const GREEN_PACK: PackedLocation = PackedLocation::select_byte(1);
|
|
|
const BLUE_PACK: PackedLocation = PackedLocation::select_byte(0);
|
|
|
- const ALPHA_PACK: PackedLocation = PackedLocation::empty();
|
|
|
+ const ALPHA_PACK: PackedLocation = PackedLocation::clear_byte(3);
|
|
|
}
|
|
|
|
|
|
/// RGBA with 8 bits per channel, stored little-endian
|