diff options
author | 2024-03-22 05:27:31 +0100 | |
---|---|---|
committer | 2024-03-22 05:27:31 +0100 | |
commit | 1f13a91361258a1607c71f4840a26a6437f88612 (patch) | |
tree | 972fd3bd7afbab9958d16b8475d42ff3e41df484 /renderer | |
parent | bbafeed13d20f2cbd6fc18b949b34596aa0c6c2e (diff) | |
download | iced-1f13a91361258a1607c71f4840a26a6437f88612.tar.gz iced-1f13a91361258a1607c71f4840a26a6437f88612.tar.bz2 iced-1f13a91361258a1607c71f4840a26a6437f88612.zip |
Make `iced_tiny_skia` optional with a `tiny-skia` feature
Diffstat (limited to 'renderer')
-rw-r--r-- | renderer/Cargo.toml | 10 | ||||
-rw-r--r-- | renderer/src/fallback.rs | 29 | ||||
-rw-r--r-- | renderer/src/lib.rs | 53 | ||||
-rw-r--r-- | renderer/src/settings.rs | 5 |
4 files changed, 45 insertions, 52 deletions
diff --git a/renderer/Cargo.toml b/renderer/Cargo.toml index 18e9e8f8..39c19fa3 100644 --- a/renderer/Cargo.toml +++ b/renderer/Cargo.toml @@ -12,18 +12,20 @@ keywords.workspace = true [features] wgpu = ["iced_wgpu"] -image = ["iced_tiny_skia/image", "iced_wgpu?/image"] -svg = ["iced_tiny_skia/svg", "iced_wgpu?/svg"] -geometry = ["iced_graphics/geometry", "iced_tiny_skia/geometry", "iced_wgpu?/geometry"] +tiny-skia = ["iced_tiny_skia"] +image = ["iced_tiny_skia?/image", "iced_wgpu?/image"] +svg = ["iced_tiny_skia?/svg", "iced_wgpu?/svg"] +geometry = ["iced_graphics/geometry", "iced_tiny_skia?/geometry", "iced_wgpu?/geometry"] tracing = ["iced_wgpu?/tracing"] web-colors = ["iced_wgpu?/web-colors"] webgl = ["iced_wgpu?/webgl"] fira-sans = ["iced_graphics/fira-sans"] -custom = [] [dependencies] iced_graphics.workspace = true + iced_tiny_skia.workspace = true +iced_tiny_skia.optional = true iced_wgpu.workspace = true iced_wgpu.optional = true diff --git a/renderer/src/fallback.rs b/renderer/src/fallback.rs index 249da9e9..4431606a 100644 --- a/renderer/src/fallback.rs +++ b/renderer/src/fallback.rs @@ -8,11 +8,7 @@ use crate::graphics; use crate::graphics::compositor; use crate::graphics::mesh; -pub enum Renderer<L, R> -where - L: core::Renderer, - R: core::Renderer, -{ +pub enum Renderer<L, R> { Left(L), Right(R), } @@ -26,29 +22,6 @@ macro_rules! delegate { }; } -impl<L, R> Renderer<L, R> -where - L: core::Renderer, - R: core::Renderer, -{ - #[cfg(feature = "geometry")] - pub fn draw_geometry<Geometry>( - &mut self, - layers: impl IntoIterator<Item = Geometry>, - ) where - L: graphics::geometry::Renderer, - R: graphics::geometry::Renderer, - - Geometry: Into<geometry::Geometry<L::Geometry, R::Geometry>>, - { - use graphics::geometry::Renderer; - - for layer in layers { - <Self as Renderer>::draw_geometry(self, layer.into()); - } - } -} - impl<L, R> core::Renderer for Renderer<L, R> where L: core::Renderer, diff --git a/renderer/src/lib.rs b/renderer/src/lib.rs index f8aa1157..199b431e 100644 --- a/renderer/src/lib.rs +++ b/renderer/src/lib.rs @@ -19,27 +19,40 @@ pub use settings::Settings; /// The default graphics renderer for [`iced`]. /// /// [`iced`]: https://github.com/iced-rs/iced -#[cfg(not(feature = "wgpu"))] -pub type Renderer = iced_tiny_skia::Renderer; - -/// The default graphics renderer for [`iced`]. -/// -/// [`iced`]: https://github.com/iced-rs/iced -#[cfg(feature = "wgpu")] -pub type Renderer = - fallback::Renderer<iced_wgpu::Renderer, iced_tiny_skia::Renderer>; +pub type Renderer = renderer::Renderer; /// The default graphics compositor for [`iced`]. /// /// [`iced`]: https://github.com/iced-rs/iced -#[cfg(not(feature = "wgpu"))] -pub type Compositor = iced_tiny_skia::window::Compositor; - -/// The default graphics renderer for [`iced`]. -/// -/// [`iced`]: https://github.com/iced-rs/iced -#[cfg(feature = "wgpu")] -pub type Compositor = fallback::Compositor< - iced_wgpu::window::Compositor, - iced_tiny_skia::window::Compositor, ->; +pub type Compositor = renderer::Compositor; + +#[cfg(all(feature = "wgpu", feature = "tiny-skia"))] +mod renderer { + pub type Renderer = crate::fallback::Renderer< + iced_wgpu::Renderer, + iced_tiny_skia::Renderer, + >; + + pub type Compositor = crate::fallback::Compositor< + iced_wgpu::window::Compositor, + iced_tiny_skia::window::Compositor, + >; +} + +#[cfg(all(feature = "wgpu", not(feature = "tiny-skia")))] +mod renderer { + pub type Renderer = iced_wgpu::Renderer; + pub type Compositor = iced_wgpu::window::Compositor; +} + +#[cfg(all(not(feature = "wgpu"), feature = "tiny-skia"))] +mod renderer { + pub type Renderer = iced_tiny_skia::Renderer; + pub type Compositor = iced_tiny_skia::window::Compositor; +} + +#[cfg(not(any(feature = "wgpu", feature = "tiny-skia")))] +mod renderer { + pub type Renderer = (); + pub type Compositor = (); +} diff --git a/renderer/src/settings.rs b/renderer/src/settings.rs index 940daa15..27788db9 100644 --- a/renderer/src/settings.rs +++ b/renderer/src/settings.rs @@ -28,6 +28,7 @@ impl Default for Settings { } } +#[cfg(feature = "tiny-skia")] impl From<Settings> for iced_tiny_skia::Settings { fn from(settings: Settings) -> Self { Self { @@ -48,3 +49,7 @@ impl From<Settings> for iced_wgpu::Settings { } } } + +impl From<Settings> for () { + fn from(_settings: Settings) -> Self {} +} |