summaryrefslogtreecommitdiffstats
path: root/core/src/image.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-03-22 00:36:57 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-04-04 02:08:02 +0200
commit0f7abffc0e94b4bb9f8117db633bfd07d900eb93 (patch)
tree89b6606db2619574369bf8c4a29d5ef0ecb7969c /core/src/image.rs
parent6fae8bf6cbe7155bcee42eaeba68e31564df057c (diff)
downloadiced-0f7abffc0e94b4bb9f8117db633bfd07d900eb93.tar.gz
iced-0f7abffc0e94b4bb9f8117db633bfd07d900eb93.tar.bz2
iced-0f7abffc0e94b4bb9f8117db633bfd07d900eb93.zip
Draft (very) basic incremental rendering for `iced_tiny_skia`
Diffstat (limited to 'core/src/image.rs')
-rw-r--r--core/src/image.rs30
1 files changed, 29 insertions, 1 deletions
diff --git a/core/src/image.rs b/core/src/image.rs
index 70fbade0..618235ef 100644
--- a/core/src/image.rs
+++ b/core/src/image.rs
@@ -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