Reintroduce backend selection through ICED_BACKEND env var

This commit is contained in:
Héctor Ramón Jiménez 2024-03-24 08:04:28 +01:00
parent 441e9237cd
commit 4f5b63f1f4
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
8 changed files with 196 additions and 83 deletions

View file

@ -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 {