Skip to content

Commit

Permalink
chore: Update skia-safe
Browse files Browse the repository at this point in the history
  • Loading branch information
marc2332 committed Nov 17, 2024
1 parent b3528ad commit d2604ab
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ dioxus-hot-reload = { version = "0.5", features = ["file_watcher"], default-feat
dioxus-router = { version = "0.5", default-features = false }
dioxus-clipboard = "0.1"

skia-safe = { path = "C:/Users/mespi/rust-skia-1030/skia-safe", features = ["gl", "textlayout", "svg"] }
skia-safe = { version = "0.80.0", features = ["gl", "textlayout", "svg"] }

gl = "0.14.0"
glutin = "0.32.0"
Expand Down
5 changes: 3 additions & 2 deletions crates/core/src/elements/svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ impl ElementUtils for SvgElement {
let x = area.min_x();
let y = area.min_y();
if let Some(svg_data) = &node_style.svg_data {
let svg_dom = svg::Dom::from_bytes(svg_data.as_slice(), font_manager);
let resource_provider = LocalResourceProvider::new(font_manager);
let svg_dom = svg::Dom::from_bytes(svg_data.as_slice(), resource_provider);
if let Ok(mut svg_dom) = svg_dom {
canvas.save();
canvas.translate((x, y));
svg_dom.set_container_size((area.width() as i32, area.height() as i32));
let root = svg_dom.root();
let mut root = svg_dom.root();
root.set_width(svg::Length::new(100.0, svg::LengthUnit::Percentage));
root.set_height(svg::Length::new(100.0, svg::LengthUnit::Percentage));
svg_dom.render(canvas);
Expand Down
8 changes: 8 additions & 0 deletions crates/engine/src/mocked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1751,3 +1751,11 @@ pub enum EncodedImageFormat {
AVIF = 12,
JPEGXL = 13,
}

struct LocalResourceProvider;

impl LocalResourceProvider {
pub fn new(font_mgr: &FontMgr) -> Self {
unimplemented!("This is mocked")
}
}
1 change: 1 addition & 0 deletions crates/engine/src/skia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub use skia_safe::{
set_resource_cache_total_bytes_limit,
},
path::ArcSize,
resources::LocalResourceProvider,
rrect::Corner,
runtime_effect::Uniform,
surfaces::raster_n32_premul,
Expand Down
2 changes: 1 addition & 1 deletion examples/ferris.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.80.1"
channel = "1.82.0"
profile = "default"

0 comments on commit d2604ab

Please sign in to comment.