Skip to content

Commit b84f1e6

Browse files
authored
Version 0.3 (#18)
## 0.3.0 ### Added - Added `vello_svg::Error`, which is returned by new functions that read text into a `usvg::Tree`. - Added `vello_svg::render`, which takes an svg string and renders to a new vello scene. - Added `vello_svg::append`, which takes an svg string and renders to a provided vello scene. - Added `vello_svg::append_with`, which takes an svg string and renders to a provided vello scene with and error handler. - Added `vello_svg::render_tree`, which takes a usvg::Tree and renders to a provided vello scene with and error handler. ### Changed - Updated to vello 0.2 - Renamed `render_tree` to `append_tree` - Renamed `render_tree_with` to `append_tree_with` and removed the `Result<(), E>` return type for the error handler.
1 parent cf6fe55 commit b84f1e6

File tree

14 files changed

+284
-582
lines changed

14 files changed

+284
-582
lines changed

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,27 @@ Subheadings to categorize changes are `added, changed, deprecated, removed, fixe
1010

1111
## Unreleased
1212

13+
## 0.3.0
14+
15+
### Added
16+
17+
- Added `vello_svg::Error`, which is returned by new functions that read text into a `usvg::Tree`.
18+
- Added `vello_svg::render`, which takes an svg string and renders to a new vello scene.
19+
- Added `vello_svg::append`, which takes an svg string and renders to a provided vello scene.
20+
- Added `vello_svg::append_with`, which takes an svg string and renders to a provided vello scene with and error handler.
21+
- Added `vello_svg::render_tree`, which takes a usvg::Tree and renders to a provided vello scene with and error handler.
22+
23+
### Changed
24+
25+
- Updated to vello 0.2
26+
- Updated to usvg 0.42
27+
- Renamed `render_tree` to `append_tree`
28+
- Renamed `render_tree_with` to `append_tree_with` and removed the `Result<(), E>` return type for the error handler.
29+
30+
### Removed
31+
32+
- All code and related profiling (`wgpu_profiler`) used in examples.
33+
1334
## 0.2.0
1435

1536
### Added

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ members = ["examples/with_winit", "examples/run_wasm", "examples/scenes"]
44

55
[workspace.package]
66
edition = "2021"
7-
version = "0.2.0"
7+
version = "0.3.0"
88
license = "Apache-2.0 OR MIT"
99
repository = "https://github.com/linebender/vello_svg"
1010

1111
[workspace.dependencies]
1212
# NOTE: Make sure to keep this in sync with the version badge in README.md
13-
vello = { version = "0.1.0", default-features = false }
13+
vello = { version = "0.2.0", default-features = false }
1414

1515
[package]
1616
name = "vello_svg"
@@ -24,14 +24,14 @@ repository.workspace = true
2424

2525
[dependencies]
2626
vello = { workspace = true }
27-
usvg = "0.41.0"
27+
thiserror = "1.0.61"
28+
usvg = "0.42.0"
2829
image = { version = "0.25.0", default-features = false, features = [
2930
"png",
3031
"jpeg",
3132
"gif",
3233
] }
3334

34-
3535
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
3636
wasm-bindgen-test = "0.3.42"
3737

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
[![Linebender Zulip](https://img.shields.io/badge/Linebender-%23gpu-blue?logo=Zulip)](https://xi.zulipchat.com/#narrow/stream/197075-gpu)
88
[![dependency status](https://deps.rs/repo/github/linebender/vello_svg/status.svg)](https://deps.rs/repo/github/linebender/vello_svg)
99
[![MIT/Apache 2.0](https://img.shields.io/badge/license-MIT%2FApache-blue.svg)](#license)
10-
[![vello version](https://img.shields.io/badge/vello-v0.1.0-purple.svg)](https://crates.io/crates/vello)
11-
10+
[![vello version](https://img.shields.io/badge/vello-v0.2.0-purple.svg)](https://crates.io/crates/vello)\
1211
[![Crates.io](https://img.shields.io/crates/v/vello_svg.svg)](https://crates.io/crates/vello_svg)
1312
[![Docs](https://docs.rs/vello_svg/badge.svg)](https://docs.rs/vello_svg)
1413
[![Build status](https://github.com/linebender/vello_svg/workflows/CI/badge.svg)](https://github.com/linebender/vello_svg/actions)

examples/run_wasm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ repository.workspace = true
66
publish = false
77

88
[dependencies]
9-
cargo-run-wasm = "0.3.2"
9+
cargo-run-wasm = "0.4.0"

examples/run_wasm/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
/// ```
1414
1515
fn main() {
16-
cargo_run_wasm::run_wasm_with_css("body { margin: 0px; }");
16+
cargo_run_wasm::run_wasm_cli_with_css("body { margin: 0px; }");
1717
}

examples/scenes/src/svg.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,14 @@ pub fn svg_function_of<R: AsRef<str>>(
9393
) -> impl FnMut(&mut Scene, &mut SceneParams) {
9494
fn render_svg_contents(name: &str, contents: &str) -> (Scene, Vec2) {
9595
let start = Instant::now();
96-
let fontdb = usvg::fontdb::Database::new();
97-
let svg = usvg::Tree::from_str(contents, &usvg::Options::default(), &fontdb)
96+
let svg = usvg::Tree::from_str(contents, &usvg::Options::default())
9897
.unwrap_or_else(|e| panic!("failed to parse svg file {name}: {e}"));
9998
eprintln!("Parsed svg {name} in {:?}", start.elapsed());
10099
let start = Instant::now();
101-
let mut new_scene = Scene::new();
102-
vello_svg::render_tree(&mut new_scene, &svg);
100+
let scene = vello_svg::render_tree(&svg);
103101
let resolution = Vec2::new(svg.size().width() as f64, svg.size().height() as f64);
104102
eprintln!("Encoded svg {name} in {:?}", start.elapsed());
105-
(new_scene, resolution)
103+
(scene, resolution)
106104
}
107105
let mut cached_scene = None;
108106
#[cfg(not(target_arch = "wasm32"))]

examples/with_winit/Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,18 @@ name = "with_winit_bin"
1717
path = "src/main.rs"
1818

1919
[dependencies]
20-
vello = { workspace = true, features = ["buffer_labels", "wgpu", "wgpu-profiler"] }
20+
vello = { workspace = true, features = ["buffer_labels", "wgpu"] }
2121
scenes = { path = "../scenes" }
2222
anyhow = "1"
2323
clap = { version = "4.5.1", features = ["derive"] }
2424
instant = { version = "0.1.12", features = ["wasm-bindgen"] }
2525
pollster = "0.3"
26-
wgpu-profiler = "0.16"
27-
wgpu = "0.19.3"
2826
winit = "0.29.12"
2927
env_logger = "0.11.2"
3028
log = "0.4.21"
3129

3230
[target.'cfg(not(any(target_arch = "wasm32", target_os = "android")))'.dependencies]
33-
vello = { workspace = true, features = ["hot_reload", "wgpu", "wgpu-profiler"] }
31+
vello = { workspace = true, features = ["hot_reload", "wgpu"] }
3432
notify-debouncer-mini = "0.3"
3533

3634
[target.'cfg(target_os = "android")'.dependencies]

examples/with_winit/src/lib.rs

Lines changed: 12 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2022 the Vello Authors
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
33

4-
use instant::{Duration, Instant};
4+
use instant::Instant;
55
use std::collections::HashSet;
66
use std::num::NonZeroUsize;
77
use std::sync::Arc;
@@ -12,7 +12,7 @@ use scenes::{RobotoText, SceneParams, SceneSet};
1212
use vello::kurbo::{Affine, Vec2};
1313
use vello::peniko::Color;
1414
use vello::util::{RenderContext, RenderSurface};
15-
use vello::{AaConfig, BumpAllocators, Renderer, RendererOptions, Scene};
15+
use vello::{wgpu, AaConfig, BumpAllocators, Renderer, RendererOptions, Scene};
1616

1717
use winit::event_loop::{EventLoop, EventLoopBuilder};
1818
use winit::window::Window;
@@ -83,7 +83,7 @@ fn run(
8383
let mut render_state = {
8484
renderers.resize_with(render_cx.devices.len(), || None);
8585
let id = render_state.surface.dev_id;
86-
let mut renderer = Renderer::new(
86+
let renderer = Renderer::new(
8787
&render_cx.devices[id].device,
8888
RendererOptions {
8989
surface_format: Some(render_state.surface.format),
@@ -95,14 +95,6 @@ fn run(
9595
},
9696
)
9797
.expect("Could create renderer");
98-
renderer
99-
.profiler
100-
.change_settings(wgpu_profiler::GpuProfilerSettings {
101-
enable_timer_queries: false,
102-
enable_debug_groups: false,
103-
..Default::default()
104-
})
105-
.expect("Not setting max_num_pending_frames");
10698
renderers[id] = Some(renderer);
10799
Some(render_state)
108100
};
@@ -145,9 +137,7 @@ fn run(
145137
if let Some(set_scene) = args.scene {
146138
scene_ix = set_scene;
147139
}
148-
let mut profile_stored = None;
149140
let mut prev_scene_ix = scene_ix - 1;
150-
let mut profile_taken = Instant::now();
151141
let mut modifiers = ModifiersState::default();
152142
event_loop
153143
.run(move |event, event_loop| match event {
@@ -211,32 +201,6 @@ fn run(
211201
aa_config_ix.saturating_add(1)
212202
};
213203
}
214-
"p" => {
215-
if let Some(renderer) = &renderers[render_state.surface.dev_id]
216-
{
217-
if let Some(profile_result) = &renderer
218-
.profile_result
219-
.as_ref()
220-
.or(profile_stored.as_ref())
221-
{
222-
// There can be empty results if the required features aren't supported
223-
if !profile_result.is_empty() {
224-
let path = std::path::Path::new("trace.json");
225-
match wgpu_profiler::chrometrace::write_chrometrace(
226-
path,
227-
profile_result,
228-
) {
229-
Ok(()) => {
230-
println!("Wrote trace to path {path:?}");
231-
}
232-
Err(e) => {
233-
eprintln!("Failed to write trace {e}")
234-
}
235-
}
236-
}
237-
}
238-
}
239-
}
240204
"v" => {
241205
vsync_on = !vsync_on;
242206
render_cx.set_present_mode(
@@ -409,26 +373,6 @@ fn run(
409373
vsync_on,
410374
antialiasing_method,
411375
);
412-
if let Some(profiling_result) = renderers[render_state.surface.dev_id]
413-
.as_mut()
414-
.and_then(|it| it.profile_result.take())
415-
{
416-
if profile_stored.is_none()
417-
|| profile_taken.elapsed() > Duration::from_secs(1)
418-
{
419-
profile_stored = Some(profiling_result);
420-
profile_taken = Instant::now();
421-
}
422-
}
423-
if let Some(profiling_result) = profile_stored.as_ref() {
424-
stats::draw_gpu_profiling(
425-
&mut scene,
426-
scene_params.text,
427-
width as f64,
428-
height as f64,
429-
profiling_result,
430-
);
431-
}
432376
}
433377
let surface_texture = render_state
434378
.surface
@@ -534,7 +478,12 @@ fn run(
534478
.take()
535479
.unwrap_or_else(|| create_window(event_loop));
536480
let size = window.inner_size();
537-
let surface_future = render_cx.create_surface(window.clone(), size.width, size.height, wgpu::PresentMode::AutoVsync);
481+
let surface_future = render_cx.create_surface(
482+
window.clone(),
483+
size.width,
484+
size.height,
485+
wgpu::PresentMode::AutoVsync,
486+
);
538487
// We need to block here, in case a Suspended event appeared
539488
let surface =
540489
pollster::block_on(surface_future).expect("Error creating surface");
@@ -550,7 +499,7 @@ fn run(
550499
surface_format: Some(render_state.surface.format),
551500
use_cpu,
552501
antialiasing_support: vello::AaSupport::all(),
553-
num_init_threads: NonZeroUsize::new(args.num_init_threads)
502+
num_init_threads: NonZeroUsize::new(args.num_init_threads),
554503
},
555504
)
556505
.expect("Could create renderer");
@@ -617,7 +566,7 @@ pub fn main() -> Result<()> {
617566
if let Some(scenes) = scenes {
618567
let event_loop = EventLoopBuilder::<UserEvent>::with_user_event().build()?;
619568
#[allow(unused_mut)]
620-
let mut render_cx = RenderContext::new().unwrap();
569+
let mut render_cx = RenderContext::new();
621570
#[cfg(not(target_arch = "wasm32"))]
622571
{
623572
#[cfg(not(target_os = "android"))]
@@ -701,7 +650,7 @@ fn android_main(app: AndroidApp) {
701650
.select_scene_set(|| Args::command())
702651
.unwrap()
703652
.unwrap();
704-
let render_cx = RenderContext::new().unwrap();
653+
let render_cx = RenderContext::new();
705654

706655
run(event_loop, args, scenes, render_cx);
707656
}

0 commit comments

Comments
 (0)