Fix clippy + fmt
This commit is contained in:
parent
5759096a4c
commit
4b32a48880
4 changed files with 33 additions and 23 deletions
|
|
@ -11,7 +11,7 @@ pub enum FilterMethod {
|
|||
/// Bilinear interpolation
|
||||
#[default]
|
||||
Linear,
|
||||
/// Nearest Neighbor
|
||||
/// Nearest Neighbor
|
||||
Nearest,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,8 +40,12 @@ impl Pipeline {
|
|||
let transform = transform.pre_scale(width_scale, height_scale);
|
||||
|
||||
let quality = match handle.filter().mag {
|
||||
raster::FilterMethod::Linear => tiny_skia::FilterQuality::Bilinear,
|
||||
raster::FilterMethod::Nearest => tiny_skia::FilterQuality::Nearest,
|
||||
raster::FilterMethod::Linear => {
|
||||
tiny_skia::FilterQuality::Bilinear
|
||||
}
|
||||
raster::FilterMethod::Nearest => {
|
||||
tiny_skia::FilterQuality::Nearest
|
||||
}
|
||||
};
|
||||
|
||||
pixels.draw_pixmap(
|
||||
|
|
@ -49,7 +53,7 @@ impl Pipeline {
|
|||
(bounds.y / height_scale) as i32,
|
||||
image,
|
||||
&tiny_skia::PixmapPaint {
|
||||
quality: quality,
|
||||
quality,
|
||||
..Default::default()
|
||||
},
|
||||
transform,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ mod raster;
|
|||
mod vector;
|
||||
|
||||
use atlas::Atlas;
|
||||
use iced_graphics::core::image::{TextureFilter, FilterMethod};
|
||||
use iced_graphics::core::image::{FilterMethod, TextureFilter};
|
||||
|
||||
use crate::core::{Rectangle, Size};
|
||||
use crate::graphics::Transformation;
|
||||
|
|
@ -39,7 +39,7 @@ pub struct Pipeline {
|
|||
pipeline: wgpu::RenderPipeline,
|
||||
vertices: wgpu::Buffer,
|
||||
indices: wgpu::Buffer,
|
||||
sampler: HashMap<TextureFilter,wgpu::Sampler>,
|
||||
sampler: HashMap<TextureFilter, wgpu::Sampler>,
|
||||
texture: wgpu::BindGroup,
|
||||
texture_version: usize,
|
||||
texture_atlas: Atlas,
|
||||
|
|
@ -144,11 +144,9 @@ impl Pipeline {
|
|||
pub fn new(device: &wgpu::Device, format: wgpu::TextureFormat) -> Self {
|
||||
use wgpu::util::DeviceExt;
|
||||
|
||||
let to_wgpu = |method: FilterMethod| {
|
||||
match method {
|
||||
FilterMethod::Linear => wgpu::FilterMode::Linear,
|
||||
FilterMethod::Nearest => wgpu::FilterMode::Nearest,
|
||||
}
|
||||
let to_wgpu = |method: FilterMethod| match method {
|
||||
FilterMethod::Linear => wgpu::FilterMode::Linear,
|
||||
FilterMethod::Nearest => wgpu::FilterMode::Nearest,
|
||||
};
|
||||
|
||||
let mut sampler = HashMap::new();
|
||||
|
|
@ -156,7 +154,11 @@ impl Pipeline {
|
|||
let filter = [FilterMethod::Linear, FilterMethod::Nearest];
|
||||
for min in 0..filter.len() {
|
||||
for mag in 0..filter.len() {
|
||||
let _ = sampler.insert(TextureFilter {min: filter[min], mag: filter[mag]},
|
||||
let _ = sampler.insert(
|
||||
TextureFilter {
|
||||
min: filter[min],
|
||||
mag: filter[mag],
|
||||
},
|
||||
device.create_sampler(&wgpu::SamplerDescriptor {
|
||||
address_mode_u: wgpu::AddressMode::ClampToEdge,
|
||||
address_mode_v: wgpu::AddressMode::ClampToEdge,
|
||||
|
|
@ -165,12 +167,11 @@ impl Pipeline {
|
|||
min_filter: to_wgpu(filter[min]),
|
||||
mipmap_filter: wgpu::FilterMode::Linear,
|
||||
..Default::default()
|
||||
}
|
||||
));
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let constant_layout =
|
||||
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
|
||||
label: Some("iced_wgpu::image constants layout"),
|
||||
|
|
@ -374,7 +375,8 @@ impl Pipeline {
|
|||
#[cfg(feature = "tracing")]
|
||||
let _ = info_span!("Wgpu::Image", "DRAW").entered();
|
||||
|
||||
let instances: &mut HashMap<TextureFilter,Vec<Instance>> = &mut HashMap::new();
|
||||
let instances: &mut HashMap<TextureFilter, Vec<Instance>> =
|
||||
&mut HashMap::new();
|
||||
|
||||
#[cfg(feature = "image")]
|
||||
let mut raster_cache = self.raster_cache.borrow_mut();
|
||||
|
|
@ -396,7 +398,9 @@ impl Pipeline {
|
|||
[bounds.x, bounds.y],
|
||||
[bounds.width, bounds.height],
|
||||
atlas_entry,
|
||||
instances.entry(handle.filter().clone()).or_insert(Vec::new()),
|
||||
instances
|
||||
.entry(handle.filter().clone())
|
||||
.or_insert(Vec::new()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -424,7 +428,9 @@ impl Pipeline {
|
|||
[bounds.x, bounds.y],
|
||||
size,
|
||||
atlas_entry,
|
||||
instances.entry(TextureFilter::default()).or_insert(Vec::new()),
|
||||
instances
|
||||
.entry(TextureFilter::default())
|
||||
.or_insert(Vec::new()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -462,13 +468,13 @@ impl Pipeline {
|
|||
self.layers.push(Layer::new(
|
||||
device,
|
||||
&self.constant_layout,
|
||||
&self.sampler.get(filter).expect("Sampler is registered"),
|
||||
self.sampler.get(filter).expect("Sampler is registered"),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
let layer = &mut self.layers[self.prepare_layer];
|
||||
layer.prepare(device, queue, &instances, transformation);
|
||||
|
||||
layer.prepare(device, queue, instances, transformation);
|
||||
|
||||
self.prepare_layer += 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use crate::core::{
|
|||
|
||||
use std::hash::Hash;
|
||||
|
||||
pub use image::{Handle, TextureFilter, FilterMethod};
|
||||
pub use image::{FilterMethod, Handle, TextureFilter};
|
||||
|
||||
/// Creates a new [`Viewer`] with the given image `Handle`.
|
||||
pub fn viewer<Handle>(handle: Handle) -> Viewer<Handle> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue