new token-permissions model, and compositor filters paint messages based on id

This commit is contained in:
Tim Kuehn 2013-07-01 14:16:43 -07:00
parent a6eaffcd93
commit c9c6cb3bf5
12 changed files with 148 additions and 147 deletions

View file

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use servo_msg::compositor::LayerBuffer; use servo_msg::compositor_msg::LayerBuffer;
use font_context::FontContext; use font_context::FontContext;
use geometry::Au; use geometry::Au;
use opts::Opts; use opts::Opts;

View file

@ -7,9 +7,9 @@
use azure::{AzFloat, AzGLContext}; use azure::{AzFloat, AzGLContext};
use azure::azure_hl::{B8G8R8A8, DrawTarget}; use azure::azure_hl::{B8G8R8A8, DrawTarget};
use display_list::DisplayList; use display_list::DisplayList;
use servo_msg::compositor::{RenderListener, IdleRenderState, RenderingRenderState, LayerBuffer}; use servo_msg::compositor_msg::{RenderListener, IdleRenderState, RenderingRenderState, LayerBuffer};
use servo_msg::compositor::{CompositorToken, LayerBufferSet}; use servo_msg::compositor_msg::{CompositorToken, LayerBufferSet};
use servo_msg::constellation::{ConstellationChan, TokenSurrenderMsg}; use servo_msg::constellation_msg::{ConstellationChan};
use font_context::FontContext; use font_context::FontContext;
use geom::matrix2d::Matrix2D; use geom::matrix2d::Matrix2D;
use geom::point::Point2D; use geom::point::Point2D;
@ -33,8 +33,8 @@ pub struct RenderLayer {
pub enum Msg { pub enum Msg {
RenderMsg(RenderLayer), RenderMsg(RenderLayer),
ReRenderMsg(f32), ReRenderMsg(f32),
TokenBestowMsg(~CompositorToken), TokenBestowMsg(CompositorToken),
TokenProcureMsg, TokenInvalidateMsg,
ExitMsg(Chan<()>), ExitMsg(Chan<()>),
} }
@ -55,6 +55,7 @@ impl RenderChan {
} }
priv struct RenderTask<C> { priv struct RenderTask<C> {
id: uint,
port: Port<Msg>, port: Port<Msg>,
compositor: C, compositor: C,
font_ctx: @mut FontContext, font_ctx: @mut FontContext,
@ -70,13 +71,14 @@ priv struct RenderTask<C> {
/// A channel to the constellation for surrendering token /// A channel to the constellation for surrendering token
constellation_chan: ConstellationChan, constellation_chan: ConstellationChan,
/// A token that grants permission to send paint messages to compositor /// A token that grants permission to send paint messages to compositor
compositor_token: Option<~CompositorToken>, compositor_token: Option<CompositorToken>,
/// Cached copy of last layers rendered /// Cached copy of last layers rendered
last_paint_msg: Option<(LayerBufferSet, Size2D<uint>)>, last_paint_msg: Option<(LayerBufferSet, Size2D<uint>)>,
} }
impl<C: RenderListener + Owned> RenderTask<C> { impl<C: RenderListener + Owned> RenderTask<C> {
pub fn create(port: Port<Msg>, pub fn create(id: uint,
port: Port<Msg>,
compositor: C, compositor: C,
opts: Opts, opts: Opts,
constellation_chan: ConstellationChan, constellation_chan: ConstellationChan,
@ -95,6 +97,7 @@ impl<C: RenderListener + Owned> RenderTask<C> {
// FIXME: rust/#5967 // FIXME: rust/#5967
let mut render_task = RenderTask { let mut render_task = RenderTask {
id: id,
port: port.take(), port: port.take(),
compositor: compositor, compositor: compositor,
font_ctx: @mut FontContext::new(opts.render_backend, font_ctx: @mut FontContext::new(opts.render_backend,
@ -130,14 +133,14 @@ impl<C: RenderListener + Owned> RenderTask<C> {
self.compositor_token = Some(token); self.compositor_token = Some(token);
match self.last_paint_msg { match self.last_paint_msg {
Some((ref layer_buffer_set, ref layer_size)) => { Some((ref layer_buffer_set, ref layer_size)) => {
self.compositor.paint(layer_buffer_set.clone(), *layer_size); self.compositor.paint(self.id, layer_buffer_set.clone(), *layer_size);
self.compositor.set_render_state(IdleRenderState); self.compositor.set_render_state(IdleRenderState);
} }
None => {} None => {}
} }
} }
TokenProcureMsg => { TokenInvalidateMsg => {
self.constellation_chan.send(TokenSurrenderMsg(self.compositor_token.swap_unwrap())); self.compositor_token = None;
} }
ExitMsg(response_ch) => { ExitMsg(response_ch) => {
response_ch.send(()); response_ch.send(());
@ -232,7 +235,7 @@ impl<C: RenderListener + Owned> RenderTask<C> {
debug!("render_task: returning surface"); debug!("render_task: returning surface");
if self.compositor_token.is_some() { if self.compositor_token.is_some() {
self.compositor.paint(layer_buffer_set.clone(), render_layer.size); self.compositor.paint(self.id, layer_buffer_set.clone(), render_layer.size);
} }
debug!("caching paint msg"); debug!("caching paint msg");
self.last_paint_msg = Some((layer_buffer_set, render_layer.size)); self.last_paint_msg = Some((layer_buffer_set, render_layer.size));

View file

@ -9,9 +9,11 @@ use script::layout_interface::{LayoutChan, RouteScriptMsg};
use windowing::{ApplicationMethods, WindowMethods, WindowMouseEvent, WindowClickEvent}; use windowing::{ApplicationMethods, WindowMethods, WindowMouseEvent, WindowClickEvent};
use windowing::{WindowMouseDownEvent, WindowMouseUpEvent}; use windowing::{WindowMouseDownEvent, WindowMouseUpEvent};
use servo_msg::compositor::{RenderListener, LayerBufferSet, RenderState};
use servo_msg::compositor::{ReadyState, ScriptListener}; use servo_msg::compositor_msg::{RenderListener, LayerBufferSet, RenderState};
use servo_msg::constellation; use servo_msg::compositor_msg::{ReadyState, ScriptListener};
use servo_msg::constellation_msg::{CompositorAck, ConstellationChan};
use servo_msg::constellation_msg;
use gfx::render_task::{RenderChan, ReRenderMsg}; use gfx::render_task::{RenderChan, ReRenderMsg};
use azure::azure_hl::{DataSourceSurface, DrawTarget, SourceSurfaceMethods, current_gl_context}; use azure::azure_hl::{DataSourceSurface, DrawTarget, SourceSurfaceMethods, current_gl_context};
@ -58,8 +60,8 @@ impl RenderListener for CompositorChan {
self.chan.send(GetGLContext(chan)); self.chan.send(GetGLContext(chan));
port.recv() port.recv()
} }
fn paint(&self, layer_buffer_set: LayerBufferSet, new_size: Size2D<uint>) { fn paint(&self, id: uint, layer_buffer_set: LayerBufferSet, new_size: Size2D<uint>) {
self.chan.send(Paint(layer_buffer_set, new_size)) self.chan.send(Paint(id, layer_buffer_set, new_size))
} }
fn set_render_state(&self, render_state: RenderState) { fn set_render_state(&self, render_state: RenderState) {
self.chan.send(ChangeRenderState(render_state)) self.chan.send(ChangeRenderState(render_state))
@ -84,15 +86,13 @@ pub enum Msg {
/// Requests the compositors GL context. /// Requests the compositors GL context.
GetGLContext(Chan<AzGLContext>), GetGLContext(Chan<AzGLContext>),
/// Requests that the compositor paint the given layer buffer set for the given page size. /// Requests that the compositor paint the given layer buffer set for the given page size.
Paint(LayerBufferSet, Size2D<uint>), Paint(uint, LayerBufferSet, Size2D<uint>),
/// Alerts the compositor to the current status of page loading. /// Alerts the compositor to the current status of page loading.
ChangeReadyState(ReadyState), ChangeReadyState(ReadyState),
/// Alerts the compositor to the current status of rendering. /// Alerts the compositor to the current status of rendering.
ChangeRenderState(RenderState), ChangeRenderState(RenderState),
/// Sets the channel to the current layout task /// Sets the channel to the current layout and render tasks, along with their id
SetLayoutChan(LayoutChan), SetLayoutRenderChans(LayoutChan, RenderChan , uint, ConstellationChan)
/// Sets the channel to the current renderer
SetRenderChan(RenderChan),
} }
/// Azure surface wrapping to work with the layers infrastructure. /// Azure surface wrapping to work with the layers infrastructure.
@ -180,13 +180,14 @@ impl CompositorTask {
// Channel to the current renderer. // Channel to the current renderer.
// FIXME: This probably shouldn't be stored like this. // FIXME: This probably shouldn't be stored like this.
let render_chan: @mut Option<RenderChan> = @mut None; let render_chan: @mut Option<RenderChan> = @mut None;
let pipeline_id: @mut Option<uint> = @mut None;
let update_layout_callbacks: @fn(LayoutChan) = |layout_chan: LayoutChan| { let update_layout_callbacks: @fn(LayoutChan) = |layout_chan: LayoutChan| {
let layout_chan_clone = layout_chan.clone(); let layout_chan_clone = layout_chan.clone();
do window.set_navigation_callback |direction| { do window.set_navigation_callback |direction| {
let direction = match direction { let direction = match direction {
windowing::Forward => constellation::Forward, windowing::Forward => constellation_msg::Forward,
windowing::Back => constellation::Back, windowing::Back => constellation_msg::Back,
}; };
layout_chan_clone.send(RouteScriptMsg(NavigateMsg(direction))); layout_chan_clone.send(RouteScriptMsg(NavigateMsg(direction)));
} }
@ -254,17 +255,24 @@ impl CompositorTask {
ChangeReadyState(ready_state) => window.set_ready_state(ready_state), ChangeReadyState(ready_state) => window.set_ready_state(ready_state),
ChangeRenderState(render_state) => window.set_render_state(render_state), ChangeRenderState(render_state) => window.set_render_state(render_state),
SetLayoutChan(layout_chan) => { SetLayoutRenderChans(new_layout_chan,
update_layout_callbacks(layout_chan); new_render_chan,
} new_pipeline_id,
response_chan) => {
SetRenderChan(new_render_chan) => { update_layout_callbacks(new_layout_chan);
*render_chan = Some(new_render_chan); *render_chan = Some(new_render_chan);
*pipeline_id = Some(new_pipeline_id);
response_chan.send(CompositorAck(new_pipeline_id));
} }
GetGLContext(chan) => chan.send(current_gl_context()), GetGLContext(chan) => chan.send(current_gl_context()),
Paint(new_layer_buffer_set, new_size) => { Paint(id, new_layer_buffer_set, new_size) => {
match *pipeline_id {
Some(pipeline_id) => if id != pipeline_id { loop; },
None => { loop; },
}
debug!("osmain: received new frame"); debug!("osmain: received new frame");
*page_size = Size2D(new_size.width as f32, new_size.height as f32); *page_size = Size2D(new_size.width as f32, new_size.height as f32);

View file

@ -2,18 +2,19 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use compositing::{CompositorChan, SetLayoutChan, SetRenderChan}; use compositing::{CompositorChan, SetLayoutRenderChans};
use std::cell::Cell; use std::cell::Cell;
use std::comm; use std::comm;
use std::comm::Port; use std::comm::Port;
use std::task; use std::task;
use gfx::opts::Opts; use gfx::opts::Opts;
use gfx::render_task::{TokenBestowMsg, TokenProcureMsg}; use gfx::render_task::{TokenBestowMsg, TokenInvalidateMsg};
use pipeline::Pipeline; use pipeline::Pipeline;
use servo_msg::compositor::{CompositorToken}; use servo_msg::compositor_msg::{CompositorToken};
use servo_msg::constellation::{ConstellationChan, ExitMsg, LoadUrlMsg, Msg, NavigateMsg}; use servo_msg::constellation_msg::{CompositorAck, ConstellationChan, ExitMsg};
use servo_msg::constellation::{Forward, Back, RendererReadyMsg, TokenSurrenderMsg}; use servo_msg::constellation_msg::{LoadUrlMsg, Msg, NavigateMsg, RendererReadyMsg};
use servo_msg::constellation_msg;
use script::script_task::ExecuteMsg; use script::script_task::ExecuteMsg;
use servo_net::image_cache_task::{ImageCacheTask, ImageCacheTaskClient}; use servo_net::image_cache_task::{ImageCacheTask, ImageCacheTaskClient};
use servo_net::resource_task::ResourceTask; use servo_net::resource_task::ResourceTask;
@ -22,6 +23,7 @@ use servo_util::time::ProfilerChan;
use std::hashmap::HashMap; use std::hashmap::HashMap;
use std::util::replace; use std::util::replace;
/// Maintains the pipelines and navigation context and grants permission to composite
pub struct Constellation { pub struct Constellation {
chan: ConstellationChan, chan: ConstellationChan,
request_port: Port<Msg>, request_port: Port<Msg>,
@ -32,18 +34,11 @@ pub struct Constellation {
navigation_context: NavigationContext, navigation_context: NavigationContext,
next_id: uint, next_id: uint,
current_token_bearer: Option<uint>, current_token_bearer: Option<uint>,
next_token_bearer: Option<(uint, NavigationType)>, next_token_bearer: Option<uint>,
compositor_token: Option<~CompositorToken>,
profiler_chan: ProfilerChan, profiler_chan: ProfilerChan,
opts: Opts, opts: Opts,
} }
/// Represents the two different ways to which a page can be navigated
enum NavigationType {
Load, // entered or clicked on a url
Navigate, // browser forward/back buttons
}
/// Stores the ID's of the pipelines previous and next in the browser's history /// Stores the ID's of the pipelines previous and next in the browser's history
pub struct NavigationContext { pub struct NavigationContext {
previous: ~[uint], previous: ~[uint],
@ -60,6 +55,9 @@ impl NavigationContext {
} }
} }
/* Note that the following two methods can fail. They should only be called *
* when it is known that, e.g., there exists a previous page or a next page. */
pub fn back(&mut self) -> uint { pub fn back(&mut self) -> uint {
self.next.push(self.current.get()); self.next.push(self.current.get());
self.current = Some(self.previous.pop()); self.current = Some(self.previous.pop());
@ -75,6 +73,7 @@ impl NavigationContext {
} }
pub fn navigate(&mut self, id: uint) { pub fn navigate(&mut self, id: uint) {
self.next.clear();
do self.current.mutate_default(id) |cur_id| { do self.current.mutate_default(id) |cur_id| {
self.previous.push(cur_id); self.previous.push(cur_id);
id id
@ -98,7 +97,6 @@ impl Constellation {
let compositor_chan = Cell::new(compositor_chan); let compositor_chan = Cell::new(compositor_chan);
let constellation_chan_clone = Cell::new(constellation_chan.clone()); let constellation_chan_clone = Cell::new(constellation_chan.clone());
{
do task::spawn { do task::spawn {
let mut constellation = Constellation { let mut constellation = Constellation {
chan: constellation_chan_clone.take(), chan: constellation_chan_clone.take(),
@ -111,13 +109,11 @@ impl Constellation {
next_id: 0, next_id: 0,
current_token_bearer: None, current_token_bearer: None,
next_token_bearer: None, next_token_bearer: None,
compositor_token: Some(~CompositorToken::new()),
profiler_chan: profiler_chan.clone(), profiler_chan: profiler_chan.clone(),
opts: opts.take(), opts: opts.take(),
}; };
constellation.run(); constellation.run();
} }
}
constellation_chan constellation_chan
} }
@ -140,6 +136,7 @@ impl Constellation {
/// Handles loading pages, navigation, and granting access to the compositor /// Handles loading pages, navigation, and granting access to the compositor
fn handle_request(&mut self, request: Msg) -> bool { fn handle_request(&mut self, request: Msg) -> bool {
match request { match request {
// Load a new page, usually either from a mouse click or typed url
LoadUrlMsg(url) => { LoadUrlMsg(url) => {
let pipeline_id = self.get_next_id(); let pipeline_id = self.get_next_id();
let mut pipeline = Pipeline::create(pipeline_id, let mut pipeline = Pipeline::create(pipeline_id,
@ -153,22 +150,24 @@ impl Constellation {
pipeline.script_chan.send(ExecuteMsg(url)); pipeline.script_chan.send(ExecuteMsg(url));
} else { } else {
pipeline.load(url); pipeline.load(url);
self.next_token_bearer = Some((pipeline_id, Load)); pipeline.navigation_type = Some(constellation_msg::Load);
self.next_token_bearer = Some(pipeline_id);
} }
self.pipelines.insert(pipeline_id, pipeline); self.pipelines.insert(pipeline_id, pipeline);
} }
// Handle a forward or back request
NavigateMsg(direction) => { NavigateMsg(direction) => {
debug!("received message to navigate %?", direction); debug!("received message to navigate %?", direction);
let destination_id = match direction { let destination_id = match direction {
Forward => { constellation_msg::Forward => {
if self.navigation_context.next.is_empty() { if self.navigation_context.next.is_empty() {
debug!("no next page to navigate to"); debug!("no next page to navigate to");
return true return true
} }
self.navigation_context.forward() self.navigation_context.forward()
} }
Back => { constellation_msg::Back => {
if self.navigation_context.previous.is_empty() { if self.navigation_context.previous.is_empty() {
debug!("no previous page to navigate to"); debug!("no previous page to navigate to");
return true return true
@ -177,27 +176,27 @@ impl Constellation {
} }
}; };
debug!("navigating to pipeline %u", destination_id); debug!("navigating to pipeline %u", destination_id);
self.pipelines.get(&destination_id).reload(); let mut pipeline = self.pipelines.pop(&destination_id).unwrap();
self.next_token_bearer = Some((destination_id, Navigate)); pipeline.navigation_type = Some(constellation_msg::Navigate);
self.procure_or_bestow(); pipeline.reload();
self.pipelines.insert(destination_id, pipeline);
self.next_token_bearer = Some(destination_id);
self.update_token_bearer();
} }
// Notification that rendering has finished and is requesting permission to paint.
RendererReadyMsg(pipeline_id) => { RendererReadyMsg(pipeline_id) => {
let next_token_bearer = self.next_token_bearer; let next_token_bearer = self.next_token_bearer;
for next_token_bearer.iter().advance |&(id, _)| { for next_token_bearer.iter().advance |&id| {
if pipeline_id == id { if pipeline_id == id {
self.procure_or_bestow(); self.update_token_bearer();
}
} }
};
} }
TokenSurrenderMsg(token) => { // Acknowledgement from the compositor that it has updated its active pipeline id
self.remove_active_pipeline(); CompositorAck(id) => {
let token = Cell::new(token); self.bestow_compositor_token(id);
let next_token_bearer = self.next_token_bearer;
for next_token_bearer.iter().advance |&(id, nav_type)| {
self.bestow_compositor_token(id, token.take(), nav_type);
};
} }
ExitMsg(sender) => { ExitMsg(sender) => {
@ -214,43 +213,28 @@ impl Constellation {
true true
} }
/// Either procures the token, sends the token to next bearer, or does nothing if waiting for token surrender. fn update_token_bearer(&mut self) {
fn procure_or_bestow(&mut self) {
let current_token_bearer = replace(&mut self.current_token_bearer, None); let current_token_bearer = replace(&mut self.current_token_bearer, None);
match current_token_bearer { for current_token_bearer.iter().advance |id| {
Some(ref id) => { self.pipelines.get(id).render_chan.send(TokenInvalidateMsg);
let pipeline = self.pipelines.get(id);
pipeline.render_chan.send(TokenProcureMsg);
} }
None => { let id = self.next_token_bearer.get();
let compositor_token = replace(&mut self.compositor_token, None);
for compositor_token.iter().advance |&token| {
let (id, nav_type) = self.next_token_bearer.get();
self.bestow_compositor_token(id, token, nav_type);
}
}
};
}
fn remove_active_pipeline(&mut self) {
// FIXME(tkuehn): currently, pipelines are not removed at all
// do self.current_token_bearer.map |id| {
// self.pipelines.pop(id).unwrap().exit();
// };
self.current_token_bearer = None;
}
fn bestow_compositor_token(&mut self, id: uint, compositor_token: ~CompositorToken, navigation_type: NavigationType) {
let pipeline = self.pipelines.get(&id); let pipeline = self.pipelines.get(&id);
pipeline.render_chan.send(TokenBestowMsg(compositor_token)); self.compositor_chan.send(SetLayoutRenderChans(pipeline.layout_chan.clone(),
self.compositor_chan.send(SetLayoutChan(pipeline.layout_chan.clone())); pipeline.render_chan.clone(),
self.compositor_chan.send(SetRenderChan(pipeline.render_chan.clone())); id,
self.chan.clone()));
}
// Sends a compositor token to a renderer; optionally updates navigation to reflect a new page
fn bestow_compositor_token(&mut self, id: uint) {
let pipeline = self.pipelines.get(&id);
pipeline.render_chan.send(TokenBestowMsg(CompositorToken::new()));
self.current_token_bearer = Some(id); self.current_token_bearer = Some(id);
self.next_token_bearer = None; self.next_token_bearer = None;
// Don't navigate on Navigate type, because that is handled by forward/back // Don't navigate on Navigate type, because that is handled by forward/back
match navigation_type { match pipeline.navigation_type.get() {
Load => self.navigation_context.navigate(id), constellation_msg::Load => self.navigation_context.navigate(id),
_ => {} _ => {}
} }
} }

View file

@ -10,14 +10,23 @@ use gfx::opts::Opts;
use layout::layout_task::LayoutTask; use layout::layout_task::LayoutTask;
use script::layout_interface::LayoutChan; use script::layout_interface::LayoutChan;
use script::script_task::LoadMsg; use script::script_task::LoadMsg;
use servo_msg::constellation::{ConstellationChan}; use servo_msg::constellation_msg::{ConstellationChan, NavigationType};
use script::script_task::{ScriptTask, ScriptChan, ScriptMsg}; use script::script_task::{ScriptTask, ScriptChan};
use script::script_task; use script::script_task;
use servo_net::image_cache_task::ImageCacheTask; use servo_net::image_cache_task::ImageCacheTask;
use servo_net::resource_task::ResourceTask; use servo_net::resource_task::ResourceTask;
use servo_util::time::ProfilerChan; use servo_util::time::ProfilerChan;
use std::comm; use std::comm;
macro_rules! special_stream(
($Chan:ident) => (
{
let (port, chan) = comm::stream::();
(port, $Chan::new(chan))
}
);
)
/// A uniquely-identifiable pipeline of stript task, layout task, and render task. /// A uniquely-identifiable pipeline of stript task, layout task, and render task.
pub struct Pipeline { pub struct Pipeline {
id: uint, id: uint,
@ -26,6 +35,7 @@ pub struct Pipeline {
render_chan: RenderChan, render_chan: RenderChan,
/// The most recently loaded url /// The most recently loaded url
url: Option<Url>, url: Option<Url>,
navigation_type: Option<NavigationType>,
} }
impl Pipeline { impl Pipeline {
@ -38,24 +48,12 @@ impl Pipeline {
profiler_chan: ProfilerChan, profiler_chan: ProfilerChan,
opts: Opts) -> Pipeline { opts: Opts) -> Pipeline {
macro_rules! closure_stream( let (script_port, script_chan) = special_stream!(ScriptChan);
($Msg:ty, $Chan:ident) => ( let (layout_port, layout_chan) = special_stream!(LayoutChan);
{ let (render_port, render_chan) = special_stream!(RenderChan);
let (port, chan) = comm::stream::<$Msg>();
(port, $Chan::new(chan))
}
);
)
// Create the script port and channel.
let (script_port, script_chan) = closure_stream!(ScriptMsg, ScriptChan);
// Create the layout port and channel. RenderTask::create(id,
let (layout_port, layout_chan) = closure_stream!(layout_interface::Msg, LayoutChan); render_port,
let (render_port, render_chan) = comm::stream::<render_task::Msg>();
let render_chan = RenderChan::new(render_chan);
RenderTask::create(render_port,
compositor_chan.clone(), compositor_chan.clone(),
copy opts, copy opts,
constellation_chan.clone(), constellation_chan.clone(),
@ -94,6 +92,7 @@ impl Pipeline {
layout_chan: layout_chan, layout_chan: layout_chan,
render_chan: render_chan, render_chan: render_chan,
url: None, url: None,
navigation_type: None,
} }
} }

View file

@ -15,8 +15,8 @@ use alert::{Alert, AlertMethods};
use std::libc::c_int; use std::libc::c_int;
use geom::point::Point2D; use geom::point::Point2D;
use geom::size::Size2D; use geom::size::Size2D;
use servo_msg::compositor::{IdleRenderState, RenderState, RenderingRenderState}; use servo_msg::compositor_msg::{IdleRenderState, RenderState, RenderingRenderState};
use servo_msg::compositor::{FinishedLoading, Loading, PerformingLayout, ReadyState}; use servo_msg::compositor_msg::{FinishedLoading, Loading, PerformingLayout, ReadyState};
use glut::glut::{ACTIVE_CTRL, ACTIVE_SHIFT, DOUBLE, HAVE_PRECISE_MOUSE_WHEEL, WindowHeight}; use glut::glut::{ACTIVE_CTRL, ACTIVE_SHIFT, DOUBLE, HAVE_PRECISE_MOUSE_WHEEL, WindowHeight};
use glut::glut::WindowWidth; use glut::glut::WindowWidth;
use glut::glut; use glut::glut;

View file

@ -36,7 +36,7 @@ extern mod core_text;
use compositing::{CompositorChan, CompositorTask}; use compositing::{CompositorChan, CompositorTask};
use constellation::Constellation; use constellation::Constellation;
use servo_msg::constellation::{ExitMsg, LoadUrlMsg}; use servo_msg::constellation_msg::{ExitMsg, LoadUrlMsg};
use gfx::opts; use gfx::opts;
use servo_net::image_cache_task::ImageCacheTask; use servo_net::image_cache_task::ImageCacheTask;

View file

@ -6,7 +6,7 @@
use geom::point::Point2D; use geom::point::Point2D;
use geom::size::Size2D; use geom::size::Size2D;
use servo_msg::compositor::{ReadyState, RenderState}; use servo_msg::compositor_msg::{ReadyState, RenderState};
pub enum WindowMouseEvent { pub enum WindowMouseEvent {
WindowClickEvent(uint, Point2D<f32>), WindowClickEvent(uint, Point2D<f32>),

View file

@ -49,7 +49,7 @@ pub enum ReadyState {
/// submit them to be drawn to the display. /// submit them to be drawn to the display.
pub trait RenderListener { pub trait RenderListener {
fn get_gl_context(&self) -> AzGLContext; fn get_gl_context(&self) -> AzGLContext;
fn paint(&self, layer_buffer_set: LayerBufferSet, new_size: Size2D<uint>); fn paint(&self, id: uint, layer_buffer_set: LayerBufferSet, new_size: Size2D<uint>);
fn set_render_state(&self, render_state: RenderState); fn set_render_state(&self, render_state: RenderState);
} }
@ -59,8 +59,10 @@ pub trait ScriptListener : Clone {
fn set_ready_state(&self, ReadyState); fn set_ready_state(&self, ReadyState);
} }
/// Signifies control of the compositor. Only the render task controlling /// Signifies to the renderer likely control of the compositor. Controlling the compositor token
/// the compositor token may send paint messages to the compositor /// is necessary but not sufficient for the renderer to successfully send paint messages to the
/// compositor. Only the render tasks controlling compositor tokens may send messages, and the
/// compositor is guaranteed to only accept messages from one of those tasks at a time.
pub struct CompositorToken { pub struct CompositorToken {
construction_restrictor: NonCopyable, construction_restrictor: NonCopyable,
} }

View file

@ -7,7 +7,6 @@
use std::comm::{Chan, SharedChan}; use std::comm::{Chan, SharedChan};
use extra::net::url::Url; use extra::net::url::Url;
use compositor::CompositorToken;
#[deriving(Clone)] #[deriving(Clone)]
pub struct ConstellationChan { pub struct ConstellationChan {
@ -30,7 +29,13 @@ pub enum Msg {
NavigateMsg(NavigationDirection), NavigateMsg(NavigationDirection),
ExitMsg(Chan<()>), ExitMsg(Chan<()>),
RendererReadyMsg(uint), RendererReadyMsg(uint),
TokenSurrenderMsg(~CompositorToken), CompositorAck(uint),
}
/// Represents the two different ways to which a page can be navigated
enum NavigationType {
Load, // entered or clicked on a url
Navigate, // browser forward/back buttons
} }
pub enum NavigationDirection { pub enum NavigationDirection {

View file

@ -14,5 +14,5 @@ extern mod std;
extern mod geom; extern mod geom;
extern mod extra; extern mod extra;
pub mod compositor; pub mod compositor_msg;
pub mod constellation; pub mod constellation_msg;

View file

@ -5,8 +5,8 @@
/// The script task is the task that owns the DOM in memory, runs JavaScript, and spawns parsing /// The script task is the task that owns the DOM in memory, runs JavaScript, and spawns parsing
/// and layout tasks. /// and layout tasks.
use servo_msg::compositor::{ScriptListener, Loading, PerformingLayout}; use servo_msg::compositor_msg::{ScriptListener, Loading, PerformingLayout};
use servo_msg::compositor::FinishedLoading; use servo_msg::compositor_msg::FinishedLoading;
use dom::bindings::utils::GlobalStaticData; use dom::bindings::utils::GlobalStaticData;
use dom::document::Document; use dom::document::Document;
use dom::element::Element; use dom::element::Element;
@ -19,9 +19,9 @@ use layout_interface::{LayoutChan, MatchSelectorsDocumentDamage, QueryMsg, Reflo
use layout_interface::{ReflowDocumentDamage, ReflowForDisplay, ReflowForScriptQuery, ReflowGoal}; use layout_interface::{ReflowDocumentDamage, ReflowForDisplay, ReflowForScriptQuery, ReflowGoal};
use layout_interface::ReflowMsg; use layout_interface::ReflowMsg;
use layout_interface; use layout_interface;
use servo_msg::constellation::{ConstellationChan, LoadUrlMsg, NavigationDirection}; use servo_msg::constellation_msg::{ConstellationChan, LoadUrlMsg, NavigationDirection};
use servo_msg::constellation::RendererReadyMsg; use servo_msg::constellation_msg::RendererReadyMsg;
use servo_msg::constellation; use servo_msg::constellation_msg;
use std::cast::transmute; use std::cast::transmute;
use std::cell::Cell; use std::cell::Cell;
@ -337,7 +337,7 @@ impl ScriptTask {
/// Handles a navigate forward or backward message. /// Handles a navigate forward or backward message.
fn handle_navigate_msg(&self, direction: NavigationDirection) { fn handle_navigate_msg(&self, direction: NavigationDirection) {
self.constellation_chan.send(constellation::NavigateMsg(direction)); self.constellation_chan.send(constellation_msg::NavigateMsg(direction));
} }
/// Handles a request to exit the script task and shut down layout. /// Handles a request to exit the script task and shut down layout.
@ -594,7 +594,7 @@ impl ScriptTask {
Err(()) => { Err(()) => {
debug!(fmt!("layout query error")); debug!(fmt!("layout query error"));
} }
}; }
} }
MouseDownEvent(*) => {} MouseDownEvent(*) => {}
MouseUpEvent(*) => {} MouseUpEvent(*) => {}