Draft (very) basic incremental rendering for iced_tiny_skia

This commit is contained in:
Héctor Ramón Jiménez 2023-03-22 00:36:57 +01:00
parent 6fae8bf6cb
commit 0f7abffc0e
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
10 changed files with 286 additions and 92 deletions

View file

@ -6,7 +6,7 @@ use std::path::PathBuf;
use std::sync::Arc;
/// A handle of some image data.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Handle {
id: u64,
data: Data,
@ -156,6 +156,34 @@ impl std::fmt::Debug for Data {
}
}
impl PartialEq for Data {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::Path(a), Self::Path(b)) => a == b,
(Self::Bytes(a), Self::Bytes(b)) => a.as_ref() == b.as_ref(),
(
Self::Rgba {
width: width_a,
height: height_a,
pixels: pixels_a,
},
Self::Rgba {
width: width_b,
height: height_b,
pixels: pixels_b,
},
) => {
width_a == width_b
&& height_a == height_b
&& pixels_a.as_ref() == pixels_b.as_ref()
}
_ => false,
}
}
}
impl Eq for Data {}
/// A [`Renderer`] that can render raster graphics.
///
/// [renderer]: crate::renderer