Allow custom renderers in Program and Application

This commit is contained in:
Héctor Ramón Jiménez 2024-03-22 07:09:51 +01:00
parent 4f2f40c68b
commit 5137d655e6
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
19 changed files with 162 additions and 122 deletions

View file

@ -1,4 +1,5 @@
use crate::core::{Font, Pixels};
use crate::graphics;
/// The settings of a [`Backend`].
///
@ -22,3 +23,12 @@ impl Default for Settings {
}
}
}
impl From<graphics::Settings> for Settings {
fn from(settings: graphics::Settings) -> Self {
Self {
default_font: settings.default_font,
default_text_size: settings.default_text_size,
}
}
}

View file

@ -1,7 +1,7 @@
use crate::core::{Color, Rectangle, Size};
use crate::graphics::compositor::{self, Information};
use crate::graphics::damage;
use crate::graphics::{Error, Viewport};
use crate::graphics::{self, Error, Viewport};
use crate::{Backend, Primitive, Renderer, Settings};
use std::collections::VecDeque;
@ -25,15 +25,14 @@ 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,
settings: graphics::Settings,
compatible_window: W,
) -> impl Future<Output = Result<Self, Error>> {
future::ready(Ok(new(settings, compatible_window)))
future::ready(Ok(new(settings.into(), compatible_window)))
}
fn create_renderer(&self) -> Self::Renderer {