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

@ -1,4 +1,5 @@
use crate::alignment;
use crate::image;
use crate::renderer::{self, Renderer};
use crate::text::{self, Text};
use crate::{
@ -7,20 +8,7 @@ use crate::{
use std::borrow::Cow;
/// A renderer that does nothing.
///
/// It can be useful if you are writing tests!
#[derive(Debug, Clone, Copy, Default)]
pub struct Null;
impl Null {
/// Creates a new [`Null`] renderer.
pub fn new() -> Null {
Null
}
}
impl Renderer for Null {
impl Renderer for () {
fn start_layer(&mut self) {}
fn end_layer(&mut self, _bounds: Rectangle) {}
@ -39,7 +27,7 @@ impl Renderer for Null {
}
}
impl text::Renderer for Null {
impl text::Renderer for () {
type Font = Font;
type Paragraph = ();
type Editor = ();
@ -173,3 +161,19 @@ impl text::Editor for () {
) {
}
}
impl image::Renderer for () {
type Handle = ();
fn measure_image(&self, _handle: &Self::Handle) -> Size<u32> {
Size::default()
}
fn draw_image(
&mut self,
_handle: Self::Handle,
_filter_method: image::FilterMethod,
_bounds: Rectangle,
) {
}
}