Use ByteBuf for the canvas messages

The type Vec<u8> is super unefficient to work with in Serde if all you want
to represent is a simple blob.
This commit is contained in:
Anthony Ramine 2018-03-23 18:41:32 +01:00
parent 3ce3f39383
commit ce81420bef
19 changed files with 170 additions and 62 deletions

View file

@ -8,6 +8,7 @@ use euclid::Size2D;
use fnv::FnvHashMap;
use gleam::gl;
use offscreen_gl_context::{GLContext, GLContextAttributes, GLLimits, NativeGLContextMethods};
use serde_bytes::ByteBuf;
use std::thread;
use super::gl_context::{GLContextFactory, GLContextWrapper};
use webrender;
@ -904,10 +905,18 @@ impl WebGLImpl {
//}
}
fn read_pixels(gl: &gl::Gl, x: i32, y: i32, width: i32, height: i32, format: u32, pixel_type: u32,
chan: WebGLSender<Vec<u8>>) {
fn read_pixels(
gl: &gl::Gl,
x: i32,
y: i32,
width: i32,
height: i32,
format: u32,
pixel_type: u32,
chan: WebGLSender<ByteBuf>,
) {
let result = gl.read_pixels(x, y, width, height, format, pixel_type);
chan.send(result).unwrap()
chan.send(result.into()).unwrap()
}
fn active_attrib(gl: &gl::Gl,