diff options
author | 2023-12-02 20:49:47 +0100 | |
---|---|---|
committer | 2023-12-02 20:49:47 +0100 | |
commit | b152ecda63238136f77b6eda3c582fa1eff99737 (patch) | |
tree | 0bf1bc8f2087b533d699aefcf161e794c47fba01 /renderer | |
parent | ea42af766f345715ff7a7168182d3896ee79cfbc (diff) | |
download | iced-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.rs | 47 |
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 => { |