mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Coalesce animated image frame data into a single shared memory region (#37058)
This makes servo use less file descriptors for animated images and avoids the crash described in https://github.com/servo/servo/issues/36792. Doing this also forces the end users to be more explicit about whether they want to deal with all image frames or just the first one. Previously, `Image::bytes` silently returned only the data for the first frame. With this change there's now a `frames` method which returns an iterator over all frames in the image. Testing: No tests - this simply reduces the number of fds used. Servo doesn't currently display animated gifs anyways. Fixes: https://github.com/servo/servo/issues/36792 Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
parent
d5e02d27be
commit
384d8f1ff8
6 changed files with 75 additions and 36 deletions
|
@ -17,7 +17,7 @@ use cssparser::color::clamp_unit_f32;
|
|||
use cssparser::{Parser, ParserInput};
|
||||
use euclid::default::{Point2D, Rect, Size2D, Transform2D};
|
||||
use euclid::vec2;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use ipc_channel::ipc::{self, IpcSender, IpcSharedMemory};
|
||||
use net_traits::image_cache::{ImageCache, ImageResponse};
|
||||
use net_traits::request::CorsSettings;
|
||||
use pixels::PixelFormat;
|
||||
|
@ -350,7 +350,7 @@ impl CanvasState {
|
|||
size.cast(),
|
||||
format,
|
||||
alpha_mode,
|
||||
img.bytes(),
|
||||
IpcSharedMemory::from_bytes(img.first_frame().bytes),
|
||||
))
|
||||
}
|
||||
|
||||
|
|
|
@ -619,7 +619,8 @@ impl WebGLRenderingContext {
|
|||
|
||||
let size = Size2D::new(img.width, img.height);
|
||||
|
||||
TexPixels::new(img.bytes(), size, img.format, false)
|
||||
let data = IpcSharedMemory::from_bytes(img.first_frame().bytes);
|
||||
TexPixels::new(data, size, img.format, false)
|
||||
},
|
||||
// TODO(emilio): Getting canvas data is implemented in CanvasRenderingContext2D,
|
||||
// but we need to refactor it moving it to `HTMLCanvasElement` and support
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue