Added support for custom shader widget for iced_wgpu backend.

This commit is contained in:
Bingus 2023-09-14 13:58:36 -07:00 committed by Héctor Ramón Jiménez
parent 817f728687
commit 781ef1f94c
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
37 changed files with 2139 additions and 6 deletions

View file

@ -7,6 +7,7 @@ pub mod compositor;
pub mod geometry;
mod settings;
pub mod widget;
pub use iced_graphics as graphics;
pub use iced_graphics::core;
@ -59,6 +60,26 @@ impl<T> Renderer<T> {
}
}
}
pub fn draw_custom<P: widget::shader::Primitive>(
&mut self,
bounds: Rectangle,
primitive: P,
) {
match self {
Renderer::TinySkia(_) => {
log::warn!(
"Custom shader primitive is unavailable with tiny-skia."
);
}
#[cfg(feature = "wgpu")]
Renderer::Wgpu(renderer) => {
renderer.draw_primitive(iced_wgpu::Primitive::Custom(
iced_wgpu::primitive::Custom::shader(bounds, primitive),
))
}
}
}
}
impl<T> core::Renderer for Renderer<T> {