Skip to content

Commit

Permalink
Update resvg version
Browse files Browse the repository at this point in the history
  • Loading branch information
ogoffart committed Sep 4, 2021
1 parent f69ad50 commit b075b40
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions sixtyfps_runtime/rendering_backends/gl/Cargo.toml
Expand Up @@ -36,9 +36,9 @@ once_cell = "1.5"
lyon_path = "0.17.3"
copypasta = { version = "0.7.0", default-features = false }
fontdb = { version = "0.5.1", default-features = false }
resvg = { version= "0.15", optional = true, default-features = false }
usvg = { version= "0.15", optional = true, default-features = false }
tiny-skia = { version= "0.5", optional = true, default-features = false }
resvg = { version= "0.16", optional = true, default-features = false }
usvg = { version= "0.16", optional = true, default-features = false }
tiny-skia = { version= "0.6", optional = true, default-features = false }
derive_more = "0.99.5"

[target.'cfg(target_arch = "wasm32")'.dependencies]
Expand Down
8 changes: 4 additions & 4 deletions sixtyfps_runtime/rendering_backends/gl/svg.rs
Expand Up @@ -12,12 +12,12 @@ LICENSE END */
#[cfg(not(target_arch = "wasm32"))]
pub fn load_from_path(path: &std::path::Path) -> Result<usvg::Tree, std::io::Error> {
let svg_data = std::fs::read(path)?;
usvg::Tree::from_data(&svg_data, &Default::default())
usvg::Tree::from_data(&svg_data, &usvg::Options::default().to_ref())
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))
}

pub fn load_from_data(slice: &[u8]) -> Result<usvg::Tree, usvg::Error> {
usvg::Tree::from_data(slice, &Default::default())
usvg::Tree::from_data(slice, &usvg::Options::default().to_ref())
}

pub fn render(
Expand All @@ -30,10 +30,10 @@ pub fn render(
let size = fit.fit_to(tree.svg_node().size.to_screen_size()).ok_or(usvg::Error::InvalidSize)?;
let mut buffer =
vec![0u8; size.width() as usize * size.height() as usize * tiny_skia::BYTES_PER_PIXEL];
let skya_buffer =
let skia_buffer =
tiny_skia::PixmapMut::from_bytes(buffer.as_mut_slice(), size.width(), size.height())
.ok_or(usvg::Error::InvalidSize)?;
resvg::render(tree, fit, skya_buffer).ok_or(usvg::Error::InvalidSize)?;
resvg::render(tree, fit, skia_buffer).ok_or(usvg::Error::InvalidSize)?;
Ok(image::DynamicImage::ImageRgba8(
image::RgbaImage::from_raw(size.width(), size.height(), buffer)
.ok_or(usvg::Error::InvalidSize)?,
Expand Down

0 comments on commit b075b40

Please sign in to comment.