summaryrefslogtreecommitdiffstats
path: root/tiny_skia
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-11-11 07:02:01 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-11-11 07:22:51 +0100
commita5125d6fea824df1191777fe3eb53a2f748208b9 (patch)
tree4c854e4367af13bf02ae0e052a28a95f79437f3a /tiny_skia
parent75c9afc608a4a9ff44d60a8fb6f4a5819f05bf79 (diff)
downloadiced-a5125d6fea824df1191777fe3eb53a2f748208b9.tar.gz
iced-a5125d6fea824df1191777fe3eb53a2f748208b9.tar.bz2
iced-a5125d6fea824df1191777fe3eb53a2f748208b9.zip
Refactor texture image filtering
- Support only `Linear` or `Nearest` - Simplify `Layer` groups - Move `FilterMethod` to `Image` and `image::Viewer`
Diffstat (limited to 'tiny_skia')
-rw-r--r--tiny_skia/src/backend.rs16
-rw-r--r--tiny_skia/src/raster.rs3
2 files changed, 15 insertions, 4 deletions
diff --git a/tiny_skia/src/backend.rs b/tiny_skia/src/backend.rs
index 3c6fe288..f2905b00 100644
--- a/tiny_skia/src/backend.rs
+++ b/tiny_skia/src/backend.rs
@@ -445,7 +445,11 @@ impl Backend {
);
}
#[cfg(feature = "image")]
- Primitive::Image { handle, bounds } => {
+ Primitive::Image {
+ handle,
+ filter_method,
+ bounds,
+ } => {
let physical_bounds = (*bounds + translation) * scale_factor;
if !clip_bounds.intersects(&physical_bounds) {
@@ -461,8 +465,14 @@ impl Backend {
)
.post_scale(scale_factor, scale_factor);
- self.raster_pipeline
- .draw(handle, *bounds, pixels, transform, clip_mask);
+ self.raster_pipeline.draw(
+ handle,
+ *filter_method,
+ *bounds,
+ pixels,
+ transform,
+ clip_mask,
+ );
}
#[cfg(not(feature = "image"))]
Primitive::Image { .. } => {
diff --git a/tiny_skia/src/raster.rs b/tiny_skia/src/raster.rs
index 3f35ee78..5f17ae60 100644
--- a/tiny_skia/src/raster.rs
+++ b/tiny_skia/src/raster.rs
@@ -28,6 +28,7 @@ impl Pipeline {
pub fn draw(
&mut self,
handle: &raster::Handle,
+ filter_method: raster::FilterMethod,
bounds: Rectangle,
pixels: &mut tiny_skia::PixmapMut<'_>,
transform: tiny_skia::Transform,
@@ -39,7 +40,7 @@ impl Pipeline {
let transform = transform.pre_scale(width_scale, height_scale);
- let quality = match handle.filter().mag {
+ let quality = match filter_method {
raster::FilterMethod::Linear => {
tiny_skia::FilterQuality::Bilinear
}