summaryrefslogtreecommitdiffstats
path: root/renderer
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-21 06:00:55 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-21 06:00:55 +0100
commit9171df1e356530410a7ceadadd78fd3dcf150dfd (patch)
treebdcc3cd85bab674c926307fab6ae79da203dc689 /renderer
parent188db4da48954b95a3fe79bcd22689ffc3a661e0 (diff)
downloadiced-9171df1e356530410a7ceadadd78fd3dcf150dfd.tar.gz
iced-9171df1e356530410a7ceadadd78fd3dcf150dfd.tar.bz2
iced-9171df1e356530410a7ceadadd78fd3dcf150dfd.zip
Gate `Custom` variants in `iced_renderer` behind `custom` feature
Diffstat (limited to 'renderer')
-rw-r--r--renderer/Cargo.toml1
-rw-r--r--renderer/src/compositor.rs13
-rw-r--r--renderer/src/geometry.rs13
-rw-r--r--renderer/src/geometry/cache.rs7
-rw-r--r--renderer/src/lib.rs9
5 files changed, 34 insertions, 9 deletions
diff --git a/renderer/Cargo.toml b/renderer/Cargo.toml
index 5cce2427..18e9e8f8 100644
--- a/renderer/Cargo.toml
+++ b/renderer/Cargo.toml
@@ -19,6 +19,7 @@ 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
diff --git a/renderer/src/compositor.rs b/renderer/src/compositor.rs
index 058fa36d..012ad3c0 100644
--- a/renderer/src/compositor.rs
+++ b/renderer/src/compositor.rs
@@ -1,5 +1,4 @@
use crate::core::Color;
-use crate::custom;
use crate::graphics::compositor::{Information, SurfaceError, Window};
use crate::graphics::{Error, Viewport};
use crate::{Renderer, Settings};
@@ -11,14 +10,16 @@ pub enum Compositor {
TinySkia(iced_tiny_skia::window::Compositor),
#[cfg(feature = "wgpu")]
Wgpu(iced_wgpu::window::Compositor),
- Custom(Box<dyn custom::Compositor>),
+ #[cfg(feature = "custom")]
+ Custom(Box<dyn crate::custom::Compositor>),
}
pub enum Surface {
TinySkia(iced_tiny_skia::window::Surface),
#[cfg(feature = "wgpu")]
Wgpu(iced_wgpu::window::Surface<'static>),
- Custom(Box<dyn custom::Surface>),
+ #[cfg(feature = "custom")]
+ Custom(Box<dyn crate::custom::Surface>),
}
impl crate::graphics::Compositor for Compositor {
@@ -59,6 +60,7 @@ impl crate::graphics::Compositor for Compositor {
Compositor::Wgpu(compositor) => {
Renderer::Wgpu(compositor.create_renderer())
}
+ #[cfg(feature = "custom")]
Compositor::Custom(compositor) => {
Renderer::Custom(compositor.create_renderer())
}
@@ -79,6 +81,7 @@ impl crate::graphics::Compositor for Compositor {
Self::Wgpu(compositor) => {
Surface::Wgpu(compositor.create_surface(window, width, height))
}
+ #[cfg(feature = "custom")]
Self::Custom(compositor) => Surface::Custom(
compositor.create_surface(Box::new(window), width, height),
),
@@ -99,6 +102,7 @@ impl crate::graphics::Compositor for Compositor {
(Self::Wgpu(compositor), Surface::Wgpu(surface)) => {
compositor.configure_surface(surface, width, height);
}
+ #[cfg(feature = "custom")]
(Self::Custom(compositor), Surface::Custom(surface)) => {
compositor.configure_surface(surface, width, height);
}
@@ -114,6 +118,7 @@ impl crate::graphics::Compositor for Compositor {
Self::TinySkia(compositor) => compositor.fetch_information(),
#[cfg(feature = "wgpu")]
Self::Wgpu(compositor) => compositor.fetch_information(),
+ #[cfg(feature = "custom")]
Self::Custom(compositor) => compositor.fetch_information(),
}
}
@@ -158,7 +163,7 @@ impl crate::graphics::Compositor for Compositor {
)
}),
- #[cfg(feature = "wgpu")]
+ #[cfg(feature = "custom")]
(
Self::Custom(compositor),
crate::Renderer::Custom(renderer),
diff --git a/renderer/src/geometry.rs b/renderer/src/geometry.rs
index bf70c7fa..a16cecd5 100644
--- a/renderer/src/geometry.rs
+++ b/renderer/src/geometry.rs
@@ -3,7 +3,6 @@ mod cache;
pub use cache::Cache;
use crate::core::{Point, Radians, Rectangle, Size, Transformation, Vector};
-use crate::custom;
use crate::graphics::geometry::{Fill, Path, Stroke, Text};
use crate::Renderer;
@@ -13,6 +12,7 @@ macro_rules! delegate {
Self::TinySkia($name) => $body,
#[cfg(feature = "wgpu")]
Self::Wgpu($name) => $body,
+ #[cfg(feature = "custom")]
Self::Custom($name) => $body,
}
};
@@ -22,7 +22,8 @@ pub enum Geometry {
TinySkia(iced_tiny_skia::Primitive),
#[cfg(feature = "wgpu")]
Wgpu(iced_wgpu::Primitive),
- Custom(Box<dyn custom::Geometry>),
+ #[cfg(feature = "custom")]
+ Custom(Box<dyn crate::custom::Geometry>),
}
impl Geometry {
@@ -35,6 +36,7 @@ impl Geometry {
Self::Wgpu(primitive) => {
Self::Wgpu(primitive.transform(transformation))
}
+ #[cfg(feature = "custom")]
Self::Custom(geometry) => {
Self::Custom(geometry.transform(transformation))
}
@@ -46,7 +48,8 @@ pub enum Frame {
TinySkia(iced_tiny_skia::geometry::Frame),
#[cfg(feature = "wgpu")]
Wgpu(iced_wgpu::geometry::Frame),
- Custom(Box<dyn custom::Frame>),
+ #[cfg(feature = "custom")]
+ Custom(Box<dyn crate::custom::Frame>),
}
impl Frame {
@@ -59,6 +62,7 @@ impl Frame {
Renderer::Wgpu(_) => {
Frame::Wgpu(iced_wgpu::geometry::Frame::new(size))
}
+ #[cfg(feature = "custom")]
Renderer::Custom(renderer) => {
Frame::Custom(renderer.new_frame(size))
}
@@ -169,6 +173,7 @@ impl Frame {
Self::Wgpu(_) => {
Self::Wgpu(iced_wgpu::geometry::Frame::new(region.size()))
}
+ #[cfg(feature = "custom")]
Self::Custom(frame) => Self::Custom(frame.new(region.size())),
};
@@ -184,6 +189,7 @@ impl Frame {
(Self::Wgpu(target), Self::Wgpu(frame)) => {
target.clip(frame, origin);
}
+ #[cfg(feature = "custom")]
(Self::Custom(target), Self::Custom(frame)) => {
target.clip(frame, origin);
}
@@ -223,6 +229,7 @@ impl Frame {
Self::TinySkia(frame) => Geometry::TinySkia(frame.into_primitive()),
#[cfg(feature = "wgpu")]
Self::Wgpu(frame) => Geometry::Wgpu(frame.into_primitive()),
+ #[cfg(feature = "custom")]
Self::Custom(frame) => Geometry::Custom(frame.into_geometry()),
}
}
diff --git a/renderer/src/geometry/cache.rs b/renderer/src/geometry/cache.rs
index 6a43ddb6..20f73f22 100644
--- a/renderer/src/geometry/cache.rs
+++ b/renderer/src/geometry/cache.rs
@@ -1,5 +1,4 @@
use crate::core::Size;
-use crate::custom;
use crate::geometry::{Frame, Geometry};
use crate::Renderer;
@@ -30,7 +29,8 @@ enum Internal {
TinySkia(Arc<iced_tiny_skia::Primitive>),
#[cfg(feature = "wgpu")]
Wgpu(Arc<iced_wgpu::Primitive>),
- Custom(Arc<dyn custom::Geometry>),
+ #[cfg(feature = "custom")]
+ Custom(Arc<dyn crate::custom::Geometry>),
}
impl Cache {
@@ -84,6 +84,7 @@ impl Cache {
content: primitive.clone(),
});
}
+ #[cfg(feature = "custom")]
Internal::Custom(geometry) => {
return Geometry::Custom(geometry.clone().load())
}
@@ -105,6 +106,7 @@ impl Cache {
Geometry::Wgpu(primitive) => {
Internal::Wgpu(Arc::new(primitive))
}
+ #[cfg(feature = "custom")]
Geometry::Custom(geometry) => {
Internal::Custom(geometry.cache())
}
@@ -128,6 +130,7 @@ impl Cache {
content: primitive,
})
}
+ #[cfg(feature = "custom")]
Internal::Custom(geometry) => Geometry::Custom(geometry.load()),
}
}
diff --git a/renderer/src/lib.rs b/renderer/src/lib.rs
index 70741356..67096115 100644
--- a/renderer/src/lib.rs
+++ b/renderer/src/lib.rs
@@ -39,6 +39,7 @@ pub enum Renderer {
TinySkia(iced_tiny_skia::Renderer),
#[cfg(feature = "wgpu")]
Wgpu(iced_wgpu::Renderer),
+ #[cfg(feature = "custom")]
Custom(Box<dyn custom::Renderer>),
}
@@ -48,6 +49,7 @@ macro_rules! delegate {
Self::TinySkia($name) => $body,
#[cfg(feature = "wgpu")]
Self::Wgpu($name) => $body,
+ #[cfg(feature = "custom")]
Self::Custom($name) => $body,
}
};
@@ -65,6 +67,7 @@ impl Renderer {
iced_wgpu::primitive::Custom::Mesh(mesh),
));
}
+ #[cfg(feature = "custom")]
Self::Custom(renderer) => {
renderer.draw_mesh(mesh);
}
@@ -102,6 +105,7 @@ impl core::Renderer for Renderer {
_ => unreachable!(),
}
}
+ #[cfg(feature = "custom")]
Self::Custom(renderer) => {
renderer.start_layer();
@@ -150,6 +154,7 @@ impl core::Renderer for Renderer {
_ => unreachable!(),
}
}
+ #[cfg(feature = "custom")]
Self::Custom(renderer) => {
renderer.start_transformation();
@@ -300,6 +305,7 @@ impl crate::graphics::geometry::Renderer for Renderer {
}
#[cfg(feature = "wgpu")]
crate::Geometry::Wgpu(_) => unreachable!(),
+ #[cfg(feature = "custom")]
crate::Geometry::Custom(_) => unreachable!(),
}
}
@@ -312,10 +318,12 @@ impl crate::graphics::geometry::Renderer for Renderer {
renderer.draw_primitive(primitive);
}
crate::Geometry::TinySkia(_) => unreachable!(),
+ #[cfg(feature = "custom")]
crate::Geometry::Custom(_) => unreachable!(),
}
}
}
+ #[cfg(feature = "custom")]
Self::Custom(renderer) => {
for layer in layers {
match layer {
@@ -348,6 +356,7 @@ impl iced_wgpu::primitive::pipeline::Renderer for Renderer {
Self::Wgpu(renderer) => {
renderer.draw_pipeline_primitive(bounds, primitive);
}
+ #[cfg(feature = "custom")]
Self::Custom(_renderer) => {
log::warn!(
"Custom shader primitive is unavailable with custom renderer."