Re-organize custom module as pipeline module

... and move `Shader` widget to `iced_widget` crate
This commit is contained in:
Héctor Ramón Jiménez 2023-11-14 12:49:49 +01:00
parent 2dda9132cd
commit 9489e29e66
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
14 changed files with 246 additions and 197 deletions

View file

@ -1,13 +1,15 @@
#![forbid(rust_2018_idioms)]
#![deny(unsafe_code, unused_results, rustdoc::broken_intra_doc_links)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#[cfg(feature = "wgpu")]
pub use iced_wgpu as wgpu;
pub mod compositor;
#[cfg(feature = "geometry")]
pub mod geometry;
mod settings;
pub mod widget;
pub use iced_graphics as graphics;
pub use iced_graphics::core;
@ -60,26 +62,6 @@ 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> {
@ -292,3 +274,23 @@ impl<T> crate::graphics::geometry::Renderer for Renderer<T> {
}
}
}
#[cfg(feature = "wgpu")]
impl<T> iced_wgpu::primitive::pipeline::Renderer for Renderer<T> {
fn draw_pipeline_primitive(
&mut self,
bounds: Rectangle,
primitive: impl wgpu::primitive::pipeline::Primitive,
) {
match self {
Self::TinySkia(_renderer) => {
log::warn!(
"Custom shader primitive is unavailable with tiny-skia."
);
}
Self::Wgpu(renderer) => {
renderer.draw_pipeline_primitive(bounds, primitive);
}
}
}
}