diff options
author | 2020-03-31 00:39:18 +0200 | |
---|---|---|
committer | 2020-03-31 00:39:18 +0200 | |
commit | ae009158cc322b69403a2512ac51582062029c99 (patch) | |
tree | bd9d64674e046f743c8688e9246e1605fa3573ed /wgpu/src/image | |
parent | 6e9ab1cd6f5358d323040379e3aadbed2cc4f7f8 (diff) | |
download | iced-ae009158cc322b69403a2512ac51582062029c99.tar.gz iced-ae009158cc322b69403a2512ac51582062029c99.tar.bz2 iced-ae009158cc322b69403a2512ac51582062029c99.zip |
Implement `svg::Handle::from_memory`
Useful if you already have your SVG data in memory.
Diffstat (limited to 'wgpu/src/image')
-rw-r--r-- | wgpu/src/image/vector.rs | 16 |
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); |