|
1 | | -/// A pixel format that Softbuffer may use. |
| 1 | +/// The pixel format of a surface and buffer. |
2 | 2 | /// |
3 | 3 | /// # Alpha |
4 | 4 | /// |
5 | 5 | /// These pixel formats all include the alpha channel in their name, but formats that ignore the |
6 | | -/// alpha channel are supported if you set [`AlphaMode::Ignored`]. This will make `RGBA` mean `RGBX` |
7 | | -/// and `BGRA` mean `BGRX`. |
| 6 | +/// alpha channel are supported if you use [`AlphaMode::Ignored`]. This will make `Rgba8` mean |
| 7 | +/// `Rgbx8`, for example. |
8 | 8 | /// |
9 | 9 | /// [`AlphaMode::Ignored`]: crate::AlphaMode::Ignored |
10 | 10 | /// |
|
13 | 13 | /// The [`Default::default`] implementation returns the pixel format that Softbuffer uses for the |
14 | 14 | /// current target platform. |
15 | 15 | /// |
16 | | -/// Currently, this is [`BGRA`][Self::Bgra] on all platforms except WebAssembly and Android, where |
17 | | -/// it is [`RGBA`][Self::Rgba], since the API on these platforms does not support BGRA. |
| 16 | +/// Currently, this is [`Bgra8`][Self::Bgra8] on all platforms except WebAssembly and Android, where |
| 17 | +/// it is [`Rgba8`][Self::Rgba8], since the API on these platforms does not support BGRA. |
18 | 18 | /// |
19 | 19 | /// The format for a given platform may change in a non-breaking release if found to be more |
20 | 20 | /// performant. |
21 | 21 | /// |
22 | 22 | /// This distinction should only be relevant if you're bitcasting `Pixel` to/from a `u32`, to e.g. |
23 | 23 | /// avoid unnecessary copying, see the documentation for [`Pixel`][crate::Pixel] for examples. |
| 24 | +#[non_exhaustive] |
24 | 25 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Default)] |
25 | 26 | pub enum PixelFormat { |
26 | | - /// The pixel format is `RGBA` (red, green, blue, alpha). |
| 27 | + // This uses roughly the same naming scheme as WebGPU does. |
| 28 | + /// 32-bit BGRA, `u8` per channel. Laid out in memory as `B,G,R,A`. |
27 | 29 | /// |
28 | | - /// This is currently the default on macOS/iOS, KMS/DRM, Orbital, Wayland, Windows and X11. |
| 30 | + /// **This is currently the default on macOS/iOS, KMS/DRM, Orbital, Wayland, Windows and X11**. |
| 31 | + /// |
| 32 | + /// ## Platform Support |
| 33 | + /// |
| 34 | + /// - macOS/iOS, KMS/DRM, Orbital, Wayland, Windows and X11: Supported. |
| 35 | + /// - Android and Web: Not yet supported. |
29 | 36 | #[cfg_attr(not(any(target_family = "wasm", target_os = "android")), default)] |
30 | | - Bgra, |
31 | | - /// The pixel format is `BGRA` (blue, green, red, alpha). |
| 37 | + #[doc(alias = "Argb8888")] |
| 38 | + #[doc(alias = "Xrgb8888")] |
| 39 | + #[doc(alias = "VK_FORMAT_B8G8R8A8_UNORM")] |
| 40 | + Bgra8, |
| 41 | + |
| 42 | + /// 32-bit RGBA, `u8` per channel. Laid out in memory as `R,G,B,A`. |
| 43 | + /// |
| 44 | + /// **This is currently the default on Android and Web**. |
| 45 | + /// |
| 46 | + /// ## Platform Support |
32 | 47 | /// |
33 | | - /// This is currently the default on Android and Web. |
| 48 | + /// - Android and Web: Supported. |
| 49 | + /// - macOS/iOS, KMS/DRM, Orbital, Wayland, Windows and X11: Not yet supported. |
34 | 50 | #[cfg_attr(any(target_family = "wasm", target_os = "android"), default)] |
35 | | - Rgba, |
36 | | - // Intentionally exhaustive for now. |
| 51 | + #[doc(alias = "Abgr8888")] |
| 52 | + #[doc(alias = "Xbgr8888")] |
| 53 | + #[doc(alias = "VK_FORMAT_R8G8B8A8_UNORM")] |
| 54 | + Rgba8, |
37 | 55 | } |
38 | 56 |
|
39 | 57 | impl PixelFormat { |
|
0 commit comments