mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
canvas: Move to shared memory for images and canvas backing stores.
The idea here is to land this before making images and canvas IPC-safe, because this will shake out bugs relating to the shared memory. There are currently test timeouts that are preventing multiprocess images and canvas from landing, and I believe those are due to the inefficiency of sending large amounts of data in the unoptimized builds we test with. By moving to shared memory, this should drastically reduce the number of copies and `serde` serialization. Under the hood, this uses Mach OOL messages on Mac and temporary memory-mapped files on Linux.
This commit is contained in:
parent
135ef35f6d
commit
626974994a
13 changed files with 54 additions and 20 deletions
|
@ -16,6 +16,7 @@ use std::sync::mpsc::{channel, Sender};
|
|||
use util::vec::byte_swap;
|
||||
use layers::platform::surface::NativeSurface;
|
||||
use offscreen_gl_context::{GLContext, GLContextAttributes, ColorAttachmentType};
|
||||
use ipc_channel::ipc::IpcSharedMemory;
|
||||
|
||||
pub struct WebGLPaintTask {
|
||||
size: Size2D<i32>,
|
||||
|
@ -440,9 +441,11 @@ impl WebGLPaintTask {
|
|||
gl::viewport(x, y, width, height);
|
||||
}
|
||||
|
||||
fn send_pixel_contents(&mut self, chan: Sender<Vec<u8>>) {
|
||||
fn send_pixel_contents(&mut self, chan: Sender<IpcSharedMemory>) {
|
||||
// FIXME(#5652, dmarcos) Instead of a readback strategy we have
|
||||
// to layerize the canvas
|
||||
// to layerize the canvas.
|
||||
// TODO(pcwalton): We'd save a copy if we had an `IpcSharedMemoryBuilder` abstraction that
|
||||
// allowed you to mutate in-place before freezing the object for sending.
|
||||
let width = self.size.width as usize;
|
||||
let height = self.size.height as usize;
|
||||
let mut pixels = gl::read_pixels(0, 0,
|
||||
|
@ -461,7 +464,7 @@ impl WebGLPaintTask {
|
|||
|
||||
// rgba -> bgra
|
||||
byte_swap(&mut pixels);
|
||||
chan.send(pixels).unwrap();
|
||||
chan.send(IpcSharedMemory::from_bytes(&pixels[..])).unwrap();
|
||||
}
|
||||
|
||||
fn send_native_surface(&self, _: Sender<NativeSurface>) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue