egui_glow: Optimize Painter::set_texture (#1093)
This commit is contained in:
parent
205e04aa18
commit
d9cfeff72c
1 changed files with 5 additions and 7 deletions
|
@ -434,19 +434,17 @@ impl Painter {
|
||||||
"Mismatch between texture size and texel count"
|
"Mismatch between texture size and texel count"
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO: optimize
|
let mut data = Vec::with_capacity(image.pixels.len() * 4);
|
||||||
let pixels: Vec<u8> = image
|
for srgba in &image.pixels {
|
||||||
.pixels
|
data.extend_from_slice(&srgba.to_array());
|
||||||
.iter()
|
}
|
||||||
.flat_map(|srgba| Vec::from(srgba.to_array()))
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
let gl_texture = srgb_texture2d(
|
let gl_texture = srgb_texture2d(
|
||||||
gl,
|
gl,
|
||||||
self.is_webgl_1,
|
self.is_webgl_1,
|
||||||
self.srgb_support,
|
self.srgb_support,
|
||||||
self.texture_filter,
|
self.texture_filter,
|
||||||
&pixels,
|
&data,
|
||||||
image.size[0],
|
image.size[0],
|
||||||
image.size[1],
|
image.size[1],
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue