summaryrefslogtreecommitdiffstats
path: root/wgpu
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2020-03-31 17:10:28 +0200
committerLibravatar GitHub <noreply@github.com>2020-03-31 17:10:28 +0200
commit291dc728a42c6e888ca6d97eea0f3308591b15a5 (patch)
treea0830fcff2295779cad6afd7b53175ebecca57da /wgpu
parent6e9ab1cd6f5358d323040379e3aadbed2cc4f7f8 (diff)
parentf4776a46bbcc2268c1080b6d655fe63cef42b7fd (diff)
downloadiced-291dc728a42c6e888ca6d97eea0f3308591b15a5.tar.gz
iced-291dc728a42c6e888ca6d97eea0f3308591b15a5.tar.bz2
iced-291dc728a42c6e888ca6d97eea0f3308591b15a5.zip
Merge pull request #247 from hecrj/feature/svg-from-memory
Implement `svg::Handle::from_memory`
Diffstat (limited to '')
-rw-r--r--wgpu/src/image/vector.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/wgpu/src/image/vector.rs b/wgpu/src/image/vector.rs
index bae0f82f..b6776827 100644
--- a/wgpu/src/image/vector.rs
+++ b/wgpu/src/image/vector.rs
@@ -45,9 +45,19 @@ impl Cache {
let opt = resvg::Options::default();
- let svg = match resvg::usvg::Tree::from_file(handle.path(), &opt.usvg) {
- Ok(tree) => Svg::Loaded(tree),
- Err(_) => Svg::NotFound,
+ let svg = match handle.data() {
+ svg::Data::Path(path) => {
+ match resvg::usvg::Tree::from_file(path, &opt.usvg) {
+ Ok(tree) => Svg::Loaded(tree),
+ Err(_) => Svg::NotFound,
+ }
+ }
+ svg::Data::Bytes(bytes) => {
+ match resvg::usvg::Tree::from_data(&bytes, &opt.usvg) {
+ Ok(tree) => Svg::Loaded(tree),
+ Err(_) => Svg::NotFound,
+ }
+ }
};
let _ = self.svgs.insert(handle.id(), svg);