Make iced_tiny_skia optional with a tiny-skia feature

This commit is contained in:
Héctor Ramón Jiménez 2024-03-22 05:27:31 +01:00
parent bbafeed13d
commit 1f13a91361
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
20 changed files with 157 additions and 91 deletions

View file

@ -15,7 +15,7 @@ pub trait Compositor: Sized {
type Settings: Default;
/// The iced renderer of the backend.
type Renderer: iced_core::Renderer;
type Renderer;
/// The surface of the backend.
type Surface;
@ -122,3 +122,63 @@ pub struct Information {
/// Contains the graphics backend.
pub backend: String,
}
impl Compositor for () {
type Settings = ();
type Renderer = ();
type Surface = ();
async fn new<W: Window + Clone>(
_settings: Self::Settings,
_compatible_window: W,
) -> Result<Self, Error> {
Ok(())
}
fn create_renderer(&self) -> Self::Renderer {}
fn create_surface<W: Window + Clone>(
&mut self,
_window: W,
_width: u32,
_height: u32,
) -> Self::Surface {
}
fn configure_surface(
&mut self,
_surface: &mut Self::Surface,
_width: u32,
_height: u32,
) {
}
fn fetch_information(&self) -> Information {
Information {
adapter: String::from("Null Renderer"),
backend: String::from("Null"),
}
}
fn present<T: AsRef<str>>(
&mut self,
_renderer: &mut Self::Renderer,
_surface: &mut Self::Surface,
_viewport: &Viewport,
_background_color: Color,
_overlay: &[T],
) -> Result<(), SurfaceError> {
Ok(())
}
fn screenshot<T: AsRef<str>>(
&mut self,
_renderer: &mut Self::Renderer,
_surface: &mut Self::Surface,
_viewport: &Viewport,
_background_color: Color,
_overlay: &[T],
) -> Vec<u8> {
vec![]
}
}