diff --git a/Cargo.lock b/Cargo.lock index 94b22b94..8c78eda1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -434,8 +434,9 @@ dependencies = [ [[package]] name = "color" -version = "0.1.0" -source = "git+https://github.com/linebender/color.git?rev=f82649b205aedab1d86de98fdce858cb80e8e482#f82649b205aedab1d86de98fdce858cb80e8e482" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "212bb4103d3dc3eca9f7b665588528dee3a42fc03272b2db5ffa3010dc84b39c" dependencies = [ "serde", ] @@ -1665,8 +1666,9 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "peniko" -version = "0.2.0" -source = "git+https://github.com/linebender/peniko.git?rev=3462e19#3462e19c7ba152a1c3aaa883825073180864e3e4" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7de2e49a1a6b7a55ec3ba866a423f46cd8f31472bfaabe42c68e144c27bc668" dependencies = [ "color", "kurbo", @@ -2077,18 +2079,18 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.215" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" +checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.215" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" +checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 66e62d80..c95a830d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -101,8 +101,7 @@ bytemuck = { version = "1.20.0", features = ["derive"] } skrifa = "0.26.0" # The version of kurbo used below should be kept in sync # with the version of kurbo used by peniko. -# peniko = "0.2.0" -peniko = { version = "0.2.0", git = "https://github.com/linebender/peniko.git", rev = "3462e19" } +peniko = "0.3.0" # FIXME: This can be removed once peniko supports the schemars feature. kurbo = "0.11.1" futures-intrusive = "0.5.0" diff --git a/examples/scenes/src/images.rs b/examples/scenes/src/images.rs index 95b6a263..f8046a05 100644 --- a/examples/scenes/src/images.rs +++ b/examples/scenes/src/images.rs @@ -5,7 +5,7 @@ use std::collections::HashMap; use std::path::{Path, PathBuf}; use std::sync::Arc; -use vello::peniko::{Blob, Format, Image}; +use vello::peniko::{Blob, Image, ImageFormat}; /// Simple hack to support loading images for examples. #[derive(Default)] @@ -50,5 +50,5 @@ fn decode_image(data: &[u8]) -> anyhow::Result { let height = image.height(); let data = Arc::new(image.into_rgba8().into_vec()); let blob = Blob::new(data); - Ok(Image::new(blob, Format::Rgba8, width, height)) + Ok(Image::new(blob, ImageFormat::Rgba8, width, height)) } diff --git a/examples/scenes/src/test_scenes.rs b/examples/scenes/src/test_scenes.rs index c8e6b2cf..badc8d5f 100644 --- a/examples/scenes/src/test_scenes.rs +++ b/examples/scenes/src/test_scenes.rs @@ -1779,7 +1779,7 @@ mod impls { blob.extend(c.premultiply().to_rgba8().to_u8_array()); }); let data = Blob::new(Arc::new(blob)); - let image = Image::new(data, Format::Rgba8, 2, 2); + let image = Image::new(data, ImageFormat::Rgba8, 2, 2); scene.draw_image( &image, @@ -1822,7 +1822,7 @@ mod impls { blob.extend(c.premultiply().to_rgba8().to_u8_array()); }); let data = Blob::new(Arc::new(blob)); - let image = Image::new(data, Format::Rgba8, 2, 2); + let image = Image::new(data, ImageFormat::Rgba8, 2, 2); let image = image.with_extend(Extend::Pad); // Pad extend mode scene.fill( diff --git a/vello/src/scene.rs b/vello/src/scene.rs index e7614599..9016c8ad 100644 --- a/vello/src/scene.rs +++ b/vello/src/scene.rs @@ -554,7 +554,7 @@ impl<'a> DrawGlyphs<'a> { Image::new( // TODO: The design of the Blob type forces the double boxing Blob::new(Arc::new(data)), - peniko::Format::Rgba8, + peniko::ImageFormat::Rgba8, bitmap.width, bitmap.height, ) @@ -583,7 +583,7 @@ impl<'a> DrawGlyphs<'a> { Image::new( // TODO: The design of the Blob type forces the double boxing Blob::new(Arc::new(buf)), - peniko::Format::Rgba8, + peniko::ImageFormat::Rgba8, bitmap.width, bitmap.height, ) @@ -614,7 +614,7 @@ impl<'a> DrawGlyphs<'a> { Image::new( // TODO: The design of the Blob type forces the double boxing Blob::new(Arc::new(data)), - peniko::Format::Rgba8, + peniko::ImageFormat::Rgba8, bitmap.width, bitmap.height, ) @@ -1015,7 +1015,7 @@ fn conv_extend(extend: skrifa::color::Extend) -> Extend { struct ColorStopsConverter<'a>(&'a [skrifa::color::ColorStop], &'a Cpal<'a>, BrushRef<'a>); impl ColorStopsSource for ColorStopsConverter<'_> { - fn collect_stops(&self, vec: &mut ColorStops) { + fn collect_stops(self, stops: &mut ColorStops) { for item in self.0 { let color = color_index(self.1, item.palette_index); let color = match color { @@ -1036,7 +1036,7 @@ impl ColorStopsSource for ColorStopsConverter<'_> { }, }; let color = color.multiply_alpha(item.alpha); - vec.push(ColorStop { + stops.push(ColorStop { color: DynamicColor::from_alpha_color(color), offset: item.offset, }); diff --git a/vello_encoding/src/ramp_cache.rs b/vello_encoding/src/ramp_cache.rs index 47d30b3e..67001f7c 100644 --- a/vello_encoding/src/ramp_cache.rs +++ b/vello_encoding/src/ramp_cache.rs @@ -3,6 +3,7 @@ use std::collections::HashMap; +use peniko::color::cache_key::CacheKey; use peniko::color::{HueDirection, Srgb}; use peniko::{ColorStop, ColorStops}; @@ -20,7 +21,7 @@ pub struct Ramps<'a> { #[derive(Default)] pub(crate) struct RampCache { epoch: u64, - map: HashMap, + map: HashMap, (u32, u64)>, data: Vec, } @@ -35,13 +36,13 @@ impl RampCache { } pub(crate) fn add(&mut self, stops: &[ColorStop]) -> u32 { - if let Some(entry) = self.map.get_mut(stops) { + if let Some(entry) = self.map.get_mut(&CacheKey(stops.into())) { entry.1 = self.epoch; entry.0 } else if self.map.len() < RETAINED_COUNT { let id = (self.data.len() / N_SAMPLES) as u32; self.data.extend(make_ramp(stops)); - self.map.insert(stops.into(), (id, self.epoch)); + self.map.insert(CacheKey(stops.into()), (id, self.epoch)); id } else { let mut reuse = None; @@ -60,12 +61,12 @@ impl RampCache { { *dst = src; } - self.map.insert(stops.into(), (id, self.epoch)); + self.map.insert(CacheKey(stops.into()), (id, self.epoch)); id } else { let id = (self.data.len() / N_SAMPLES) as u32; self.data.extend(make_ramp(stops)); - self.map.insert(stops.into(), (id, self.epoch)); + self.map.insert(CacheKey(stops.into()), (id, self.epoch)); id } } diff --git a/vello_tests/src/compare.rs b/vello_tests/src/compare.rs index a8760085..65524b65 100644 --- a/vello_tests/src/compare.rs +++ b/vello_tests/src/compare.rs @@ -10,7 +10,7 @@ use anyhow::{anyhow, bail, Result}; use image::DynamicImage; use nv_flip::FlipPool; use vello::{ - peniko::{Format, Image}, + peniko::{Image, ImageFormat}, Scene, }; @@ -105,8 +105,8 @@ pub async fn compare_gpu_cpu(scene: Scene, mut params: TestParams) -> Result Result