Skip to content
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

Upgrade usvg from 0.9 -> 0.20 #493

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
955 changes: 816 additions & 139 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion c/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ font-kit = "0.6"
foreign-types = "0.3"
gl = "0.14"
libc = "0.2"
usvg = "0.9"
usvg = "0.20"

[dependencies.pathfinder_canvas]
features = ["pf-text"]
Expand Down
9 changes: 6 additions & 3 deletions c/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ pub unsafe extern "C" fn PFSceneProxyDestroy(scene_proxy: PFSceneProxyRef) {
pub unsafe extern "C" fn PFSVGSceneCreateWithMemory(bytes: *const c_char, byte_len: usize)
-> PFSVGSceneRef {
let data = slice::from_raw_parts(bytes as *const _, byte_len);
let tree = match Tree::from_data(data, &Options::default()) {
let tree = match Tree::from_data(data, &Options::default().to_ref()) {
Ok(tree) => tree,
Err(_) => return ptr::null_mut(),
};
Expand All @@ -817,8 +817,11 @@ pub unsafe extern "C" fn PFSVGSceneCreateWithMemory(bytes: *const c_char, byte_l
#[no_mangle]
pub unsafe extern "C" fn PFSVGSceneCreateWithPath(path: *const c_char) -> PFSVGSceneRef {
let string = to_rust_string(&path, 0);
let path = PathBuf::from(string);
let tree = match Tree::from_file(path, &Options::default()) {
let data = match std::fs::read(PathBuf::from(string)) {
Ok(data) => data,
Err(_) => return ptr::null_mut(),
};
let tree = match Tree::from_data(&data, &Options::default().to_ref()) {
Ok(tree) => tree,
Err(_) => return ptr::null_mut(),
};
Expand Down
2 changes: 1 addition & 1 deletion demo/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pf-gl = []
clap = "2.32"
gl = "0.14"
rayon = "1.0"
usvg = "0.9"
usvg = "0.20"

[dependencies.image]
version = "0.23"
Expand Down
2 changes: 1 addition & 1 deletion demo/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ fn load_scene(resource_loader: &dyn ResourceLoader,
DataPath::Path(ref path) => std::fs::read(path).unwrap().into()
};

if let Ok(tree) = SvgTree::from_data(&data, &UsvgOptions::default()) {
if let Ok(tree) = SvgTree::from_data(&data, &UsvgOptions::default().to_ref()) {
Content::Svg(tree)
} else if let Ok(file) = PdfFile::from_data(data) {
Content::Pdf { file, cache: PdfRenderCache::new(), page_nr: 0 }
Expand Down
2 changes: 1 addition & 1 deletion demo/magicleap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = ["Alan Jeffrey <[email protected]>"]
[dependencies]
gl = "0.14"
rayon = "1.0"
usvg = "0.9"
usvg = "0.20"
egl = "0.2"
log = "0.4"
smallvec = "1.2"
Expand Down
2 changes: 1 addition & 1 deletion svg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ keywords = ["pathfinder", "svg", "vector", "graphics", "gpu"]
[dependencies]
bitflags = "1.0"
hashbrown = "0.7"
usvg = "0.9"
usvg = "0.20"

[dependencies.pathfinder_color]
path = "../color"
Expand Down
2 changes: 1 addition & 1 deletion svg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl SVGScene {
state.transform = state.transform * node_transform;
match *node.borrow() {
NodeKind::Group(ref group) => {
if group.filter.is_some() {
if !group.filter.is_empty() {
self.result_flags.insert(BuildResultFlags::UNSUPPORTED_FILTER_ATTR);
}
if group.mask.is_some() {
Expand Down
2 changes: 1 addition & 1 deletion utils/convert/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ edition = "2018"
[dependencies]
pathfinder_export = { path = "../../export" }
pathfinder_svg = { path = "../../svg" }
usvg = "0.9"
usvg = "0.20"
2 changes: 1 addition & 1 deletion utils/convert/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn main() -> Result<(), Box<dyn Error>> {

let mut data = Vec::new();
File::open(input)?.read_to_end(&mut data)?;
let svg = SVGScene::from_tree(&Tree::from_data(&data, &Options::default()).unwrap());
let svg = SVGScene::from_tree(&Tree::from_data(&data, &Options::default().to_ref()).unwrap());

let scene = &svg.scene;
let mut writer = BufWriter::new(File::create(&output)?);
Expand Down
2 changes: 1 addition & 1 deletion utils/svg-to-skia/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ authors = ["Patrick Walton <[email protected]>"]
edition = "2018"

[dependencies]
usvg = "0.9"
usvg = "0.20"
2 changes: 1 addition & 1 deletion utils/svg-to-skia/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use usvg::{Node, NodeKind, Options, Paint, PathSegment, Tree};

fn main() {
let input_path = env::args().skip(1).next().unwrap();
let tree = Tree::from_file(&input_path, &Options::default()).unwrap();
let tree = Tree::from_data(&std::fs::read(&input_path).unwrap(), &Options::default().to_ref()).unwrap();

println!("#ifndef PAINT_H");
println!("#define PAINT_H");
Expand Down