mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Split paint task messages from ScriptMsg
Refs: https://github.com/servo/servo/issues/8592
This commit is contained in:
parent
6ab205a97e
commit
7668fd0503
4 changed files with 50 additions and 15 deletions
|
@ -27,6 +27,7 @@ use layout_traits::{LayoutControlChan, LayoutTaskFactory};
|
||||||
use msg::compositor_msg::Epoch;
|
use msg::compositor_msg::Epoch;
|
||||||
use msg::constellation_msg::AnimationState;
|
use msg::constellation_msg::AnimationState;
|
||||||
use msg::constellation_msg::CompositorMsg as FromCompositorMsg;
|
use msg::constellation_msg::CompositorMsg as FromCompositorMsg;
|
||||||
|
use msg::constellation_msg::PaintMsg as FromPaintMsg;
|
||||||
use msg::constellation_msg::ScriptMsg as FromScriptMsg;
|
use msg::constellation_msg::ScriptMsg as FromScriptMsg;
|
||||||
use msg::constellation_msg::WebDriverCommandMsg;
|
use msg::constellation_msg::WebDriverCommandMsg;
|
||||||
use msg::constellation_msg::{FrameId, PipelineId};
|
use msg::constellation_msg::{FrameId, PipelineId};
|
||||||
|
@ -86,12 +87,18 @@ pub struct Constellation<LTF, STF> {
|
||||||
/// A channel through which compositor messages can be sent to this object.
|
/// A channel through which compositor messages can be sent to this object.
|
||||||
pub compositor_sender: Sender<FromCompositorMsg>,
|
pub compositor_sender: Sender<FromCompositorMsg>,
|
||||||
|
|
||||||
|
/// A channel through which paint task messages can be sent to this object.
|
||||||
|
pub painter_sender: ConstellationChan<FromPaintMsg>,
|
||||||
|
|
||||||
/// Receives messages from scripts.
|
/// Receives messages from scripts.
|
||||||
pub script_receiver: Receiver<FromScriptMsg>,
|
pub script_receiver: Receiver<FromScriptMsg>,
|
||||||
|
|
||||||
/// Receives messages from the compositor
|
/// Receives messages from the compositor
|
||||||
pub compositor_receiver: Receiver<FromCompositorMsg>,
|
pub compositor_receiver: Receiver<FromCompositorMsg>,
|
||||||
|
|
||||||
|
/// Receives messages from paint task.
|
||||||
|
pub painter_receiver: Receiver<FromPaintMsg>,
|
||||||
|
|
||||||
/// A channel (the implementation of which is port-specific) through which messages can be sent
|
/// A channel (the implementation of which is port-specific) through which messages can be sent
|
||||||
/// to the compositor.
|
/// to the compositor.
|
||||||
pub compositor_proxy: Box<CompositorProxy>,
|
pub compositor_proxy: Box<CompositorProxy>,
|
||||||
|
@ -275,16 +282,19 @@ enum ChildProcess {
|
||||||
impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
pub fn start(state: InitialConstellationState) -> Sender<FromCompositorMsg> {
|
pub fn start(state: InitialConstellationState) -> Sender<FromCompositorMsg> {
|
||||||
let (ipc_script_receiver, ipc_script_sender) = ConstellationChan::<FromScriptMsg>::new();
|
let (ipc_script_receiver, ipc_script_sender) = ConstellationChan::<FromScriptMsg>::new();
|
||||||
//let (script_receiver, script_sender) = channel();
|
|
||||||
let script_receiver = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_script_receiver);
|
let script_receiver = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_script_receiver);
|
||||||
let (compositor_sender, compositor_receiver) = channel();
|
let (compositor_sender, compositor_receiver) = channel();
|
||||||
|
let (ipc_painter_receiver, ipc_painter_sender) = ConstellationChan::<FromPaintMsg>::new();
|
||||||
|
let painter_receiver = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_painter_receiver);
|
||||||
let compositor_sender_clone = compositor_sender.clone();
|
let compositor_sender_clone = compositor_sender.clone();
|
||||||
spawn_named("Constellation".to_owned(), move || {
|
spawn_named("Constellation".to_owned(), move || {
|
||||||
let mut constellation: Constellation<LTF, STF> = Constellation {
|
let mut constellation: Constellation<LTF, STF> = Constellation {
|
||||||
script_sender: ipc_script_sender,
|
script_sender: ipc_script_sender,
|
||||||
compositor_sender: compositor_sender_clone,
|
compositor_sender: compositor_sender_clone,
|
||||||
|
painter_sender: ipc_painter_sender,
|
||||||
script_receiver: script_receiver,
|
script_receiver: script_receiver,
|
||||||
compositor_receiver: compositor_receiver,
|
compositor_receiver: compositor_receiver,
|
||||||
|
painter_receiver: painter_receiver,
|
||||||
compositor_proxy: state.compositor_proxy,
|
compositor_proxy: state.compositor_proxy,
|
||||||
devtools_chan: state.devtools_chan,
|
devtools_chan: state.devtools_chan,
|
||||||
resource_task: state.resource_task,
|
resource_task: state.resource_task,
|
||||||
|
@ -357,6 +367,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
id: pipeline_id,
|
id: pipeline_id,
|
||||||
parent_info: parent_info,
|
parent_info: parent_info,
|
||||||
constellation_chan: self.script_sender.clone(),
|
constellation_chan: self.script_sender.clone(),
|
||||||
|
painter_chan: self.painter_sender.clone(),
|
||||||
scheduler_chan: self.scheduler_chan.clone(),
|
scheduler_chan: self.scheduler_chan.clone(),
|
||||||
compositor_proxy: self.compositor_proxy.clone_compositor_proxy(),
|
compositor_proxy: self.compositor_proxy.clone_compositor_proxy(),
|
||||||
devtools_chan: self.devtools_chan.clone(),
|
devtools_chan: self.devtools_chan.clone(),
|
||||||
|
@ -458,17 +469,21 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
fn handle_request(&mut self) -> bool {
|
fn handle_request(&mut self) -> bool {
|
||||||
enum Request {
|
enum Request {
|
||||||
Script(FromScriptMsg),
|
Script(FromScriptMsg),
|
||||||
Compositor(FromCompositorMsg)
|
Compositor(FromCompositorMsg),
|
||||||
|
Paint(FromPaintMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
let request = {
|
let request = {
|
||||||
let receiver_from_script = &self.script_receiver;
|
let receiver_from_script = &self.script_receiver;
|
||||||
let receiver_from_compositor = &self.compositor_receiver;
|
let receiver_from_compositor = &self.compositor_receiver;
|
||||||
|
let receiver_from_paint = &self.painter_receiver;
|
||||||
select! {
|
select! {
|
||||||
msg = receiver_from_script.recv() =>
|
msg = receiver_from_script.recv() =>
|
||||||
Request::Script(msg.unwrap()),
|
Request::Script(msg.unwrap()),
|
||||||
msg = receiver_from_compositor.recv() =>
|
msg = receiver_from_compositor.recv() =>
|
||||||
Request::Compositor(msg.unwrap())
|
Request::Compositor(msg.unwrap()),
|
||||||
|
msg = receiver_from_paint.recv() =>
|
||||||
|
Request::Paint(msg.unwrap())
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -548,6 +563,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
|
|
||||||
|
|
||||||
Request::Script(FromScriptMsg::Failure(Failure { pipeline_id, parent_info })) => {
|
Request::Script(FromScriptMsg::Failure(Failure { pipeline_id, parent_info })) => {
|
||||||
|
debug!("handling script failure message from pipeline {:?}, {:?}", pipeline_id, parent_info);
|
||||||
self.handle_failure_msg(pipeline_id, parent_info);
|
self.handle_failure_msg(pipeline_id, parent_info);
|
||||||
}
|
}
|
||||||
Request::Script(FromScriptMsg::ScriptLoadedURLInIFrame(load_info)) => {
|
Request::Script(FromScriptMsg::ScriptLoadedURLInIFrame(load_info)) => {
|
||||||
|
@ -585,11 +601,6 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
debug!("constellation got navigation message from script");
|
debug!("constellation got navigation message from script");
|
||||||
self.handle_navigate_msg(pipeline_info, direction);
|
self.handle_navigate_msg(pipeline_info, direction);
|
||||||
}
|
}
|
||||||
// Notification that painting has finished and is requesting permission to paint.
|
|
||||||
Request::Script(FromScriptMsg::PainterReady(pipeline_id)) => {
|
|
||||||
debug!("constellation got painter ready message");
|
|
||||||
self.handle_painter_ready_msg(pipeline_id);
|
|
||||||
}
|
|
||||||
Request::Script(FromScriptMsg::MozBrowserEvent(pipeline_id,
|
Request::Script(FromScriptMsg::MozBrowserEvent(pipeline_id,
|
||||||
subpage_id,
|
subpage_id,
|
||||||
event)) => {
|
event)) => {
|
||||||
|
@ -647,6 +658,21 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
debug!("constellation got NodeStatus message");
|
debug!("constellation got NodeStatus message");
|
||||||
self.compositor_proxy.send(ToCompositorMsg::Status(message));
|
self.compositor_proxy.send(ToCompositorMsg::Status(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Messages from paint task
|
||||||
|
|
||||||
|
|
||||||
|
// Notification that painting has finished and is requesting permission to paint.
|
||||||
|
Request::Paint(FromPaintMsg::Ready(pipeline_id)) => {
|
||||||
|
debug!("constellation got painter ready message");
|
||||||
|
self.handle_painter_ready_msg(pipeline_id);
|
||||||
|
}
|
||||||
|
Request::Paint(FromPaintMsg::Failure(Failure { pipeline_id, parent_info })) => {
|
||||||
|
debug!("handling paint failure message from pipeline {:?}, {:?}", pipeline_id, parent_info);
|
||||||
|
self.handle_failure_msg(pipeline_id, parent_info);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -669,8 +695,6 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
fn handle_failure_msg(&mut self,
|
fn handle_failure_msg(&mut self,
|
||||||
pipeline_id: PipelineId,
|
pipeline_id: PipelineId,
|
||||||
parent_info: Option<(PipelineId, SubpageId)>) {
|
parent_info: Option<(PipelineId, SubpageId)>) {
|
||||||
debug!("handling failure message from pipeline {:?}, {:?}", pipeline_id, parent_info);
|
|
||||||
|
|
||||||
if opts::get().hard_fail {
|
if opts::get().hard_fail {
|
||||||
// It's quite difficult to make Servo exit cleanly if some tasks have failed.
|
// It's quite difficult to make Servo exit cleanly if some tasks have failed.
|
||||||
// Hard fail exists for test runners so we crash and that's good enough.
|
// Hard fail exists for test runners so we crash and that's good enough.
|
||||||
|
|
|
@ -15,6 +15,7 @@ use ipc_channel::router::ROUTER;
|
||||||
use layers::geometry::DevicePixel;
|
use layers::geometry::DevicePixel;
|
||||||
use layout_traits::{LayoutControlChan, LayoutTaskFactory};
|
use layout_traits::{LayoutControlChan, LayoutTaskFactory};
|
||||||
use msg::compositor_msg::ScriptToCompositorMsg;
|
use msg::compositor_msg::ScriptToCompositorMsg;
|
||||||
|
use msg::constellation_msg::PaintMsg;
|
||||||
use msg::constellation_msg::ScriptMsg as ConstellationMsg;
|
use msg::constellation_msg::ScriptMsg as ConstellationMsg;
|
||||||
use msg::constellation_msg::{ConstellationChan, Failure, FrameId, PipelineId, SubpageId};
|
use msg::constellation_msg::{ConstellationChan, Failure, FrameId, PipelineId, SubpageId};
|
||||||
use msg::constellation_msg::{LoadData, MozBrowserEvent, WindowSizeData};
|
use msg::constellation_msg::{LoadData, MozBrowserEvent, WindowSizeData};
|
||||||
|
@ -81,6 +82,8 @@ pub struct InitialPipelineState {
|
||||||
pub parent_info: Option<(PipelineId, SubpageId)>,
|
pub parent_info: Option<(PipelineId, SubpageId)>,
|
||||||
/// A channel to the associated constellation.
|
/// A channel to the associated constellation.
|
||||||
pub constellation_chan: ConstellationChan<ConstellationMsg>,
|
pub constellation_chan: ConstellationChan<ConstellationMsg>,
|
||||||
|
/// A channel to the associated paint task.
|
||||||
|
pub painter_chan: ConstellationChan<PaintMsg>,
|
||||||
/// A channel to schedule timer events.
|
/// A channel to schedule timer events.
|
||||||
pub scheduler_chan: IpcSender<TimerEventRequest>,
|
pub scheduler_chan: IpcSender<TimerEventRequest>,
|
||||||
/// A channel to the compositor.
|
/// A channel to the compositor.
|
||||||
|
@ -226,6 +229,7 @@ impl Pipeline {
|
||||||
let privileged_pipeline_content = PrivilegedPipelineContent {
|
let privileged_pipeline_content = PrivilegedPipelineContent {
|
||||||
id: state.id,
|
id: state.id,
|
||||||
constellation_chan: state.constellation_chan,
|
constellation_chan: state.constellation_chan,
|
||||||
|
painter_chan: state.painter_chan,
|
||||||
compositor_proxy: state.compositor_proxy,
|
compositor_proxy: state.compositor_proxy,
|
||||||
font_cache_task: state.font_cache_task,
|
font_cache_task: state.font_cache_task,
|
||||||
time_profiler_chan: state.time_profiler_chan,
|
time_profiler_chan: state.time_profiler_chan,
|
||||||
|
@ -429,6 +433,7 @@ impl UnprivilegedPipelineContent {
|
||||||
pub struct PrivilegedPipelineContent {
|
pub struct PrivilegedPipelineContent {
|
||||||
id: PipelineId,
|
id: PipelineId,
|
||||||
constellation_chan: ConstellationChan<ConstellationMsg>,
|
constellation_chan: ConstellationChan<ConstellationMsg>,
|
||||||
|
painter_chan: ConstellationChan<PaintMsg>,
|
||||||
compositor_proxy: Box<CompositorProxy + Send + 'static>,
|
compositor_proxy: Box<CompositorProxy + Send + 'static>,
|
||||||
script_to_compositor_port: Option<IpcReceiver<ScriptToCompositorMsg>>,
|
script_to_compositor_port: Option<IpcReceiver<ScriptToCompositorMsg>>,
|
||||||
font_cache_task: FontCacheTask,
|
font_cache_task: FontCacheTask,
|
||||||
|
@ -464,7 +469,7 @@ impl PrivilegedPipelineContent {
|
||||||
mem::replace(&mut self.layout_to_paint_port, None).unwrap(),
|
mem::replace(&mut self.layout_to_paint_port, None).unwrap(),
|
||||||
mem::replace(&mut self.chrome_to_paint_port, None).unwrap(),
|
mem::replace(&mut self.chrome_to_paint_port, None).unwrap(),
|
||||||
self.compositor_proxy.clone_compositor_proxy(),
|
self.compositor_proxy.clone_compositor_proxy(),
|
||||||
self.constellation_chan.clone(),
|
self.painter_chan.clone(),
|
||||||
self.font_cache_task.clone(),
|
self.font_cache_task.clone(),
|
||||||
self.failure.clone(),
|
self.failure.clone(),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|
|
|
@ -21,7 +21,7 @@ use layers::layers::{BufferRequest, LayerBuffer, LayerBufferSet};
|
||||||
use layers::platform::surface::{NativeDisplay, NativeSurface};
|
use layers::platform::surface::{NativeDisplay, NativeSurface};
|
||||||
use msg::compositor_msg::{Epoch, FrameTreeId, LayerId, LayerKind, LayerProperties};
|
use msg::compositor_msg::{Epoch, FrameTreeId, LayerId, LayerKind, LayerProperties};
|
||||||
use msg::compositor_msg::{PaintListener, ScrollPolicy};
|
use msg::compositor_msg::{PaintListener, ScrollPolicy};
|
||||||
use msg::constellation_msg::ScriptMsg as ConstellationMsg;
|
use msg::constellation_msg::PaintMsg as ConstellationMsg;
|
||||||
use msg::constellation_msg::{ConstellationChan, Failure, PipelineId};
|
use msg::constellation_msg::{ConstellationChan, Failure, PipelineId};
|
||||||
use paint_context::PaintContext;
|
use paint_context::PaintContext;
|
||||||
use profile_traits::mem::{self, ReportsChan};
|
use profile_traits::mem::{self, ReportsChan};
|
||||||
|
@ -330,7 +330,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
|
||||||
if !self.paint_permission {
|
if !self.paint_permission {
|
||||||
debug!("PaintTask: paint ready msg");
|
debug!("PaintTask: paint ready msg");
|
||||||
let ConstellationChan(ref mut c) = self.constellation_chan;
|
let ConstellationChan(ref mut c) = self.constellation_chan;
|
||||||
c.send(ConstellationMsg::PainterReady(self.id)).unwrap();
|
c.send(ConstellationMsg::Ready(self.id)).unwrap();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
|
||||||
if !self.paint_permission {
|
if !self.paint_permission {
|
||||||
debug!("PaintTask: paint ready msg");
|
debug!("PaintTask: paint ready msg");
|
||||||
let ConstellationChan(ref mut c) = self.constellation_chan;
|
let ConstellationChan(ref mut c) = self.constellation_chan;
|
||||||
c.send(ConstellationMsg::PainterReady(self.id)).unwrap();
|
c.send(ConstellationMsg::Ready(self.id)).unwrap();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -294,7 +294,6 @@ pub enum ScriptMsg {
|
||||||
NewFavicon(Url),
|
NewFavicon(Url),
|
||||||
/// Status message to be displayed in the chrome, eg. a link URL on mouseover.
|
/// Status message to be displayed in the chrome, eg. a link URL on mouseover.
|
||||||
NodeStatus(Option<String>),
|
NodeStatus(Option<String>),
|
||||||
PainterReady(PipelineId),
|
|
||||||
/// Notification that this iframe should be removed.
|
/// Notification that this iframe should be removed.
|
||||||
RemoveIFrame(PipelineId),
|
RemoveIFrame(PipelineId),
|
||||||
ScriptLoadedURLInIFrame(IframeLoadInfo),
|
ScriptLoadedURLInIFrame(IframeLoadInfo),
|
||||||
|
@ -306,6 +305,13 @@ pub enum ScriptMsg {
|
||||||
ViewportConstrained(PipelineId, ViewportConstraints),
|
ViewportConstrained(PipelineId, ViewportConstraints),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Messages from the paint task to the constellation.
|
||||||
|
#[derive(Deserialize, Serialize)]
|
||||||
|
pub enum PaintMsg {
|
||||||
|
Ready(PipelineId),
|
||||||
|
Failure(Failure),
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Eq, PartialEq, Deserialize, Serialize, Debug)]
|
#[derive(Clone, Eq, PartialEq, Deserialize, Serialize, Debug)]
|
||||||
pub enum AnimationState {
|
pub enum AnimationState {
|
||||||
AnimationsPresent,
|
AnimationsPresent,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue