summaryrefslogtreecommitdiffstats
path: root/core/src/image.rs
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 /core/src/image.rs
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 'core/src/image.rs')
-rw-r--r--core/src/image.rs49
1 files changed, 16 insertions, 33 deletions
diff --git a/core/src/image.rs b/core/src/image.rs
index 69f19436..e9675316 100644
--- a/core/src/image.rs
+++ b/core/src/image.rs
@@ -5,31 +5,11 @@ use std::hash::{Hash, Hasher as _};
use std::path::PathBuf;
use std::sync::Arc;
-/// Image filter method
-#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, Hash)]
-pub enum FilterMethod {
- /// Bilinear interpolation
- #[default]
- Linear,
- /// Nearest Neighbor
- Nearest,
-}
-
-/// Texture filter settings
-#[derive(Default, Debug, Clone, PartialEq, Eq, Hash)]
-pub struct TextureFilter {
- /// Filter for scaling the image down.
- pub min: FilterMethod,
- /// Filter for scaling the image up.
- pub mag: FilterMethod,
-}
-
/// A handle of some image data.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Handle {
id: u64,
data: Data,
- filter: TextureFilter,
}
impl Handle {
@@ -76,7 +56,6 @@ impl Handle {
Handle {
id: hasher.finish(),
data,
- filter: TextureFilter::default(),
}
}
@@ -89,17 +68,6 @@ impl Handle {
pub fn data(&self) -> &Data {
&self.data
}
-
- /// Returns a reference to the [`TextureFilter`].
- pub fn filter(&self) -> &TextureFilter {
- &self.filter
- }
-
- /// Sets the texture filtering methods.
- pub fn set_filter(mut self, filter: TextureFilter) -> Self {
- self.filter = filter;
- self
- }
}
impl<T> From<T> for Handle
@@ -196,6 +164,16 @@ impl std::fmt::Debug for Data {
}
}
+/// Image filtering strategy.
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
+pub enum FilterMethod {
+ /// Bilinear interpolation.
+ #[default]
+ Linear,
+ /// Nearest neighbor.
+ Nearest,
+}
+
/// A [`Renderer`] that can render raster graphics.
///
/// [renderer]: crate::renderer
@@ -210,5 +188,10 @@ pub trait Renderer: crate::Renderer {
/// Draws an image with the given [`Handle`] and inside the provided
/// `bounds`.
- fn draw(&mut self, handle: Self::Handle, bounds: Rectangle);
+ fn draw(
+ &mut self,
+ handle: Self::Handle,
+ filter_method: FilterMethod,
+ bounds: Rectangle,
+ );
}