diff options
author | 2023-11-11 21:40:07 +0100 | |
---|---|---|
committer | 2023-11-11 21:40:07 +0100 | |
commit | 178521e8121d6f54dbaf2d0dbeb3892f7555b96a (patch) | |
tree | 92e09caf7fe952a54513424027c7935ec1d9cbed /tiny_skia/src | |
parent | ef015a5e72802c059784e74d611f351df75403c0 (diff) | |
parent | 9d560c813566ba04be3e23ae1b14861365485b57 (diff) | |
download | iced-178521e8121d6f54dbaf2d0dbeb3892f7555b96a.tar.gz iced-178521e8121d6f54dbaf2d0dbeb3892f7555b96a.tar.bz2 iced-178521e8121d6f54dbaf2d0dbeb3892f7555b96a.zip |
Merge pull request #1894 from Remmirad/texture_filtering
Add texture filtering options
Diffstat (limited to 'tiny_skia/src')
-rw-r--r-- | tiny_skia/src/backend.rs | 16 | ||||
-rw-r--r-- | tiny_skia/src/raster.rs | 12 |
2 files changed, 24 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 d13b1167..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,12 +40,21 @@ impl Pipeline { let transform = transform.pre_scale(width_scale, height_scale); + let quality = match filter_method { + raster::FilterMethod::Linear => { + tiny_skia::FilterQuality::Bilinear + } + raster::FilterMethod::Nearest => { + tiny_skia::FilterQuality::Nearest + } + }; + pixels.draw_pixmap( (bounds.x / width_scale) as i32, (bounds.y / height_scale) as i32, image, &tiny_skia::PixmapPaint { - quality: tiny_skia::FilterQuality::Bilinear, + quality, ..Default::default() }, transform, |