-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add PremulRgba8
, Rgba8::to_u32
#66
Conversation
e2b36a3
to
1b9230b
Compare
PremulRgb8a
, Rgba8::to_u32
PremulRgba8
, Rgba8::to_u32
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good, some suggestions inline.
69c004d
to
6a51843
Compare
Packing a `PremulColor` to 8 bit channels is a common operation and is done in Vello, so we now have support for a `PremulRgb8a` and some `to_u32` operations as well.
6a51843
to
45e459b
Compare
/// Returns the color as a packed value, with `r` as the most significant byte and | ||
/// `a` the least. | ||
#[must_use] | ||
pub const fn to_u32(self) -> u32 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IWBN to have the mirroring from_u32
.
/// `a` the least. | ||
#[must_use] | ||
pub const fn to_u32(self) -> u32 { | ||
((self.r as u32) << 24) | ((self.g as u32) << 16) | ((self.b as u32) << 8) | self.a as u32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this use from_be_bytes instead? That is also const.
Also, add a short sanity check test. Based on feedback from @DJMcNab in PR linebender#66.
Packing a
PremulColor
to 8 bit channels is a common operation and is done in Vello, so we now have support for aPremulRgb8a
and someto_u32
operations as well.