From 5cd98f069dea8720bca7748d6c12fa410cbe79b5 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 7 Apr 2024 12:42:12 +0200 Subject: Use built-in `[lints]` table in `Cargo.toml` --- tiny_skia/src/raster.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tiny_skia/src/raster.rs') diff --git a/tiny_skia/src/raster.rs b/tiny_skia/src/raster.rs index 5f17ae60..176b0da9 100644 --- a/tiny_skia/src/raster.rs +++ b/tiny_skia/src/raster.rs @@ -6,6 +6,7 @@ use rustc_hash::{FxHashMap, FxHashSet}; use std::cell::RefCell; use std::collections::hash_map; +#[derive(Debug)] pub struct Pipeline { cache: RefCell, } @@ -68,7 +69,7 @@ impl Pipeline { } } -#[derive(Default)] +#[derive(Debug, Default)] struct Cache { entries: FxHashMap>, hits: FxHashSet, @@ -119,6 +120,7 @@ impl Cache { } } +#[derive(Debug)] struct Entry { width: u32, height: u32, -- cgit From 45254ab88c6ca76759523069c2fb8734de626f02 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 1 May 2024 00:55:49 +0200 Subject: Use `Bytes` as the `Container` of `ImageBuffer` Since we don't need to mutate images once loaded, we avoid unnecessary extra allocations. --- tiny_skia/src/raster.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tiny_skia/src/raster.rs') diff --git a/tiny_skia/src/raster.rs b/tiny_skia/src/raster.rs index 176b0da9..59f1e4d5 100644 --- a/tiny_skia/src/raster.rs +++ b/tiny_skia/src/raster.rs @@ -83,7 +83,7 @@ impl Cache { let id = handle.id(); if let hash_map::Entry::Vacant(entry) = self.entries.entry(id) { - let image = graphics::image::load(handle).ok()?.into_rgba8(); + let image = graphics::image::load(handle).ok()?; let mut buffer = vec![0u32; image.width() as usize * image.height() as usize]; -- cgit From b52c7bb610f593fffc624d461dca17ac50c81626 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 1 May 2024 01:39:43 +0200 Subject: Use an opaque `Id` type for `image::Handle` Hashing pointers is a terrible idea. --- tiny_skia/src/raster.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tiny_skia/src/raster.rs') diff --git a/tiny_skia/src/raster.rs b/tiny_skia/src/raster.rs index 59f1e4d5..907fce7c 100644 --- a/tiny_skia/src/raster.rs +++ b/tiny_skia/src/raster.rs @@ -71,8 +71,8 @@ impl Pipeline { #[derive(Debug, Default)] struct Cache { - entries: FxHashMap>, - hits: FxHashSet, + entries: FxHashMap>, + hits: FxHashSet, } impl Cache { -- cgit From fa9e1d96ea1924b51749b775ea0e67e69bc8a305 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 3 May 2024 13:25:58 +0200 Subject: Introduce dynamic `opacity` support for `Image` and `Svg` --- tiny_skia/src/raster.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tiny_skia/src/raster.rs') diff --git a/tiny_skia/src/raster.rs b/tiny_skia/src/raster.rs index 907fce7c..c40f55b2 100644 --- a/tiny_skia/src/raster.rs +++ b/tiny_skia/src/raster.rs @@ -31,6 +31,7 @@ impl Pipeline { handle: &raster::Handle, filter_method: raster::FilterMethod, bounds: Rectangle, + opacity: f32, pixels: &mut tiny_skia::PixmapMut<'_>, transform: tiny_skia::Transform, clip_mask: Option<&tiny_skia::Mask>, @@ -56,6 +57,7 @@ impl Pipeline { image, &tiny_skia::PixmapPaint { quality, + opacity, ..Default::default() }, transform, -- cgit