diff options
author | 2024-03-24 08:04:28 +0100 | |
---|---|---|
committer | 2024-03-24 08:04:28 +0100 | |
commit | 4f5b63f1f4cd7d3ab72289c697f4abc767114eca (patch) | |
tree | 876f9502936b24f63ef21bb2b41e16b222750444 /tiny_skia | |
parent | 441e9237cd1c9c9b61d9b144b5b4dafa236ace28 (diff) | |
download | iced-4f5b63f1f4cd7d3ab72289c697f4abc767114eca.tar.gz iced-4f5b63f1f4cd7d3ab72289c697f4abc767114eca.tar.bz2 iced-4f5b63f1f4cd7d3ab72289c697f4abc767114eca.zip |
Reintroduce backend selection through `ICED_BACKEND` env var
Diffstat (limited to 'tiny_skia')
-rw-r--r-- | tiny_skia/src/window/compositor.rs | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/tiny_skia/src/window/compositor.rs b/tiny_skia/src/window/compositor.rs index 0c08097b..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::{self, 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 { @@ -28,11 +28,22 @@ impl crate::graphics::Compositor for Compositor { type Renderer = Renderer; type Surface = Surface; - fn new<W: compositor::Window>( + async fn with_backend<W: compositor::Window>( settings: graphics::Settings, compatible_window: W, - ) -> impl Future<Output = Result<Self, Error>> { - future::ready(Ok(new(settings.into(), 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 { |