diff options
| author | 2023-04-26 16:28:47 +0200 | |
|---|---|---|
| committer | 2023-04-26 16:28:47 +0200 | |
| commit | e63cc181bddbdc0a5b9b091cfeee5e4343b3d906 (patch) | |
| tree | 5d442e89638c1e51ef5b91df972c360130a96f26 /renderer | |
| parent | f0fa5f76cb0b0e451b3fc86b1678403c103867e4 (diff) | |
| download | iced-e63cc181bddbdc0a5b9b091cfeee5e4343b3d906.tar.gz iced-e63cc181bddbdc0a5b9b091cfeee5e4343b3d906.tar.bz2 iced-e63cc181bddbdc0a5b9b091cfeee5e4343b3d906.zip | |
Fix `Candidate::build` in `compositor` of `iced_renderer`
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`" +                );              }          }      } | 
