diff --git a/Cargo.lock b/Cargo.lock
index 8d8548591a4..f162070384d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -274,6 +274,7 @@ dependencies = [
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"offscreen_gl_context 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_bytes 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_config 0.0.1",
"webrender 0.57.0 (git+https://github.com/servo/webrender)",
"webrender_api 0.57.0 (git+https://github.com/servo/webrender)",
@@ -292,6 +293,7 @@ dependencies = [
"nonzero 0.0.1",
"offscreen_gl_context 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_bytes 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_config 0.0.1",
"webrender_api 0.57.0 (git+https://github.com/servo/webrender)",
]
@@ -1633,6 +1635,7 @@ dependencies = [
"hashglobe 0.1.0",
"mozjs 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"selectors 0.19.0",
+ "serde_bytes 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_arc 0.1.1",
"smallbitvec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2514,6 +2517,7 @@ dependencies = [
"script_traits 0.0.1",
"selectors 0.19.0",
"serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_bytes 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_allocator 0.0.1",
"servo_arc 0.1.1",
diff --git a/components/canvas/Cargo.toml b/components/canvas/Cargo.toml
index 576f948e4bd..d99b799cea4 100644
--- a/components/canvas/Cargo.toml
+++ b/components/canvas/Cargo.toml
@@ -21,6 +21,7 @@ ipc-channel = "0.10"
log = "0.3.5"
num-traits = "0.1.32"
offscreen_gl_context = { version = "0.15", features = ["serde", "osmesa"] }
+serde_bytes = "0.10"
servo_config = {path = "../config"}
webrender = {git = "https://github.com/servo/webrender"}
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
diff --git a/components/canvas/canvas_paint_thread.rs b/components/canvas/canvas_paint_thread.rs
index b3e6093f6f0..d464f6488e5 100644
--- a/components/canvas/canvas_paint_thread.rs
+++ b/components/canvas/canvas_paint_thread.rs
@@ -13,6 +13,7 @@ use cssparser::RGBA;
use euclid::{Transform2D, Point2D, Vector2D, Rect, Size2D};
use ipc_channel::ipc::{self, IpcSender};
use num_traits::ToPrimitive;
+use serde_bytes::ByteBuf;
use std::borrow::ToOwned;
use std::mem;
use std::sync::Arc;
@@ -145,9 +146,20 @@ impl<'a> CanvasPaintThread<'a> {
Canvas2dMsg::IsPointInPath(x, y, fill_rule, chan) => {
painter.is_point_in_path(x, y, fill_rule, chan)
},
- Canvas2dMsg::DrawImage(imagedata, image_size, dest_rect, source_rect,
- smoothing_enabled) => {
- painter.draw_image(imagedata, image_size, dest_rect, source_rect, smoothing_enabled)
+ Canvas2dMsg::DrawImage(
+ imagedata,
+ image_size,
+ dest_rect,
+ source_rect,
+ smoothing_enabled,
+ ) => {
+ painter.draw_image(
+ imagedata.into(),
+ image_size,
+ dest_rect,
+ source_rect,
+ smoothing_enabled,
+ )
}
Canvas2dMsg::DrawImageSelf(image_size, dest_rect, source_rect, smoothing_enabled) => {
painter.draw_image_self(image_size, dest_rect, source_rect, smoothing_enabled)
@@ -189,8 +201,19 @@ impl<'a> CanvasPaintThread<'a> {
Canvas2dMsg::SetGlobalComposition(op) => painter.set_global_composition(op),
Canvas2dMsg::GetImageData(dest_rect, canvas_size, chan)
=> painter.image_data(dest_rect, canvas_size, chan),
- Canvas2dMsg::PutImageData(imagedata, offset, image_data_size, dirty_rect)
- => painter.put_image_data(imagedata, offset, image_data_size, dirty_rect),
+ Canvas2dMsg::PutImageData(
+ imagedata,
+ offset,
+ image_data_size,
+ dirty_rect,
+ ) => {
+ painter.put_image_data(
+ imagedata.into(),
+ offset,
+ image_data_size,
+ dirty_rect,
+ )
+ }
Canvas2dMsg::SetShadowOffsetX(value) => painter.set_shadow_offset_x(value),
Canvas2dMsg::SetShadowOffsetY(value) => painter.set_shadow_offset_y(value),
Canvas2dMsg::SetShadowBlur(value) => painter.set_shadow_blur(value),
@@ -402,7 +425,12 @@ impl<'a> CanvasPaintThread<'a> {
byte_swap(&mut image_data);
let msg = CanvasMsg::Canvas2d(Canvas2dMsg::DrawImage(
- image_data, source_rect.size, dest_rect, source_rect, smoothing_enabled));
+ image_data.into(),
+ source_rect.size,
+ dest_rect,
+ source_rect,
+ smoothing_enabled,
+ ));
renderer.send(msg).unwrap();
// We acknowledge to the caller here that the data was sent to the
// other canvas so that if JS immediately afterwards try to get the
@@ -578,9 +606,9 @@ impl<'a> CanvasPaintThread<'a> {
}
}
- fn send_pixels(&mut self, chan: IpcSender