mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Add unique canvas IDs to all canvas operations.
This commit is contained in:
parent
a69eceefc9
commit
8a1590efc6
13 changed files with 334 additions and 155 deletions
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use base64;
|
||||
use canvas_traits::canvas::{CanvasMsg, FromScriptMsg};
|
||||
use canvas_traits::canvas::{CanvasMsg, CanvasId, FromScriptMsg};
|
||||
use canvas_traits::webgl::WebGLVersion;
|
||||
use dom::attr::Attr;
|
||||
use dom::bindings::cell::DomRefCell;
|
||||
|
@ -105,6 +105,7 @@ pub trait LayoutHTMLCanvasElementHelpers {
|
|||
fn data(&self) -> HTMLCanvasData;
|
||||
fn get_width(&self) -> LengthOrPercentageOrAuto;
|
||||
fn get_height(&self) -> LengthOrPercentageOrAuto;
|
||||
fn get_canvas_id_for_layout(&self) -> CanvasId;
|
||||
}
|
||||
|
||||
impl LayoutHTMLCanvasElementHelpers for LayoutDom<HTMLCanvasElement> {
|
||||
|
@ -133,6 +134,7 @@ impl LayoutHTMLCanvasElementHelpers for LayoutDom<HTMLCanvasElement> {
|
|||
source: source,
|
||||
width: width_attr.map_or(DEFAULT_WIDTH, |val| val.as_uint()),
|
||||
height: height_attr.map_or(DEFAULT_HEIGHT, |val| val.as_uint()),
|
||||
canvas_id: self.get_canvas_id_for_layout(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,6 +158,18 @@ impl LayoutHTMLCanvasElementHelpers for LayoutDom<HTMLCanvasElement> {
|
|||
.unwrap_or(LengthOrPercentageOrAuto::Auto)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn get_canvas_id_for_layout(&self) -> CanvasId {
|
||||
unsafe {
|
||||
let canvas = &*self.unsafe_get();
|
||||
if let &Some(CanvasContext::Context2d(ref context)) = canvas.context.borrow_for_layout() {
|
||||
context.to_layout().get_canvas_id()
|
||||
} else {
|
||||
CanvasId(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -261,7 +275,7 @@ impl HTMLCanvasElement {
|
|||
let data = match self.context.borrow().as_ref() {
|
||||
Some(&CanvasContext::Context2d(ref context)) => {
|
||||
let (sender, receiver) = ipc::channel(self.global().time_profiler_chan().clone()).unwrap();
|
||||
let msg = CanvasMsg::FromScript(FromScriptMsg::SendPixels(sender));
|
||||
let msg = CanvasMsg::FromScript(FromScriptMsg::SendPixels(sender), context.get_canvas_id());
|
||||
context.get_ipc_renderer().send(msg).unwrap();
|
||||
|
||||
receiver.recv().unwrap()?.into()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue