summaryrefslogtreecommitdiffstats
path: root/wgpu
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2023-07-12 09:24:35 +0200
committerLibravatar GitHub <noreply@github.com>2023-07-12 09:24:35 +0200
commite96fe1443da5882285729b9e9c041ff34fbe5485 (patch)
treeae76a80eacd961b5d8919e2771f3765ffa95c8be /wgpu
parent9f2be29a286d435b3d1daa8025a74063c50713cb (diff)
parent5dd923402e07578a0002884ac14044fe8762f8b0 (diff)
downloadiced-e96fe1443da5882285729b9e9c041ff34fbe5485.tar.gz
iced-e96fe1443da5882285729b9e9c041ff34fbe5485.tar.bz2
iced-e96fe1443da5882285729b9e9c041ff34fbe5485.zip
Merge pull request #1907 from alec-deason/master
Update `resvg` to `0.35` and `tiny-skia` to `0.10`
Diffstat (limited to 'wgpu')
-rw-r--r--wgpu/Cargo.toml2
-rw-r--r--wgpu/src/image/vector.rs32
2 files changed, 23 insertions, 11 deletions
diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml
index 15db5b5d..22cfad55 100644
--- a/wgpu/Cargo.toml
+++ b/wgpu/Cargo.toml
@@ -55,7 +55,7 @@ version = "1.0"
optional = true
[dependencies.resvg]
-version = "0.32"
+version = "0.35"
optional = true
[dependencies.tracing]
diff --git a/wgpu/src/image/vector.rs b/wgpu/src/image/vector.rs
index 6b9be651..2c03d36b 100644
--- a/wgpu/src/image/vector.rs
+++ b/wgpu/src/image/vector.rs
@@ -114,16 +114,28 @@ impl Cache {
// It would be cool to be able to smooth resize the `svg` example.
let mut img = tiny_skia::Pixmap::new(width, height)?;
- resvg::render(
- tree,
- if width > height {
- resvg::FitTo::Width(width)
- } else {
- resvg::FitTo::Height(height)
- },
- tiny_skia::Transform::default(),
- img.as_mut(),
- )?;
+ let tree_size = tree.size.to_int_size();
+
+ let target_size = if width > height {
+ tree_size.scale_to_width(width)
+ } else {
+ tree_size.scale_to_height(height)
+ };
+
+ let transform = if let Some(target_size) = target_size {
+ let tree_size = tree_size.to_size();
+ let target_size = target_size.to_size();
+
+ tiny_skia::Transform::from_scale(
+ target_size.width() / tree_size.width(),
+ target_size.height() / tree_size.height(),
+ )
+ } else {
+ tiny_skia::Transform::default()
+ };
+
+ resvg::Tree::from_usvg(tree)
+ .render(transform, &mut img.as_mut());
let mut rgba = img.take();