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

Send display lists over IPC in multiprocess mode. #6795

Merged
merged 6 commits into from Jul 31, 2015
@@ -4,8 +4,7 @@

use surface_map::SurfaceMap;
use compositor_layer::{CompositorData, CompositorLayer, WantsScrollEventsFlag};
use compositor_task::{CompositorEventListener, CompositorProxy, CompositorReceiver};
use compositor_task::Msg;
use compositor_task::{CompositorEventListener, CompositorProxy, CompositorReceiver, Msg};
use constellation::SendableFrameTree;
use pipeline::CompositionPipeline;
use scrolling::ScrollingTimerProxy;
@@ -18,8 +17,7 @@ use euclid::rect::{Rect, TypedRect};
use euclid::scale_factor::ScaleFactor;
use euclid::size::{Size2D, TypedSize2D};
use gfx_traits::color;
use gfx::paint_task::Msg as PaintMsg;
use gfx::paint_task::PaintRequest;
use gfx::paint_task::{ChromeToPaintMsg, PaintRequest};
use gleam::gl::types::{GLint, GLsizei};
use gleam::gl;
use ipc_channel::ipc;
@@ -1306,8 +1304,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
self.convert_buffer_requests_to_pipeline_requests_map(layers_and_requests);

for (pipeline_id, requests) in pipeline_requests.into_iter() {
let msg = PaintMsg::Paint(requests, self.frame_tree_id);
let _ = self.get_pipeline(pipeline_id).paint_chan.send(msg);
let msg = ChromeToPaintMsg::Paint(requests, self.frame_tree_id);
let _ = self.get_pipeline(pipeline_id).chrome_to_paint_chan.send(msg);
}

true
@@ -11,8 +11,7 @@ use compositor_task;
use devtools_traits::{DevtoolsControlChan, DevtoolsControlMsg, ScriptToDevtoolsControlMsg};
use euclid::rect::{TypedRect};
use euclid::scale_factor::ScaleFactor;
use gfx::paint_task::Msg as PaintMsg;
use gfx::paint_task::{PaintChan, PaintTask};
use gfx::paint_task::{ChromeToPaintMsg, LayoutToPaintMsg, PaintTask};
use gfx::font_cache_task::FontCacheTask;
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use ipc_channel::router::ROUTER;
@@ -30,7 +29,9 @@ use std::mem;
use std::sync::mpsc::{Receiver, Sender, channel};
use std::thread;
use url::Url;
use util;
use util::geometry::{PagePx, ViewportPx};
use util::ipc::OptionalIpcSender;
use util::opts;

/// A uniquely-identifiable pipeline of script task, layout task, and paint task.
@@ -40,7 +41,7 @@ pub struct Pipeline {
pub script_chan: ScriptControlChan,
/// A channel to layout, for performing reflows and shutdown.
pub layout_chan: LayoutControlChan,
pub paint_chan: PaintChan,
pub chrome_to_paint_chan: Sender<ChromeToPaintMsg>,
pub layout_shutdown_port: Receiver<()>,
pub paint_shutdown_port: Receiver<()>,
/// URL corresponding to the most recently-loaded page.
@@ -60,7 +61,7 @@ pub struct CompositionPipeline {
pub id: PipelineId,
pub script_chan: ScriptControlChan,
pub layout_chan: LayoutControlChan,
pub paint_chan: PaintChan,
pub chrome_to_paint_chan: Sender<ChromeToPaintMsg>,
}

impl Pipeline {
@@ -84,7 +85,8 @@ impl Pipeline {
device_pixel_ratio: ScaleFactor<ViewportPx, DevicePixel, f32>)
-> (Pipeline, PipelineContent)
where LTF: LayoutTaskFactory, STF:ScriptTaskFactory {
let (paint_port, paint_chan) = PaintChan::new();
let (layout_to_paint_chan, layout_to_paint_port) = util::ipc::optional_ipc_channel();
let (chrome_to_paint_chan, chrome_to_paint_port) = channel();
let (paint_shutdown_chan, paint_shutdown_port) = channel();
let (layout_shutdown_chan, layout_shutdown_port) = channel();
let (pipeline_chan, pipeline_port) = ipc::channel().unwrap();
@@ -123,7 +125,7 @@ impl Pipeline {
new_pipeline_id: id,
subpage_id: subpage_id,
load_data: load_data.clone(),
paint_chan: box paint_chan.clone() as Box<Any + Send>,
paint_chan: box layout_to_paint_chan.clone() as Box<Any + Send>,
failure: failure,
pipeline_port: mem::replace(&mut pipeline_port, None).unwrap(),
layout_shutdown_chan: layout_shutdown_chan.clone(),
@@ -144,7 +146,7 @@ impl Pipeline {
parent_info,
script_chan.clone(),
LayoutControlChan(pipeline_chan),
paint_chan.clone(),
chrome_to_paint_chan.clone(),
layout_shutdown_port,
paint_shutdown_port,
load_data.url.clone(),
@@ -167,8 +169,10 @@ impl Pipeline {
load_data: load_data,
failure: failure,
script_port: script_port,
paint_chan: paint_chan,
paint_port: Some(paint_port),
layout_to_paint_chan: layout_to_paint_chan,
chrome_to_paint_chan: chrome_to_paint_chan,
layout_to_paint_port: Some(layout_to_paint_port),
chrome_to_paint_port: Some(chrome_to_paint_port),
pipeline_port: pipeline_port,
paint_shutdown_chan: paint_shutdown_chan,
layout_shutdown_chan: layout_shutdown_chan,
@@ -181,7 +185,7 @@ impl Pipeline {
parent_info: Option<(PipelineId, SubpageId)>,
script_chan: ScriptControlChan,
layout_chan: LayoutControlChan,
paint_chan: PaintChan,
chrome_to_paint_chan: Sender<ChromeToPaintMsg>,
layout_shutdown_port: Receiver<()>,
paint_shutdown_port: Receiver<()>,
url: Url,
@@ -192,7 +196,7 @@ impl Pipeline {
parent_info: parent_info,
script_chan: script_chan,
layout_chan: layout_chan,
paint_chan: paint_chan,
chrome_to_paint_chan: chrome_to_paint_chan,
layout_shutdown_port: layout_shutdown_port,
paint_shutdown_port: paint_shutdown_port,
url: url,
@@ -204,12 +208,12 @@ impl Pipeline {
}

pub fn grant_paint_permission(&self) {
let _ = self.paint_chan.send(PaintMsg::PaintPermissionGranted);
let _ = self.chrome_to_paint_chan.send(ChromeToPaintMsg::PaintPermissionGranted);
}

pub fn revoke_paint_permission(&self) {
debug!("pipeline revoking paint channel paint permission");
let _ = self.paint_chan.send(PaintMsg::PaintPermissionRevoked);
let _ = self.chrome_to_paint_chan.send(ChromeToPaintMsg::PaintPermissionRevoked);
}

pub fn exit(&self, exit_type: PipelineExitType) {
@@ -242,7 +246,9 @@ impl Pipeline {
let _ = script_channel.send(
ConstellationControlMsg::ExitPipeline(self.id,
PipelineExitType::PipelineOnly)).unwrap();
let _ = self.paint_chan.send(PaintMsg::Exit(None, PipelineExitType::PipelineOnly));
let _ = self.chrome_to_paint_chan.send(ChromeToPaintMsg::Exit(
None,
PipelineExitType::PipelineOnly));
let LayoutControlChan(ref layout_channel) = self.layout_chan;
let _ = layout_channel.send(
LayoutControlMsg::ExitNow(PipelineExitType::PipelineOnly)).unwrap();
@@ -253,7 +259,7 @@ impl Pipeline {
id: self.id.clone(),
script_chan: self.script_chan.clone(),
layout_chan: self.layout_chan.clone(),
paint_chan: self.paint_chan.clone(),
chrome_to_paint_chan: self.chrome_to_paint_chan.clone(),
}
}

@@ -296,8 +302,10 @@ pub struct PipelineContent {
load_data: LoadData,
failure: Failure,
script_port: Option<Receiver<ConstellationControlMsg>>,
paint_chan: PaintChan,
paint_port: Option<Receiver<PaintMsg>>,
layout_to_paint_chan: OptionalIpcSender<LayoutToPaintMsg>,
chrome_to_paint_chan: Sender<ChromeToPaintMsg>,
layout_to_paint_port: Option<Receiver<LayoutToPaintMsg>>,
chrome_to_paint_port: Option<Receiver<ChromeToPaintMsg>>,
paint_shutdown_chan: Sender<()>,
pipeline_port: Option<IpcReceiver<LayoutControlMsg>>,
layout_shutdown_chan: Sender<()>,
@@ -344,7 +352,7 @@ impl PipelineContent {
self.constellation_chan,
self.failure,
self.script_chan.clone(),
self.paint_chan.clone(),
self.layout_to_paint_chan.clone(),
self.image_cache_task,
self.font_cache_task,
self.time_profiler_chan,
@@ -355,8 +363,9 @@ impl PipelineContent {
pub fn start_paint_task(&mut self) {
PaintTask::create(self.id,
self.load_data.url.clone(),
self.paint_chan.clone(),
mem::replace(&mut self.paint_port, None).unwrap(),
self.chrome_to_paint_chan.clone(),
mem::replace(&mut self.layout_to_paint_port, None).unwrap(),
mem::replace(&mut self.chrome_to_paint_port, None).unwrap(),
self.compositor_proxy.clone_compositor_proxy(),
self.constellation_chan.clone(),
self.font_cache_task.clone(),
@@ -42,7 +42,7 @@ use style::computed_values::{pointer_events};
use style::properties::ComputedValues;
use util::cursor::Cursor;
use util::geometry::{self, Au, MAX_RECT, ZERO_RECT};
use util::linked_list::{SerializableLinkedList, prepend_from};
use util::linked_list::prepend_from;
use util::mem::HeapSizeOf;
use util::opts;
use util::range::Range;
@@ -84,68 +84,68 @@ impl OpaqueNode {
#[derive(HeapSizeOf, Deserialize, Serialize)]
pub struct DisplayList {
/// The border and backgrounds for the root of this stacking context: steps 1 and 2.
pub background_and_borders: SerializableLinkedList<DisplayItem>,
pub background_and_borders: LinkedList<DisplayItem>,
/// Borders and backgrounds for block-level descendants: step 4.
pub block_backgrounds_and_borders: SerializableLinkedList<DisplayItem>,
pub block_backgrounds_and_borders: LinkedList<DisplayItem>,
/// Floats: step 5. These are treated as pseudo-stacking contexts.
pub floats: SerializableLinkedList<DisplayItem>,
pub floats: LinkedList<DisplayItem>,
/// All non-positioned content.
pub content: SerializableLinkedList<DisplayItem>,
pub content: LinkedList<DisplayItem>,
/// All positioned content that does not get a stacking context.
pub positioned_content: SerializableLinkedList<DisplayItem>,
pub positioned_content: LinkedList<DisplayItem>,
/// Outlines: step 10.
pub outlines: SerializableLinkedList<DisplayItem>,
pub outlines: LinkedList<DisplayItem>,
/// Child stacking contexts.
pub children: SerializableLinkedList<Arc<StackingContext>>,
pub children: LinkedList<Arc<StackingContext>>,
}

impl DisplayList {
/// Creates a new, empty display list.
#[inline]
pub fn new() -> DisplayList {
DisplayList {
background_and_borders: SerializableLinkedList::new(LinkedList::new()),
block_backgrounds_and_borders: SerializableLinkedList::new(LinkedList::new()),
floats: SerializableLinkedList::new(LinkedList::new()),
content: SerializableLinkedList::new(LinkedList::new()),
positioned_content: SerializableLinkedList::new(LinkedList::new()),
outlines: SerializableLinkedList::new(LinkedList::new()),
children: SerializableLinkedList::new(LinkedList::new()),
background_and_borders: LinkedList::new(),
block_backgrounds_and_borders: LinkedList::new(),
floats: LinkedList::new(),
content: LinkedList::new(),
positioned_content: LinkedList::new(),
outlines: LinkedList::new(),
children: LinkedList::new(),
}
}

/// Appends all display items from `other` into `self`, preserving stacking order and emptying
/// `other` in the process.
#[inline]
pub fn append_from(&mut self, other: &mut DisplayList) {
self.background_and_borders.append(&mut *other.background_and_borders);
self.block_backgrounds_and_borders.append(&mut *other.block_backgrounds_and_borders);
self.floats.append(&mut *other.floats);
self.content.append(&mut *other.content);
self.positioned_content.append(&mut *other.positioned_content);
self.outlines.append(&mut *other.outlines);
self.children.append(&mut *other.children);
self.background_and_borders.append(&mut other.background_and_borders);
self.block_backgrounds_and_borders.append(&mut other.block_backgrounds_and_borders);
self.floats.append(&mut other.floats);
self.content.append(&mut other.content);
self.positioned_content.append(&mut other.positioned_content);
self.outlines.append(&mut other.outlines);
self.children.append(&mut other.children);
}

/// Merges all display items from all non-float stacking levels to the `float` stacking level.
#[inline]
pub fn form_float_pseudo_stacking_context(&mut self) {
prepend_from(&mut *self.floats, &mut *self.outlines);
prepend_from(&mut *self.floats, &mut *self.positioned_content);
prepend_from(&mut *self.floats, &mut *self.content);
prepend_from(&mut *self.floats, &mut *self.block_backgrounds_and_borders);
prepend_from(&mut *self.floats, &mut *self.background_and_borders);
prepend_from(&mut self.floats, &mut self.outlines);
prepend_from(&mut self.floats, &mut self.positioned_content);
prepend_from(&mut self.floats, &mut self.content);
prepend_from(&mut self.floats, &mut self.block_backgrounds_and_borders);
prepend_from(&mut self.floats, &mut self.background_and_borders);
}

/// Merges all display items from all non-positioned-content stacking levels to the
/// positioned-content stacking level.
#[inline]
pub fn form_pseudo_stacking_context_for_positioned_content(&mut self) {
prepend_from(&mut *self.positioned_content, &mut *self.outlines);
prepend_from(&mut *self.positioned_content, &mut *self.content);
prepend_from(&mut *self.positioned_content, &mut *self.floats);
prepend_from(&mut *self.positioned_content, &mut *self.block_backgrounds_and_borders);
prepend_from(&mut *self.positioned_content, &mut *self.background_and_borders);
prepend_from(&mut self.positioned_content, &mut self.outlines);
prepend_from(&mut self.positioned_content, &mut self.content);
prepend_from(&mut self.positioned_content, &mut self.floats);
prepend_from(&mut self.positioned_content, &mut self.block_backgrounds_and_borders);
prepend_from(&mut self.positioned_content, &mut self.background_and_borders);
}

/// Returns a list of all items in this display list concatenated together. This is extremely
@@ -42,7 +42,7 @@ fn create_scaled_font(template: &Arc<FontTemplateData>, pt_size: Au) -> ScaledFo

#[cfg(target_os="macos")]
fn create_scaled_font(template: &Arc<FontTemplateData>, pt_size: Au) -> ScaledFont {
let cgfont = template.ctfont.as_ref().unwrap().copy_to_CGFont();
let cgfont = template.ctfont().as_ref().unwrap().copy_to_CGFont();
ScaledFont::new(BackendType::Skia, &cgfont, pt_size.to_f32_px())
}

@@ -9,6 +9,7 @@
#![feature(custom_derive)]
#![feature(hashmap_hasher)]
#![cfg_attr(any(target_os="linux", target_os = "android"), feature(heap_api))]
#![feature(mpsc_select)]
#![feature(plugin)]
#![feature(str_char)]
#![feature(vec_push_all)]
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.