mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Reuse input vector for LUMINANCE_ALPHA/HALF_FLOAT
This commit is contained in:
parent
7e7441749b
commit
e1486f7d71
1 changed files with 6 additions and 5 deletions
|
@ -4178,12 +4178,13 @@ fn rgba8_image_to_tex_image_data(
|
||||||
pixels
|
pixels
|
||||||
},
|
},
|
||||||
(TexFormat::LuminanceAlpha, TexDataType::HalfFloat) => {
|
(TexFormat::LuminanceAlpha, TexDataType::HalfFloat) => {
|
||||||
let mut data = Vec::<u8>::with_capacity(pixel_count * 8);
|
for rgba8 in pixels.chunks_mut(4) {
|
||||||
for rgba8 in pixels.chunks(4) {
|
let lum = f16::from_f32(rgba8[0] as f32).as_bits();
|
||||||
data.write_u16::<NativeEndian>(f16::from_f32(rgba8[0] as f32).as_bits()).unwrap();
|
let a = f16::from_f32(rgba8[3] as f32).as_bits();
|
||||||
data.write_u16::<NativeEndian>(f16::from_f32(rgba8[3] as f32).as_bits()).unwrap();
|
NativeEndian::write_u16(&mut rgba8[0..2], lum);
|
||||||
|
NativeEndian::write_u16(&mut rgba8[2..4], a);
|
||||||
}
|
}
|
||||||
data
|
pixels
|
||||||
},
|
},
|
||||||
|
|
||||||
// Validation should have ensured that we only hit the
|
// Validation should have ensured that we only hit the
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue