Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compositing: Make `ScriptListener` and `LayoutControlChan` messages go over IPC. #6596

Merged
merged 2 commits into from Jul 14, 2015
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

layout: Make the `LayoutControlChan` use IPC.

  • Loading branch information
pcwalton committed Jul 14, 2015
commit 9ce65c08a51d1a2a62c1d50ca97415f31df2e5fe
@@ -19,6 +19,7 @@ use euclid::rect::{Rect, TypedRect};
use euclid::size::Size2D;
use euclid::scale_factor::ScaleFactor;
use gfx::font_cache_task::FontCacheTask;
use ipc_channel::ipc;
use layout_traits::{LayoutControlChan, LayoutControlMsg, LayoutTaskFactory};
use libc;
use msg::compositor_msg::{Epoch, LayerId};
@@ -1128,7 +1129,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
// epoch matches what the compositor has drawn. If they match
// (and script is idle) then this pipeline won't change again
// and can be considered stable.
let (sender, receiver) = channel();
let (sender, receiver) = ipc::channel().unwrap();
let LayoutControlChan(ref layout_chan) = pipeline.layout_chan;
layout_chan.send(LayoutControlMsg::GetCurrentEpoch(sender)).unwrap();
let layout_task_epoch = receiver.recv().unwrap();
@@ -85,7 +85,7 @@ impl Pipeline {
let (paint_port, paint_chan) = PaintChan::new();
let (paint_shutdown_chan, paint_shutdown_port) = channel();
let (layout_shutdown_chan, layout_shutdown_port) = channel();
let (pipeline_chan, pipeline_port) = channel();
let (pipeline_chan, pipeline_port) = ipc::channel().unwrap();

let failure = Failure {
pipeline_id: id,
@@ -55,6 +55,9 @@ git = "https://github.com/servo/rust-selectors"
[dependencies.clock_ticks]
git = "https://github.com/tomaka/clock_ticks"

[dependencies.ipc-channel]
git = "https://github.com/pcwalton/ipc-channel"

[dependencies]
log = "*"
encoding = "0.2"
@@ -39,6 +39,7 @@ use gfx::display_list::StackingContext;
use gfx::font_cache_task::FontCacheTask;
use gfx::paint_task::Msg as PaintMsg;
use gfx::paint_task::{PaintChan, PaintLayer};
use ipc_channel::ipc::IpcReceiver;
use layout_traits::{LayoutControlMsg, LayoutTaskFactory};
use log;
use msg::compositor_msg::{Epoch, ScrollPolicy, LayerId};
@@ -65,6 +66,7 @@ use std::mem::transmute;
use std::ops::{Deref, DerefMut};
use std::sync::mpsc::{channel, Sender, Receiver, Select};
use std::sync::{Arc, Mutex, MutexGuard};
use std::thread;
use style::computed_values::{filter, mix_blend_mode};
use style::media_queries::{MediaType, MediaQueryList, Device};
use style::selector_matching::Stylist;
@@ -155,7 +157,7 @@ pub struct LayoutTask {
/// The port on which we receive messages from the script task.
pub port: Receiver<Msg>,

/// The port on which we receive messages from the constellation
/// The port on which we receive messages from the constellation.
pub pipeline_port: Receiver<LayoutControlMsg>,

/// The port on which we receive messages from the image cache
@@ -213,7 +215,7 @@ impl LayoutTaskFactory for LayoutTask {
url: Url,
is_iframe: bool,
chan: OpaqueScriptLayoutChannel,
pipeline_port: Receiver<LayoutControlMsg>,
pipeline_port: IpcReceiver<LayoutControlMsg>,
constellation_chan: ConstellationChan,
failure_msg: Failure,
script_chan: ScriptControlChan,
@@ -284,7 +286,7 @@ impl LayoutTask {
is_iframe: bool,
port: Receiver<Msg>,
chan: LayoutChan,
pipeline_port: Receiver<LayoutControlMsg>,
pipeline_port: IpcReceiver<LayoutControlMsg>,
constellation_chan: ConstellationChan,
script_chan: ScriptControlChan,
paint_chan: PaintChan,
@@ -314,12 +316,20 @@ impl LayoutTask {
let (image_cache_sender, image_cache_receiver) = channel();
let (canvas_layers_sender, canvas_layers_receiver) = channel();

// Start a thread to proxy IPC messages from the layout thread to us.
let (pipeline_sender, pipeline_receiver) = channel();
thread::spawn(move || {
while let Ok(message) = pipeline_port.recv() {
pipeline_sender.send(message).unwrap()
}
});

LayoutTask {
id: id,
url: url,
is_iframe: is_iframe,
port: port,
pipeline_port: pipeline_port,
pipeline_port: pipeline_receiver,
chan: chan,
script_chan: script_chan,
constellation_chan: constellation_chan.clone(),
@@ -46,6 +46,7 @@ extern crate fnv;
extern crate euclid;
extern crate gfx;
extern crate gfx_traits;
extern crate ipc_channel;
extern crate layout_traits;
extern crate libc;
extern crate msg;
@@ -25,6 +25,12 @@ path = "../profile_traits"
[dependencies.util]
path = "../util"

[dependencies.ipc-channel]
git = "https://github.com/pcwalton/ipc-channel"

[dependencies]
url = "0.2.35"
euclid = "0.1"
serde = "*"
serde_macros = "*"

@@ -2,12 +2,17 @@
* 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/. */

#![feature(custom_derive, plugin)]
#![plugin(serde_macros)]

extern crate euclid;
extern crate gfx;
extern crate ipc_channel;
extern crate script_traits;
extern crate msg;
extern crate profile_traits;
extern crate net_traits;
extern crate serde;
extern crate url;
extern crate util;

@@ -19,27 +24,29 @@ extern crate util;
use euclid::rect::Rect;
use gfx::font_cache_task::FontCacheTask;
use gfx::paint_task::PaintChan;
use ipc_channel::ipc::{IpcReceiver, IpcSender};
use msg::compositor_msg::{Epoch, LayerId};
use msg::constellation_msg::{ConstellationChan, Failure, PipelineId, PipelineExitType};
use profile_traits::mem;
use profile_traits::time;
use net_traits::image_cache_task::ImageCacheTask;
use script_traits::{ScriptControlChan, OpaqueScriptLayoutChannel};
use std::sync::mpsc::{Sender, Receiver};
use std::sync::mpsc::Sender;
use util::geometry::Au;
use url::Url;

/// Messages sent to the layout task from the constellation and/or compositor.
#[derive(Deserialize, Serialize)]
pub enum LayoutControlMsg {
ExitNow(PipelineExitType),
GetCurrentEpoch(Sender<Epoch>),
GetCurrentEpoch(IpcSender<Epoch>),
TickAnimations,
SetVisibleRects(Vec<(LayerId, Rect<Au>)>),
}

/// A channel wrapper for constellation messages
#[derive(Clone)]
pub struct LayoutControlChan(pub Sender<LayoutControlMsg>);
#[derive(Clone, Deserialize, Serialize)]
pub struct LayoutControlChan(pub IpcSender<LayoutControlMsg>);

// A static method creating a layout task
// Here to remove the compositor -> layout dependency
@@ -50,7 +57,7 @@ pub trait LayoutTaskFactory {
url: Url,
is_iframe: bool,
chan: OpaqueScriptLayoutChannel,
pipeline_port: Receiver<LayoutControlMsg>,
pipeline_port: IpcReceiver<LayoutControlMsg>,
constellation_chan: ConstellationChan,
failure_msg: Failure,
script_chan: ScriptControlChan,
@@ -16,7 +16,7 @@ use std::fmt;
use constellation_msg::PipelineId;

/// A newtype struct for denoting the age of messages; prevents race conditions.
#[derive(PartialEq, Eq, Debug, Copy, Clone, PartialOrd, Ord)]
#[derive(PartialEq, Eq, Debug, Copy, Clone, PartialOrd, Ord, Deserialize, Serialize)]
pub struct Epoch(pub u32);

impl Epoch {
@@ -377,7 +377,7 @@ pub struct SubpageId(pub u32);

// The type of pipeline exit. During complete shutdowns, pipelines do not have to
// release resources automatically released on process termination.
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
pub enum PipelineExitType {
PipelineOnly,
Complete,
@@ -55,6 +55,9 @@ features = ["query_encoding"]
[dependencies.offscreen_gl_context]
git = "https://github.com/ecoal95/rust-offscreen-rendering-context"

[dependencies.ipc-channel]
git = "https://github.com/pcwalton/ipc-channel"

[dependencies]
log = "*"
encoding = "0.2"
@@ -10,6 +10,7 @@ use dom::node::LayoutData;

use euclid::point::Point2D;
use euclid::rect::Rect;
use ipc_channel::ipc::IpcSender;
use libc::uintptr_t;
use msg::compositor_msg::LayerId;
use msg::constellation_msg::{PipelineExitType, WindowSizeData};
@@ -71,7 +72,7 @@ pub enum Msg {
ExitNow(PipelineExitType),

/// Get the last epoch counter for this layout task.
GetCurrentEpoch(Sender<Epoch>)
GetCurrentEpoch(IpcSender<Epoch>)
}

/// Synchronous messages that script can send to layout.
@@ -44,6 +44,7 @@ extern crate html5ever;
extern crate encoding;
extern crate fnv;
extern crate hyper;
extern crate ipc_channel;
extern crate js;
extern crate libc;
extern crate msg;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.