-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
229: Implement `bytemuck::Zeroable` and `bytemuck::Pod` for every color type r=Ogeon a=gymore-io I'm working on an experimental creative framework for Rust and I wanted to use one of `palette` types in a uniform buffer. This can be easily done through unsafe code but I think it is much cleaner to use the [`bytemuck`](https://crates.io/crates/bytemuck) crate which provide the [`Zeroable`] and [`Pod`] traits to convert types from and to raw bytes. This pull request implements those traits for the color types defined in this crate. # Changes I did the whole pull request in a single commit, implementing the traits for the following types. * `Rgb<S, T>` where `T` is `Pod`/`Zeroable` * `Luma<S, T>` where `T` is `Pod`/`Zeroable` * `Hsl<S, T>` where `T` is `Pod`/`Zeroable` * `Hsluv<Wp, T>` where `T` is `Pod`/`Zeroable` * `Hsv<S, T>` where `T` is `Pod`/`Zeroable` * `Hwb<S, T>` where `T` is `Pod`/`Zeroable` * `Lab<Wp, T>` where `T` is `Pod`/`Zeroable` * `Lch<Wp, T>` where `T` is `Pod`/`Zeroable` * `Lchuv<Wp, T>` where `T` is `Pod`/`Zeroable` * `Xyz<Wp, T>` where `T` is `Pod`/`Zeroable` * `Yxy<Wp, T>` where `T` is `Pod`/`Zeroable` * `Alpha<C, T>` where `C` and `T` are `Zeroable` * `Alpha<C<T>, T>` where `C<T>` is a color that is `Pod` and `T` is `Pod` eg. `Alpha<Rgb<T>, T>` is `Pod` if `T` is `Pod` I also implemented `Zeroable` and `Pod` for the [`Packed<C>`](https://ogeon.github.io/docs/palette/master/palette/struct.Packed.html) rgba struct. This required to make it implement `Copy` regardless of whether `C` was `Copy`. # Note I really expect this change to be used with the `Rgba` / `Rgb` types, but I made the change for every color type for consistency. [`Pod`]: https://docs.rs/bytemuck/1.5.1/bytemuck/trait.Pod.html [`Zeroable`]: https://docs.rs/bytemuck/1.5.1/bytemuck/trait.Zeroable.html Co-authored-by: Gymore <gymore.contact@gmail.com> Co-authored-by: Erik Hedvall <Ogeon@users.noreply.github.com>
- Loading branch information
Showing
17 changed files
with
254 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters