Fix clippy 1.50 lints

This commit is contained in:
Emil Ernerfeldt 2021-02-12 17:40:53 +01:00
parent fc8b27807c
commit 5906bf7a87
3 changed files with 35 additions and 41 deletions

View file

@ -286,18 +286,16 @@ impl Painter {
assert_eq!(size.0 * size.1, pixels.len());
if let egui::TextureId::User(id) = id {
if let Some(user_texture) = self.user_textures.get_mut(id as usize) {
if let Some(user_texture) = user_texture {
let pixels: Vec<Vec<(u8, u8, u8, u8)>> = pixels
.chunks(size.0 as usize)
.map(|row| row.iter().map(|srgba| srgba.to_tuple()).collect())
.collect();
if let Some(Some(user_texture)) = self.user_textures.get_mut(id as usize) {
let pixels: Vec<Vec<(u8, u8, u8, u8)>> = pixels
.chunks(size.0 as usize)
.map(|row| row.iter().map(|srgba| srgba.to_tuple()).collect())
.collect();
*user_texture = UserTexture {
pixels,
gl_texture: None,
};
}
*user_texture = UserTexture {
pixels,
gl_texture: None,
};
}
}
}

View file

@ -181,22 +181,20 @@ impl WebGlPainter {
let index = self.alloc_user_texture_index();
assert_eq!(size.0 * size.1, srgba_pixels.len());
if let Some(user_texture) = self.user_textures.get_mut(index) {
if let Some(user_texture) = user_texture {
let mut pixels: Vec<u8> = Vec::with_capacity(srgba_pixels.len() * 4);
for srgba in srgba_pixels {
pixels.push(srgba.r());
pixels.push(srgba.g());
pixels.push(srgba.b());
pixels.push(srgba.a());
}
*user_texture = UserTexture {
size,
pixels,
gl_texture: None,
};
if let Some(Some(user_texture)) = self.user_textures.get_mut(index) {
let mut pixels: Vec<u8> = Vec::with_capacity(srgba_pixels.len() * 4);
for srgba in srgba_pixels {
pixels.push(srgba.r());
pixels.push(srgba.g());
pixels.push(srgba.b());
pixels.push(srgba.a());
}
*user_texture = UserTexture {
size,
pixels,
gl_texture: None,
};
}
egui::TextureId::User(index as u64)

View file

@ -171,22 +171,20 @@ impl WebGl2Painter {
let index = self.alloc_user_texture_index();
assert_eq!(size.0 * size.1, srgba_pixels.len());
if let Some(user_texture) = self.user_textures.get_mut(index) {
if let Some(user_texture) = user_texture {
let mut pixels: Vec<u8> = Vec::with_capacity(srgba_pixels.len() * 4);
for srgba in srgba_pixels {
pixels.push(srgba.r());
pixels.push(srgba.g());
pixels.push(srgba.b());
pixels.push(srgba.a());
}
*user_texture = UserTexture {
size,
pixels,
gl_texture: None,
};
if let Some(Some(user_texture)) = self.user_textures.get_mut(index) {
let mut pixels: Vec<u8> = Vec::with_capacity(srgba_pixels.len() * 4);
for srgba in srgba_pixels {
pixels.push(srgba.r());
pixels.push(srgba.g());
pixels.push(srgba.b());
pixels.push(srgba.a());
}
*user_texture = UserTexture {
size,
pixels,
gl_texture: None,
};
}
egui::TextureId::User(index as u64)