mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Send IPC receiver for canvas as part of CreateCanvasPaintThread message
This commit is contained in:
parent
22472b4db4
commit
a504c9358b
4 changed files with 13 additions and 18 deletions
|
@ -11,7 +11,7 @@ use azure::azure_hl::SurfacePattern;
|
||||||
use canvas_traits::canvas::*;
|
use canvas_traits::canvas::*;
|
||||||
use cssparser::RGBA;
|
use cssparser::RGBA;
|
||||||
use euclid::{Transform2D, Point2D, Vector2D, Rect, Size2D};
|
use euclid::{Transform2D, Point2D, Vector2D, Rect, Size2D};
|
||||||
use ipc_channel::ipc::{self, IpcSender};
|
use ipc_channel::ipc::{self, IpcSender, IpcReceiver};
|
||||||
use num_traits::ToPrimitive;
|
use num_traits::ToPrimitive;
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
@ -118,9 +118,8 @@ impl<'a> CanvasPaintThread<'a> {
|
||||||
/// communicate with it.
|
/// communicate with it.
|
||||||
pub fn start(size: Size2D<i32>,
|
pub fn start(size: Size2D<i32>,
|
||||||
webrender_api_sender: webrender_api::RenderApiSender,
|
webrender_api_sender: webrender_api::RenderApiSender,
|
||||||
antialias: bool)
|
antialias: bool,
|
||||||
-> IpcSender<CanvasMsg> {
|
receiver: IpcReceiver<CanvasMsg>) {
|
||||||
let (sender, receiver) = ipc::channel::<CanvasMsg>().unwrap();
|
|
||||||
let antialias = if antialias {
|
let antialias = if antialias {
|
||||||
AntialiasMode::Default
|
AntialiasMode::Default
|
||||||
} else {
|
} else {
|
||||||
|
@ -216,8 +215,6 @@ impl<'a> CanvasPaintThread<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).expect("Thread spawning failed");
|
}).expect("Thread spawning failed");
|
||||||
|
|
||||||
sender
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn save_context_state(&mut self) {
|
fn save_context_state(&mut self) {
|
||||||
|
|
|
@ -1235,9 +1235,9 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
|
||||||
self.embedder_proxy.send(EmbedderMsg::HeadParsed(source_top_ctx_id));
|
self.embedder_proxy.send(EmbedderMsg::HeadParsed(source_top_ctx_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FromScriptMsg::CreateCanvasPaintThread(size, sender) => {
|
FromScriptMsg::CreateCanvasPaintThread(size, receiver) => {
|
||||||
debug!("constellation got create-canvas-paint-thread message");
|
debug!("constellation got create-canvas-paint-thread message");
|
||||||
self.handle_create_canvas_paint_thread_msg(&size, sender)
|
self.handle_create_canvas_paint_thread_msg(&size, receiver)
|
||||||
}
|
}
|
||||||
FromScriptMsg::NodeStatus(message) => {
|
FromScriptMsg::NodeStatus(message) => {
|
||||||
debug!("constellation got NodeStatus message");
|
debug!("constellation got NodeStatus message");
|
||||||
|
@ -2264,13 +2264,12 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
|
||||||
fn handle_create_canvas_paint_thread_msg(
|
fn handle_create_canvas_paint_thread_msg(
|
||||||
&mut self,
|
&mut self,
|
||||||
size: &Size2D<i32>,
|
size: &Size2D<i32>,
|
||||||
response_sender: IpcSender<IpcSender<CanvasMsg>>) {
|
receiver: IpcReceiver<CanvasMsg>) {
|
||||||
let webrender_api = self.webrender_api_sender.clone();
|
let webrender_api = self.webrender_api_sender.clone();
|
||||||
let sender = CanvasPaintThread::start(*size, webrender_api,
|
CanvasPaintThread::start(*size,
|
||||||
opts::get().enable_canvas_antialiasing);
|
webrender_api,
|
||||||
if let Err(e) = response_sender.send(sender) {
|
opts::get().enable_canvas_antialiasing,
|
||||||
warn!("Create canvas paint thread response failed ({})", e);
|
receiver);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_webdriver_msg(&mut self, msg: WebDriverCommandMsg) {
|
fn handle_webdriver_msg(&mut self, msg: WebDriverCommandMsg) {
|
||||||
|
|
|
@ -129,11 +129,10 @@ impl CanvasRenderingContext2D {
|
||||||
size: Size2D<i32>)
|
size: Size2D<i32>)
|
||||||
-> CanvasRenderingContext2D {
|
-> CanvasRenderingContext2D {
|
||||||
debug!("Creating new canvas rendering context.");
|
debug!("Creating new canvas rendering context.");
|
||||||
let (sender, receiver) = ipc::channel().unwrap();
|
let (ipc_renderer, receiver) = ipc::channel::<CanvasMsg>().unwrap();
|
||||||
let script_to_constellation_chan = global.script_to_constellation_chan();
|
let script_to_constellation_chan = global.script_to_constellation_chan();
|
||||||
debug!("Asking constellation to create new canvas thread.");
|
debug!("Asking constellation to create new canvas thread.");
|
||||||
script_to_constellation_chan.send(ScriptMsg::CreateCanvasPaintThread(size, sender)).unwrap();
|
script_to_constellation_chan.send(ScriptMsg::CreateCanvasPaintThread(size, receiver)).unwrap();
|
||||||
let ipc_renderer = receiver.recv().unwrap();
|
|
||||||
debug!("Done.");
|
debug!("Done.");
|
||||||
CanvasRenderingContext2D {
|
CanvasRenderingContext2D {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
|
|
|
@ -79,7 +79,7 @@ pub enum ScriptMsg {
|
||||||
ChangeRunningAnimationsState(AnimationState),
|
ChangeRunningAnimationsState(AnimationState),
|
||||||
/// Requests that a new 2D canvas thread be created. (This is done in the constellation because
|
/// Requests that a new 2D canvas thread be created. (This is done in the constellation because
|
||||||
/// 2D canvases may use the GPU and we don't want to give untrusted content access to the GPU.)
|
/// 2D canvases may use the GPU and we don't want to give untrusted content access to the GPU.)
|
||||||
CreateCanvasPaintThread(Size2D<i32>, IpcSender<IpcSender<CanvasMsg>>),
|
CreateCanvasPaintThread(Size2D<i32>, IpcReceiver<CanvasMsg>),
|
||||||
/// Notifies the constellation that this frame has received focus.
|
/// Notifies the constellation that this frame has received focus.
|
||||||
Focus,
|
Focus,
|
||||||
/// Forward an event that was sent to the parent window.
|
/// Forward an event that was sent to the parent window.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue