diff options
Diffstat (limited to '')
| -rw-r--r-- | renderer/src/compositor.rs | 75 | 
1 files changed, 39 insertions, 36 deletions
| diff --git a/renderer/src/compositor.rs b/renderer/src/compositor.rs index 484d91eb..e31c2bed 100644 --- a/renderer/src/compositor.rs +++ b/renderer/src/compositor.rs @@ -179,47 +179,50 @@ impl Candidate {      fn build<Theme, W: HasRawWindowHandle + HasRawDisplayHandle>(          self,          settings: Settings, -        compatible_window: Option<&W>, +        _compatible_window: Option<&W>,      ) -> Result<(Compositor<Theme>, Renderer<Theme>), Error> {          match self { +            #[cfg(feature = "wgpu")]              Self::Wgpu => { -                if cfg!(feature = "wgpu") { -                    let (compositor, backend) = -                        iced_wgpu::window::compositor::new( -                            iced_wgpu::Settings { -                                default_font: settings.default_font, -                                default_text_size: settings.default_text_size, -                                antialiasing: settings.antialiasing, -                                ..iced_wgpu::Settings::from_env() -                            }, -                            compatible_window, -                        )?; - -                    return Ok(( -                        Compositor::Wgpu(compositor), -                        Renderer::new(crate::Backend::Wgpu(backend)), -                    )); -                } else { -                    panic!("`wgpu` feature was not enabled in `iced_renderer`"); -                } +                let (compositor, backend) = iced_wgpu::window::compositor::new( +                    iced_wgpu::Settings { +                        default_font: settings.default_font, +                        default_text_size: settings.default_text_size, +                        antialiasing: settings.antialiasing, +                        ..iced_wgpu::Settings::from_env() +                    }, +                    _compatible_window, +                )?; + +                Ok(( +                    Compositor::Wgpu(compositor), +                    Renderer::new(crate::Backend::Wgpu(backend)), +                ))              } +            #[cfg(feature = "tiny-skia")]              Self::TinySkia => { -                if cfg!(feature = "tiny-skia") { -                    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, -                            }, -                        ); - -                    Ok(( -                        Compositor::TinySkia(compositor), -                        Renderer::new(crate::Backend::TinySkia(backend)), -                    )) -                } else { -                    panic!("`tiny-skia` feature was not enabled in `iced_renderer`"); -                } +                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, +                        }, +                    ); + +                Ok(( +                    Compositor::TinySkia(compositor), +                    Renderer::new(crate::Backend::TinySkia(backend)), +                )) +            } +            #[cfg(not(feature = "wgpu"))] +            Self::Wgpu => { +                panic!("`wgpu` feature was not enabled in `iced_renderer`") +            } +            #[cfg(not(feature = "tiny-skia"))] +            Self::TinySkia => { +                panic!( +                    "`tiny-skia` feature was not enabled in `iced_renderer`" +                );              }          }      } | 
