Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

Commit

Permalink
Bump Kurbo, Vello, and Parley
Browse files Browse the repository at this point in the history
  • Loading branch information
xorgy committed Feb 14, 2024
1 parent ec7e0c5 commit a172562
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 29 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 = "16cd071cd5b642ab81fda37e7dcfe13630755f3c" }
pollster = "0.3.0"
wgpu = "0.18.0"

Expand Down
4 changes: 2 additions & 2 deletions examples/common/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ParleyBrush>) {
pub fn render_text(scene: &mut Scene, transform: Affine, layout: &Layout<ParleyBrush>) {
let mut gcx = GlyphContext::new();
for line in layout.lines() {
for glyph_run in line.glyph_runs() {
Expand All @@ -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;
}
Expand Down
20 changes: 12 additions & 8 deletions examples/edit_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -229,18 +229,22 @@ 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)),
None,
&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)
Expand All @@ -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)),
Expand All @@ -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),
Expand Down Expand Up @@ -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)),
Expand All @@ -310,7 +314,7 @@ impl WindowState {
);
}

sb.pop_layer();
self.scene.pop_layer();
}
}

Expand Down
12 changes: 6 additions & 6 deletions examples/pen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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)),
Expand All @@ -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();
}
20 changes: 10 additions & 10 deletions examples/shello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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)),
Expand All @@ -247,42 +247,42 @@ 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,
None,
&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();
}

0 comments on commit a172562

Please sign in to comment.