From 8d2a4b2cafd5e6be49bfb4ac8d0bd26fe02f036e Mon Sep 17 00:00:00 2001 From: Aaron Muir Hamilton Date: Wed, 14 Feb 2024 16:09:19 -0700 Subject: [PATCH] Bump Kurbo, Vello, and Parley (#178) --- Cargo.toml | 6 +++--- examples/common/text.rs | 4 ++-- examples/edit_text.rs | 20 ++++++++++++-------- examples/pen.rs | 12 ++++++------ examples/shello.rs | 20 ++++++++++---------- 5 files changed, 33 insertions(+), 29 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cb7689d..997fa83 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,7 +44,7 @@ accesskit = [ [dependencies] # Moving forward, this version should align with the kurbo version in peniko. -kurbo = "0.10.4" +kurbo = "0.11.0" tracing = { version = "0.1.22", features = ["log"] } lazy_static = "1.4.0" @@ -148,8 +148,8 @@ static_assertions = "1.1.0" test-log = { version = "0.2.5", features = ["trace"], default-features = false } tracing-subscriber = { version = "0.3.2", features = ["env-filter"] } unicode-segmentation = "1.7.0" -vello = { git = "https://github.com/linebender/vello", rev = "1c06c308b2ed1ebb858ed585cc284756325f9bb3" } -parley = { git = "https://github.com/dfrg/parley", rev = "2371bf4b702ec91edee2d58ffb2d432539580e1e" } +vello = { git = "https://github.com/linebender/vello", rev = "b1bd9e361f2944b71cef0ea8a2c71dce5182d79b" } +parley = { git = "https://github.com/dfrg/parley", rev = "1940d1ae9f2a9b44b7c18967147ffa7d345fdafd" } pollster = "0.3.0" wgpu = "0.18.0" diff --git a/examples/common/text.rs b/examples/common/text.rs index 0b3adc7..6168a79 100644 --- a/examples/common/text.rs +++ b/examples/common/text.rs @@ -24,7 +24,7 @@ impl Default for ParleyBrush { impl parley::style::Brush for ParleyBrush {} -pub fn render_text(builder: &mut SceneBuilder, transform: Affine, layout: &Layout) { +pub fn render_text(scene: &mut Scene, transform: Affine, layout: &Layout) { let mut gcx = GlyphContext::new(); for line in layout.lines() { for glyph_run in line.glyph_runs() { @@ -44,7 +44,7 @@ pub fn render_text(builder: &mut SceneBuilder, transform: Affine, layout: &Layou let gy = y - glyph.y; let xform = Affine::translate((gx as f64, gy as f64)) * Affine::scale_non_uniform(1.0, -1.0); - builder.append(&fragment, Some(transform * xform)); + scene.append(&fragment, Some(transform * xform)); } x += glyph.advance; } diff --git a/examples/edit_text.rs b/examples/edit_text.rs index 66027bb..2505841 100644 --- a/examples/edit_text.rs +++ b/examples/edit_text.rs @@ -14,7 +14,7 @@ use vello::util::{RenderContext, RenderSurface}; use vello::{ kurbo::{Affine, Point, Rect}, peniko::{Brush, Color, Fill}, - RenderParams, RendererOptions, Scene, SceneBuilder, + RenderParams, RendererOptions, Scene, }; use vello::{AaSupport, Renderer}; @@ -229,10 +229,10 @@ impl WindowState { fn render_anim_frame(&mut self) { let (height, width) = self.surface_size(); - let mut sb = SceneBuilder::for_scene(&mut self.scene); + self.scene.reset(); let rect = Rect::from_origin_size(Point::new(0.0, 0.0), Size::new(height as f64, width as f64)); - sb.fill( + self.scene.fill( Fill::NonZero, Affine::IDENTITY, &Brush::Solid(Color::rgb8(255, 255, 255)), @@ -240,7 +240,11 @@ impl WindowState { &rect, ); let doc = self.document.borrow(); - text::render_text(&mut sb, Affine::translate((TEXT_X, TEXT_Y)), &doc.layout); + text::render_text( + &mut self.scene, + Affine::translate((TEXT_X, TEXT_Y)), + &doc.layout, + ); if doc.selection.len() > 0 { let selection_start_x = parley::layout::Cursor::from_position(&doc.layout, doc.selection.min(), true) @@ -254,7 +258,7 @@ impl WindowState { Point::new(selection_start_x, TEXT_Y), Point::new(selection_end_x, TEXT_Y + FONT_SIZE as f64), ); - sb.fill( + self.scene.fill( Fill::NonZero, Affine::IDENTITY, &Brush::Solid(Color::rgba8(0, 0, 255, 100)), @@ -271,7 +275,7 @@ impl WindowState { Point::new(cursor_active_x - 1.0, TEXT_Y), Point::new(cursor_active_x + 1.0, TEXT_Y + FONT_SIZE as f64), ); - sb.fill( + self.scene.fill( Fill::NonZero, Affine::IDENTITY, &Brush::Solid(Color::BLACK), @@ -301,7 +305,7 @@ impl WindowState { TEXT_Y + FONT_SIZE as f64 + 5.0, ), ); - sb.fill( + self.scene.fill( Fill::NonZero, Affine::IDENTITY, &Brush::Solid(Color::rgba8(0, 0, 255, 100)), @@ -310,7 +314,7 @@ impl WindowState { ); } - sb.pop_layer(); + self.scene.pop_layer(); } } diff --git a/examples/pen.rs b/examples/pen.rs index f80aa7a..4aae9b6 100644 --- a/examples/pen.rs +++ b/examples/pen.rs @@ -9,7 +9,7 @@ use vello::util::{RenderContext, RenderSurface}; use vello::{ kurbo::{Affine, BezPath, Point, Rect, Stroke}, peniko::{Brush, Color, Fill}, - RenderParams, RendererOptions, Scene, SceneBuilder, + RenderParams, RendererOptions, Scene, }; use vello::{AaSupport, Renderer}; @@ -270,9 +270,9 @@ pub fn render_anim_frame( pen_state: Option<&PenState>, touch_state: &TouchState, ) { - let mut sb = SceneBuilder::for_scene(scene); + scene.reset(); let rect = Rect::from_origin_size(Point::new(0.0, 0.0), (5000.0, 5000.0)); - sb.fill( + scene.fill( Fill::NonZero, Affine::IDENTITY, &Brush::Solid(Color::rgb8(128, 128, 128)), @@ -287,12 +287,12 @@ pub fn render_anim_frame( (r, r * state.inclination.altitude.to_degrees() / 90.0), state.inclination.azimuth.to_radians() + PI / 2.0, ); - sb.fill(Fill::NonZero, Affine::IDENTITY, Color::BLUE, None, &shape); + scene.fill(Fill::NonZero, Affine::IDENTITY, Color::BLUE, None, &shape); } for (path, color) in touch_state.points.values() { - sb.stroke(&Stroke::default(), Affine::IDENTITY, color, None, path); + scene.stroke(&Stroke::default(), Affine::IDENTITY, color, None, path); } - sb.pop_layer(); + scene.pop_layer(); } diff --git a/examples/shello.rs b/examples/shello.rs index ed7086b..7dd406d 100644 --- a/examples/shello.rs +++ b/examples/shello.rs @@ -8,7 +8,7 @@ use vello::util::{RenderContext, RenderSurface}; use vello::{ kurbo::{Affine, PathEl, Point, Rect, Stroke}, peniko::{Brush, Color, Fill, Mix}, - RenderParams, RendererOptions, Scene, SceneBuilder, + RenderParams, RendererOptions, Scene, }; use vello::{AaSupport, Renderer}; @@ -218,9 +218,9 @@ impl WinHandler for WindowState { } pub fn render_anim_frame(scene: &mut Scene, fcx: &mut FontContext, i: u64) { - let mut sb = SceneBuilder::for_scene(scene); + scene.reset(); let rect = Rect::from_origin_size(Point::new(0.0, 0.0), (1000.0, 1000.0)); - sb.fill( + scene.fill( Fill::NonZero, Affine::IDENTITY, &Brush::Solid(Color::rgb8(128, 128, 128)), @@ -247,21 +247,21 @@ pub fn render_anim_frame(scene: &mut Scene, fcx: &mut FontContext, i: u64) { ))); let mut layout = layout_builder.build(); layout.break_all_lines(None, parley::layout::Alignment::Start); - text::render_text(&mut sb, Affine::translate((100.0, 400.0)), &layout); + text::render_text(scene, Affine::translate((100.0, 400.0)), &layout); let th = (std::f64::consts::PI / 180.0) * (i as f64); let center = Point::new(500.0, 500.0); let mut p1 = center; p1.x += 400.0 * th.cos(); p1.y += 400.0 * th.sin(); - sb.stroke( + scene.stroke( &Stroke::new(5.0), Affine::IDENTITY, &Brush::Solid(Color::rgb8(128, 0, 0)), None, &[PathEl::MoveTo(center), PathEl::LineTo(p1)], ); - sb.fill( + scene.fill( Fill::NonZero, Affine::translate((150.0, 150.0)) * Affine::scale(0.2), Color::RED, @@ -269,20 +269,20 @@ pub fn render_anim_frame(scene: &mut Scene, fcx: &mut FontContext, i: u64) { &rect, ); let alpha = (i as f64 * 0.03).sin() as f32 * 0.5 + 0.5; - sb.push_layer(Mix::Normal, alpha, Affine::IDENTITY, &rect); - sb.fill( + scene.push_layer(Mix::Normal, alpha, Affine::IDENTITY, &rect); + scene.fill( Fill::NonZero, Affine::translate((100.0, 100.0)) * Affine::scale(0.2), Color::BLUE, None, &rect, ); - sb.fill( + scene.fill( Fill::NonZero, Affine::translate((200.0, 200.0)) * Affine::scale(0.2), Color::GREEN, None, &rect, ); - sb.pop_layer(); + scene.pop_layer(); }