mirror of
https://github.com/servo/servo.git
synced 2025-08-11 16:35:33 +01:00
Optimise memory allocation in set_webrender_image_key
This commit is contained in:
parent
a5779ad372
commit
da43e35ab2
1 changed files with 1 additions and 0 deletions
|
@ -59,6 +59,7 @@ fn set_webrender_image_key(webrender_api: &webrender_api::RenderApi, image: &mut
|
||||||
pixels::rgba8_premultiply_inplace(bytes.as_mut_slice())
|
pixels::rgba8_premultiply_inplace(bytes.as_mut_slice())
|
||||||
},
|
},
|
||||||
PixelFormat::RGB8 => {
|
PixelFormat::RGB8 => {
|
||||||
|
bytes.reserve(image.bytes.len() / 3 * 4);
|
||||||
for bgr in image.bytes.chunks(3) {
|
for bgr in image.bytes.chunks(3) {
|
||||||
bytes.extend_from_slice(&[bgr[2], bgr[1], bgr[0], 0xff]);
|
bytes.extend_from_slice(&[bgr[2], bgr[1], bgr[0], 0xff]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue