summaryrefslogtreecommitdiffstats
path: root/renderer
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-12-02 20:49:47 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-12-02 20:49:47 +0100
commitb152ecda63238136f77b6eda3c582fa1eff99737 (patch)
tree0bf1bc8f2087b533d699aefcf161e794c47fba01 /renderer
parentea42af766f345715ff7a7168182d3896ee79cfbc (diff)
downloadiced-b152ecda63238136f77b6eda3c582fa1eff99737.tar.gz
iced-b152ecda63238136f77b6eda3c582fa1eff99737.tar.bz2
iced-b152ecda63238136f77b6eda3c582fa1eff99737.zip
Separate `Compositor::new` from `Compositor::create_renderer`
Diffstat (limited to 'renderer')
-rw-r--r--renderer/src/compositor.rs47
1 files changed, 15 insertions, 32 deletions
diff --git a/renderer/src/compositor.rs b/renderer/src/compositor.rs
index 5bec1639..9d0ff9ab 100644
--- a/renderer/src/compositor.rs
+++ b/renderer/src/compositor.rs
@@ -26,7 +26,7 @@ impl<Theme> crate::graphics::Compositor for Compositor<Theme> {
fn new<W: HasRawWindowHandle + HasRawDisplayHandle>(
settings: Self::Settings,
compatible_window: Option<&W>,
- ) -> Result<(Self, Self::Renderer), Error> {
+ ) -> Result<Self, Error> {
let candidates =
Candidate::list_from_env().unwrap_or(Candidate::default_list());
@@ -34,9 +34,7 @@ impl<Theme> crate::graphics::Compositor for Compositor<Theme> {
for candidate in candidates {
match candidate.build(settings, compatible_window) {
- Ok((compositor, renderer)) => {
- return Ok((compositor, renderer))
- }
+ Ok(compositor) => return Ok(compositor),
Err(new_error) => {
error = new_error;
}
@@ -46,14 +44,14 @@ impl<Theme> crate::graphics::Compositor for Compositor<Theme> {
Err(error)
}
- fn renderer(&self) -> Self::Renderer {
+ fn create_renderer(&self) -> Self::Renderer {
match self {
Compositor::TinySkia(compositor) => {
- Renderer::TinySkia(compositor.renderer())
+ Renderer::TinySkia(compositor.create_renderer())
}
#[cfg(feature = "wgpu")]
Compositor::Wgpu(compositor) => {
- Renderer::Wgpu(compositor.renderer())
+ Renderer::Wgpu(compositor.create_renderer())
}
}
}
@@ -232,29 +230,21 @@ impl Candidate {
self,
settings: Settings,
_compatible_window: Option<&W>,
- ) -> Result<(Compositor<Theme>, Renderer<Theme>), Error> {
+ ) -> Result<Compositor<Theme>, Error> {
match self {
Self::TinySkia => {
- let (compositor, backend) =
- iced_tiny_skia::window::compositor::new(
- iced_tiny_skia::Settings {
- default_font: settings.default_font,
- default_text_size: settings.default_text_size,
- },
- );
+ let compositor = iced_tiny_skia::window::compositor::new(
+ iced_tiny_skia::Settings {
+ default_font: settings.default_font,
+ default_text_size: settings.default_text_size,
+ },
+ );
- Ok((
- Compositor::TinySkia(compositor),
- Renderer::TinySkia(iced_tiny_skia::Renderer::new(
- backend,
- settings.default_font,
- settings.default_text_size,
- )),
- ))
+ Ok(Compositor::TinySkia(compositor))
}
#[cfg(feature = "wgpu")]
Self::Wgpu => {
- let (compositor, backend) = iced_wgpu::window::compositor::new(
+ let compositor = iced_wgpu::window::compositor::new(
iced_wgpu::Settings {
default_font: settings.default_font,
default_text_size: settings.default_text_size,
@@ -264,14 +254,7 @@ impl Candidate {
_compatible_window,
)?;
- Ok((
- Compositor::Wgpu(compositor),
- Renderer::Wgpu(iced_wgpu::Renderer::new(
- backend,
- settings.default_font,
- settings.default_text_size,
- )),
- ))
+ Ok(Compositor::Wgpu(compositor))
}
#[cfg(not(feature = "wgpu"))]
Self::Wgpu => {