mirror of
https://github.com/servo/servo.git
synced 2025-07-25 08:10:21 +01:00
canvas: Cleanup CanvasData and layout and script messages.
This commit is contained in:
parent
1c26f44cbb
commit
2e69143f6b
5 changed files with 49 additions and 24 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue