canvas: Cleanup CanvasData and layout and script messages.

This commit is contained in:
Emilio Cobos Álvarez 2016-11-06 16:50:39 +01:00
parent 1c26f44cbb
commit 2e69143f6b
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
5 changed files with 49 additions and 24 deletions

View file

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use canvas_traits::{CanvasMsg, FromLayoutMsg, CanvasData};
use canvas_traits::{CanvasMsg, FromScriptMsg};
use dom::attr::Attr;
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasRenderingContext2DMethods;
@ -202,16 +202,17 @@ impl HTMLCanvasElement {
let data = if let Some(renderer) = self.ipc_renderer() {
let (sender, receiver) = ipc::channel().unwrap();
let msg = CanvasMsg::FromLayout(FromLayoutMsg::SendData(sender));
let msg = CanvasMsg::FromScript(FromScriptMsg::SendPixels(sender));
renderer.send(msg).unwrap();
match receiver.recv().unwrap() {
CanvasData::Pixels(pixel_data)
=> pixel_data.image_data.to_vec(),
CanvasData::WebGL(_)
// TODO(emilio): Not sure if WebGL canvas is required for 2d spec,
// but I think it's not.
=> return None,
Some(pixels) => pixels,
None => {
// TODO(emilio, #14109): Not sure if WebGL canvas is
// required for 2d spec, but I think it's not, if so, make
// this return a readback from the GL context.
return None;
}
}
} else {
repeat(0xffu8).take((size.height as usize) * (size.width as usize) * 4).collect()