Skip to content

Commit

Permalink
fix: svg
Browse files Browse the repository at this point in the history
  • Loading branch information
wash2 committed Sep 17, 2024
1 parent a5886f8 commit c3b14f1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
10 changes: 9 additions & 1 deletion examples/todos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@ iced.workspace = true
iced_core.workspace = true
# iced.features = ["async-std", "debug", "winit", "a11y", "tiny-skia"]
# TODO(POP): Fix a11y not working with new winit
iced.features = ["tokio", "debug", "winit", "tiny-skia", "wgpu"]
iced.features = [
"tokio",
"debug",
"winit",
"tiny-skia",
"wgpu",
"svg",
"web-colors",
]

once_cell.workspace = true
serde = { version = "1.0", features = ["derive"] }
Expand Down
12 changes: 7 additions & 5 deletions wgpu/src/image/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ impl Pipeline {
8 => Uint32,
),
}],
compilation_options: Default::default(),
},
fragment: Some(wgpu::FragmentState {
module: &shader,
Expand All @@ -173,6 +174,7 @@ impl Pipeline {
}),
write_mask: wgpu::ColorWrites::ALL,
})],
compilation_options: Default::default(),
}),
primitive: wgpu::PrimitiveState {
topology: wgpu::PrimitiveTopology::TriangleList,
Expand Down Expand Up @@ -246,22 +248,22 @@ impl Pipeline {
Image::Raster { .. } => {}

#[cfg(feature = "svg")]
Image::Vector(svg, bounds) => {
Image::Vector { handle, bounds } => {
let size = [bounds.width, bounds.height];

if let Some(atlas_entry) = cache.upload_vector(
device,
encoder,
&svg.handle,
svg.color,
&handle.handle,
handle.color,
size,
scale,
) {
add_instances(
[bounds.x, bounds.y],
size,
f32::from(svg.rotation),
svg.opacity,
f32::from(handle.rotation),
handle.opacity,
true,
atlas_entry,
nearest_instances,
Expand Down
12 changes: 2 additions & 10 deletions wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,17 +546,9 @@ impl core::svg::Renderer for Renderer {
self.image_cache.borrow_mut().measure_svg(handle)
}

fn draw_svg(
&mut self,
handle: core::svg::Handle,
color_filter: Option<Color>,
bounds: Rectangle,
rotation: core::Radians,
opacity: f32,
border_radius: [f32; 4],
) {
fn draw_svg(&mut self, handle: core::svg::Svg, bounds: Rectangle) {
let (layer, transformation) = self.layers.current_mut();
layer.draw_svg(handle, color_filter, bounds);
layer.draw_svg(handle, bounds, transformation);
}
}

Expand Down

0 comments on commit c3b14f1

Please sign in to comment.