Gate Custom variants in iced_renderer behind custom feature
This commit is contained in:
parent
188db4da48
commit
9171df1e35
5 changed files with 34 additions and 9 deletions
|
|
@ -19,6 +19,7 @@ tracing = ["iced_wgpu?/tracing"]
|
||||||
web-colors = ["iced_wgpu?/web-colors"]
|
web-colors = ["iced_wgpu?/web-colors"]
|
||||||
webgl = ["iced_wgpu?/webgl"]
|
webgl = ["iced_wgpu?/webgl"]
|
||||||
fira-sans = ["iced_graphics/fira-sans"]
|
fira-sans = ["iced_graphics/fira-sans"]
|
||||||
|
custom = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
iced_graphics.workspace = true
|
iced_graphics.workspace = true
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::core::Color;
|
use crate::core::Color;
|
||||||
use crate::custom;
|
|
||||||
use crate::graphics::compositor::{Information, SurfaceError, Window};
|
use crate::graphics::compositor::{Information, SurfaceError, Window};
|
||||||
use crate::graphics::{Error, Viewport};
|
use crate::graphics::{Error, Viewport};
|
||||||
use crate::{Renderer, Settings};
|
use crate::{Renderer, Settings};
|
||||||
|
|
@ -11,14 +10,16 @@ pub enum Compositor {
|
||||||
TinySkia(iced_tiny_skia::window::Compositor),
|
TinySkia(iced_tiny_skia::window::Compositor),
|
||||||
#[cfg(feature = "wgpu")]
|
#[cfg(feature = "wgpu")]
|
||||||
Wgpu(iced_wgpu::window::Compositor),
|
Wgpu(iced_wgpu::window::Compositor),
|
||||||
Custom(Box<dyn custom::Compositor>),
|
#[cfg(feature = "custom")]
|
||||||
|
Custom(Box<dyn crate::custom::Compositor>),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Surface {
|
pub enum Surface {
|
||||||
TinySkia(iced_tiny_skia::window::Surface),
|
TinySkia(iced_tiny_skia::window::Surface),
|
||||||
#[cfg(feature = "wgpu")]
|
#[cfg(feature = "wgpu")]
|
||||||
Wgpu(iced_wgpu::window::Surface<'static>),
|
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 {
|
impl crate::graphics::Compositor for Compositor {
|
||||||
|
|
@ -59,6 +60,7 @@ impl crate::graphics::Compositor for Compositor {
|
||||||
Compositor::Wgpu(compositor) => {
|
Compositor::Wgpu(compositor) => {
|
||||||
Renderer::Wgpu(compositor.create_renderer())
|
Renderer::Wgpu(compositor.create_renderer())
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "custom")]
|
||||||
Compositor::Custom(compositor) => {
|
Compositor::Custom(compositor) => {
|
||||||
Renderer::Custom(compositor.create_renderer())
|
Renderer::Custom(compositor.create_renderer())
|
||||||
}
|
}
|
||||||
|
|
@ -79,6 +81,7 @@ impl crate::graphics::Compositor for Compositor {
|
||||||
Self::Wgpu(compositor) => {
|
Self::Wgpu(compositor) => {
|
||||||
Surface::Wgpu(compositor.create_surface(window, width, height))
|
Surface::Wgpu(compositor.create_surface(window, width, height))
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "custom")]
|
||||||
Self::Custom(compositor) => Surface::Custom(
|
Self::Custom(compositor) => Surface::Custom(
|
||||||
compositor.create_surface(Box::new(window), width, height),
|
compositor.create_surface(Box::new(window), width, height),
|
||||||
),
|
),
|
||||||
|
|
@ -99,6 +102,7 @@ impl crate::graphics::Compositor for Compositor {
|
||||||
(Self::Wgpu(compositor), Surface::Wgpu(surface)) => {
|
(Self::Wgpu(compositor), Surface::Wgpu(surface)) => {
|
||||||
compositor.configure_surface(surface, width, height);
|
compositor.configure_surface(surface, width, height);
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "custom")]
|
||||||
(Self::Custom(compositor), Surface::Custom(surface)) => {
|
(Self::Custom(compositor), Surface::Custom(surface)) => {
|
||||||
compositor.configure_surface(surface, width, height);
|
compositor.configure_surface(surface, width, height);
|
||||||
}
|
}
|
||||||
|
|
@ -114,6 +118,7 @@ impl crate::graphics::Compositor for Compositor {
|
||||||
Self::TinySkia(compositor) => compositor.fetch_information(),
|
Self::TinySkia(compositor) => compositor.fetch_information(),
|
||||||
#[cfg(feature = "wgpu")]
|
#[cfg(feature = "wgpu")]
|
||||||
Self::Wgpu(compositor) => compositor.fetch_information(),
|
Self::Wgpu(compositor) => compositor.fetch_information(),
|
||||||
|
#[cfg(feature = "custom")]
|
||||||
Self::Custom(compositor) => compositor.fetch_information(),
|
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),
|
Self::Custom(compositor),
|
||||||
crate::Renderer::Custom(renderer),
|
crate::Renderer::Custom(renderer),
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ mod cache;
|
||||||
pub use cache::Cache;
|
pub use cache::Cache;
|
||||||
|
|
||||||
use crate::core::{Point, Radians, Rectangle, Size, Transformation, Vector};
|
use crate::core::{Point, Radians, Rectangle, Size, Transformation, Vector};
|
||||||
use crate::custom;
|
|
||||||
use crate::graphics::geometry::{Fill, Path, Stroke, Text};
|
use crate::graphics::geometry::{Fill, Path, Stroke, Text};
|
||||||
use crate::Renderer;
|
use crate::Renderer;
|
||||||
|
|
||||||
|
|
@ -13,6 +12,7 @@ macro_rules! delegate {
|
||||||
Self::TinySkia($name) => $body,
|
Self::TinySkia($name) => $body,
|
||||||
#[cfg(feature = "wgpu")]
|
#[cfg(feature = "wgpu")]
|
||||||
Self::Wgpu($name) => $body,
|
Self::Wgpu($name) => $body,
|
||||||
|
#[cfg(feature = "custom")]
|
||||||
Self::Custom($name) => $body,
|
Self::Custom($name) => $body,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -22,7 +22,8 @@ pub enum Geometry {
|
||||||
TinySkia(iced_tiny_skia::Primitive),
|
TinySkia(iced_tiny_skia::Primitive),
|
||||||
#[cfg(feature = "wgpu")]
|
#[cfg(feature = "wgpu")]
|
||||||
Wgpu(iced_wgpu::Primitive),
|
Wgpu(iced_wgpu::Primitive),
|
||||||
Custom(Box<dyn custom::Geometry>),
|
#[cfg(feature = "custom")]
|
||||||
|
Custom(Box<dyn crate::custom::Geometry>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Geometry {
|
impl Geometry {
|
||||||
|
|
@ -35,6 +36,7 @@ impl Geometry {
|
||||||
Self::Wgpu(primitive) => {
|
Self::Wgpu(primitive) => {
|
||||||
Self::Wgpu(primitive.transform(transformation))
|
Self::Wgpu(primitive.transform(transformation))
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "custom")]
|
||||||
Self::Custom(geometry) => {
|
Self::Custom(geometry) => {
|
||||||
Self::Custom(geometry.transform(transformation))
|
Self::Custom(geometry.transform(transformation))
|
||||||
}
|
}
|
||||||
|
|
@ -46,7 +48,8 @@ pub enum Frame {
|
||||||
TinySkia(iced_tiny_skia::geometry::Frame),
|
TinySkia(iced_tiny_skia::geometry::Frame),
|
||||||
#[cfg(feature = "wgpu")]
|
#[cfg(feature = "wgpu")]
|
||||||
Wgpu(iced_wgpu::geometry::Frame),
|
Wgpu(iced_wgpu::geometry::Frame),
|
||||||
Custom(Box<dyn custom::Frame>),
|
#[cfg(feature = "custom")]
|
||||||
|
Custom(Box<dyn crate::custom::Frame>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Frame {
|
impl Frame {
|
||||||
|
|
@ -59,6 +62,7 @@ impl Frame {
|
||||||
Renderer::Wgpu(_) => {
|
Renderer::Wgpu(_) => {
|
||||||
Frame::Wgpu(iced_wgpu::geometry::Frame::new(size))
|
Frame::Wgpu(iced_wgpu::geometry::Frame::new(size))
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "custom")]
|
||||||
Renderer::Custom(renderer) => {
|
Renderer::Custom(renderer) => {
|
||||||
Frame::Custom(renderer.new_frame(size))
|
Frame::Custom(renderer.new_frame(size))
|
||||||
}
|
}
|
||||||
|
|
@ -169,6 +173,7 @@ impl Frame {
|
||||||
Self::Wgpu(_) => {
|
Self::Wgpu(_) => {
|
||||||
Self::Wgpu(iced_wgpu::geometry::Frame::new(region.size()))
|
Self::Wgpu(iced_wgpu::geometry::Frame::new(region.size()))
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "custom")]
|
||||||
Self::Custom(frame) => Self::Custom(frame.new(region.size())),
|
Self::Custom(frame) => Self::Custom(frame.new(region.size())),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -184,6 +189,7 @@ impl Frame {
|
||||||
(Self::Wgpu(target), Self::Wgpu(frame)) => {
|
(Self::Wgpu(target), Self::Wgpu(frame)) => {
|
||||||
target.clip(frame, origin);
|
target.clip(frame, origin);
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "custom")]
|
||||||
(Self::Custom(target), Self::Custom(frame)) => {
|
(Self::Custom(target), Self::Custom(frame)) => {
|
||||||
target.clip(frame, origin);
|
target.clip(frame, origin);
|
||||||
}
|
}
|
||||||
|
|
@ -223,6 +229,7 @@ impl Frame {
|
||||||
Self::TinySkia(frame) => Geometry::TinySkia(frame.into_primitive()),
|
Self::TinySkia(frame) => Geometry::TinySkia(frame.into_primitive()),
|
||||||
#[cfg(feature = "wgpu")]
|
#[cfg(feature = "wgpu")]
|
||||||
Self::Wgpu(frame) => Geometry::Wgpu(frame.into_primitive()),
|
Self::Wgpu(frame) => Geometry::Wgpu(frame.into_primitive()),
|
||||||
|
#[cfg(feature = "custom")]
|
||||||
Self::Custom(frame) => Geometry::Custom(frame.into_geometry()),
|
Self::Custom(frame) => Geometry::Custom(frame.into_geometry()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::core::Size;
|
use crate::core::Size;
|
||||||
use crate::custom;
|
|
||||||
use crate::geometry::{Frame, Geometry};
|
use crate::geometry::{Frame, Geometry};
|
||||||
use crate::Renderer;
|
use crate::Renderer;
|
||||||
|
|
||||||
|
|
@ -30,7 +29,8 @@ enum Internal {
|
||||||
TinySkia(Arc<iced_tiny_skia::Primitive>),
|
TinySkia(Arc<iced_tiny_skia::Primitive>),
|
||||||
#[cfg(feature = "wgpu")]
|
#[cfg(feature = "wgpu")]
|
||||||
Wgpu(Arc<iced_wgpu::Primitive>),
|
Wgpu(Arc<iced_wgpu::Primitive>),
|
||||||
Custom(Arc<dyn custom::Geometry>),
|
#[cfg(feature = "custom")]
|
||||||
|
Custom(Arc<dyn crate::custom::Geometry>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Cache {
|
impl Cache {
|
||||||
|
|
@ -84,6 +84,7 @@ impl Cache {
|
||||||
content: primitive.clone(),
|
content: primitive.clone(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "custom")]
|
||||||
Internal::Custom(geometry) => {
|
Internal::Custom(geometry) => {
|
||||||
return Geometry::Custom(geometry.clone().load())
|
return Geometry::Custom(geometry.clone().load())
|
||||||
}
|
}
|
||||||
|
|
@ -105,6 +106,7 @@ impl Cache {
|
||||||
Geometry::Wgpu(primitive) => {
|
Geometry::Wgpu(primitive) => {
|
||||||
Internal::Wgpu(Arc::new(primitive))
|
Internal::Wgpu(Arc::new(primitive))
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "custom")]
|
||||||
Geometry::Custom(geometry) => {
|
Geometry::Custom(geometry) => {
|
||||||
Internal::Custom(geometry.cache())
|
Internal::Custom(geometry.cache())
|
||||||
}
|
}
|
||||||
|
|
@ -128,6 +130,7 @@ impl Cache {
|
||||||
content: primitive,
|
content: primitive,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "custom")]
|
||||||
Internal::Custom(geometry) => Geometry::Custom(geometry.load()),
|
Internal::Custom(geometry) => Geometry::Custom(geometry.load()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ pub enum Renderer {
|
||||||
TinySkia(iced_tiny_skia::Renderer),
|
TinySkia(iced_tiny_skia::Renderer),
|
||||||
#[cfg(feature = "wgpu")]
|
#[cfg(feature = "wgpu")]
|
||||||
Wgpu(iced_wgpu::Renderer),
|
Wgpu(iced_wgpu::Renderer),
|
||||||
|
#[cfg(feature = "custom")]
|
||||||
Custom(Box<dyn custom::Renderer>),
|
Custom(Box<dyn custom::Renderer>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -48,6 +49,7 @@ macro_rules! delegate {
|
||||||
Self::TinySkia($name) => $body,
|
Self::TinySkia($name) => $body,
|
||||||
#[cfg(feature = "wgpu")]
|
#[cfg(feature = "wgpu")]
|
||||||
Self::Wgpu($name) => $body,
|
Self::Wgpu($name) => $body,
|
||||||
|
#[cfg(feature = "custom")]
|
||||||
Self::Custom($name) => $body,
|
Self::Custom($name) => $body,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -65,6 +67,7 @@ impl Renderer {
|
||||||
iced_wgpu::primitive::Custom::Mesh(mesh),
|
iced_wgpu::primitive::Custom::Mesh(mesh),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "custom")]
|
||||||
Self::Custom(renderer) => {
|
Self::Custom(renderer) => {
|
||||||
renderer.draw_mesh(mesh);
|
renderer.draw_mesh(mesh);
|
||||||
}
|
}
|
||||||
|
|
@ -102,6 +105,7 @@ impl core::Renderer for Renderer {
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "custom")]
|
||||||
Self::Custom(renderer) => {
|
Self::Custom(renderer) => {
|
||||||
renderer.start_layer();
|
renderer.start_layer();
|
||||||
|
|
||||||
|
|
@ -150,6 +154,7 @@ impl core::Renderer for Renderer {
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "custom")]
|
||||||
Self::Custom(renderer) => {
|
Self::Custom(renderer) => {
|
||||||
renderer.start_transformation();
|
renderer.start_transformation();
|
||||||
|
|
||||||
|
|
@ -300,6 +305,7 @@ impl crate::graphics::geometry::Renderer for Renderer {
|
||||||
}
|
}
|
||||||
#[cfg(feature = "wgpu")]
|
#[cfg(feature = "wgpu")]
|
||||||
crate::Geometry::Wgpu(_) => unreachable!(),
|
crate::Geometry::Wgpu(_) => unreachable!(),
|
||||||
|
#[cfg(feature = "custom")]
|
||||||
crate::Geometry::Custom(_) => unreachable!(),
|
crate::Geometry::Custom(_) => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -312,10 +318,12 @@ impl crate::graphics::geometry::Renderer for Renderer {
|
||||||
renderer.draw_primitive(primitive);
|
renderer.draw_primitive(primitive);
|
||||||
}
|
}
|
||||||
crate::Geometry::TinySkia(_) => unreachable!(),
|
crate::Geometry::TinySkia(_) => unreachable!(),
|
||||||
|
#[cfg(feature = "custom")]
|
||||||
crate::Geometry::Custom(_) => unreachable!(),
|
crate::Geometry::Custom(_) => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "custom")]
|
||||||
Self::Custom(renderer) => {
|
Self::Custom(renderer) => {
|
||||||
for layer in layers {
|
for layer in layers {
|
||||||
match layer {
|
match layer {
|
||||||
|
|
@ -348,6 +356,7 @@ impl iced_wgpu::primitive::pipeline::Renderer for Renderer {
|
||||||
Self::Wgpu(renderer) => {
|
Self::Wgpu(renderer) => {
|
||||||
renderer.draw_pipeline_primitive(bounds, primitive);
|
renderer.draw_pipeline_primitive(bounds, primitive);
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "custom")]
|
||||||
Self::Custom(_renderer) => {
|
Self::Custom(_renderer) => {
|
||||||
log::warn!(
|
log::warn!(
|
||||||
"Custom shader primitive is unavailable with custom renderer."
|
"Custom shader primitive is unavailable with custom renderer."
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue