diff options
Diffstat (limited to '')
| -rw-r--r-- | tiny_skia/src/window/compositor.rs | 24 | 
1 files changed, 17 insertions, 7 deletions
diff --git a/tiny_skia/src/window/compositor.rs b/tiny_skia/src/window/compositor.rs index a98825f1..25c57dc1 100644 --- a/tiny_skia/src/window/compositor.rs +++ b/tiny_skia/src/window/compositor.rs @@ -1,11 +1,11 @@  use crate::core::{Color, Rectangle, Size};  use crate::graphics::compositor::{self, Information};  use crate::graphics::damage; -use crate::graphics::{Error, Viewport}; +use crate::graphics::error::{self, Error}; +use crate::graphics::{self, Viewport};  use crate::{Backend, Primitive, Renderer, Settings};  use std::collections::VecDeque; -use std::future::{self, Future};  use std::num::NonZeroU32;  pub struct Compositor { @@ -25,15 +25,25 @@ pub struct Surface {  }  impl crate::graphics::Compositor for Compositor { -    type Settings = Settings;      type Renderer = Renderer;      type Surface = Surface; -    fn new<W: compositor::Window>( -        settings: Self::Settings, +    async fn with_backend<W: compositor::Window>( +        settings: graphics::Settings,          compatible_window: W, -    ) -> impl Future<Output = Result<Self, Error>> { -        future::ready(Ok(new(settings, compatible_window))) +        backend: Option<&str>, +    ) -> Result<Self, Error> { +        match backend { +            None | Some("tiny-skia") | Some("tiny_skia") => { +                Ok(new(settings.into(), compatible_window)) +            } +            Some(backend) => Err(Error::GraphicsAdapterNotFound { +                backend: "tiny-skia", +                reason: error::Reason::DidNotMatch { +                    preferred_backend: backend.to_owned(), +                }, +            }), +        }      }      fn create_renderer(&self) -> Self::Renderer {  | 
