-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
impl Hash+Eq for GradientStop #450
Comments
Actually implementing |
Yes, I was thinking bitwise. The actual thing I care about is "will generate an identical GPU-side representation" for which bitwise is appropriate. |
Implement Hash and Eq traits on gradient stops, which implies doing the same for colors. This facilitates creating a cache of baked gradient ramps. Closes #450
Implement Hash and Eq traits on gradient stops, which implies doing the same for colors. This facilitates creating a cache of baked gradient ramps. Closes #450
Implement Hash and Eq traits on gradient stops, which implies doing the same for colors. This facilitates creating a cache of baked gradient ramps. Closes linebender#450
* make image formats optional via features * make sure image is also imported when importing an image format * make the features propperly formatted * fix merge * Move cairo over to 0.14 version * Fix clippy issues * Fix weird addition * Remove snapshots * Fix tests * Fix CI * Make piet-cairo almost unwrap free * Make gradient stops hashable (#454) Implement Hash and Eq traits on gradient stops, which implies doing the same for colors. This facilitates creating a cache of baked gradient ramps. Closes #450 * [cairo] Fix for big-endian systems Cairo defines pixels as "a 32-bit quantity [...] stored in native-endian". However, the existing code was treating a pixel as four 8-bit quantities. Put differently, it was hardcoding little endian. This commit changes the code to first calculate the pixel value as an u32 and then use u32::to_ne_bytes() to get back to "the world of bytes". For readability, this is done in a new helper function. I did not actually check if this fixes anything on big endian, but at least it does not change anything for little endian according to the test-pictures examples. Fixes: #224 Signed-off-by: Uli Schlachter <[email protected]> * Remove unnecessary dst_off parameter Signed-off-by: Uli Schlachter <[email protected]> * Fix clippy warning about single-character names error: 5 bindings with single-character names in scope Error: --> piet-cairo/src/lib.rs:523:47 | 523 | fn write_rgba(data: &mut [u8], offset: usize, x: usize, r: u8, g: u8, b: u8, a: u8) { | ^ ^ ^ ^ ^ | = note: `-D clippy::many-single-char-names` implied by `-D warnings` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#many_single_char_names Signed-off-by: Uli Schlachter <[email protected]> * Add a simple criterion benchmark This adds a simple benchmark for piet-cairo's make_image function. Signed-off-by: Uli Schlachter <[email protected]> * Fill benchmark image with random data Signed-off-by: Uli Schlachter <[email protected]> * Make rustfmt happy Signed-off-by: Uli Schlachter <[email protected]> * Try to clarify docs for ImageFormat The image format is based on individual bytes and thus independent of the system's endianness. This commit tries to make that more explicit. This was originally suggested in issue #224. Signed-off-by: Uli Schlachter <[email protected]> * Fix issue with benchmarks * Remove redefinition * Add safety comment Co-authored-by: Raph Levien <[email protected]> Co-authored-by: Uli Schlachter <[email protected]>
I'm implementing gradients in piet-gpu, and one of the things I'm running into is being able to determine whether a gradient ramp is new or already in the cache. There are a number of ways to deal with this, but the most direct is to impl
Hash
onGradientStop
, so it can be used as a key in a hashmap.This is messy, because a gradient stop contains a float, and also because it means we have to hash color, but I think it's worth it.
Opening an issue first in case people want to discuss.
The text was updated successfully, but these errors were encountered: