Skip to content

Conversation

@madsmtm
Copy link
Member

@madsmtm madsmtm commented Nov 23, 2025

This is much easier to get right than manually bit-packing into a u32.

The format is RGBX on WASM (and TODO Android) and BGRX elsewhere, which should also allow avoiding needless copying on WASM. This should either fix or allow fixing #207.

See also discussion in #98. This is not a full solution to pixel formats such as proposed by #186 and #241, but I believe it's an improvement we can more easily make in the meantime, and if nothing else it should at least be a stepping stone in allowing us to figure out what we do want.

Fixes #109.

Tested on:

  • Android
  • CoreGraphics
  • KMS/DRM
  • Orbital
  • Wayland
  • Web
  • Win32
  • X11

@madsmtm madsmtm added the enhancement New feature or request label Nov 23, 2025
Comment on lines +95 to +99
/// The alpha component.
///
/// `0xff` here means opaque, whereas `0` means transparent.
///
/// NOTE: Transparency is not yet supported, see [#17], so this doesn't actually do anything.
///
/// [#17]: https://github.com/rust-windowing/softbuffer/issues/17
pub(crate) a: u8,
Copy link
Member Author

@madsmtm madsmtm Nov 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could leave this out, but:

  • There are backends that want to read this, such as the Web backend, and leaving it as padding in the struct would cause that to read uninitialized bytes instead.
  • It'll be useful in moving towards Transparency #17 with less of a breaking change.

The downside of course is that struct initialization syntax is unavailable (at least until we expose this).

This is much more intuitive to use than manually bit-packing into a u32.

The format is RGBX on WASM and Android and BGRX elsewhere. This should
allow avoiding needless copying on these platforms.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Development

Successfully merging this pull request may close these issues.

Endianness Considerations

3 participants