diff --git a/src/components/gfx/compositor.rs b/src/components/gfx/compositor.rs index b0f599c1f4d..46e09800685 100644 --- a/src/components/gfx/compositor.rs +++ b/src/components/gfx/compositor.rs @@ -32,7 +32,7 @@ pub enum RenderState { RenderingRenderState, } -/// The interface used to by the renderer to acquire draw targets for each rendered frame and +/// The interface used by the renderer to acquire draw targets for each rendered frame and /// submit them to be drawn to the display. pub trait RenderListener { fn get_gl_context(&self) -> AzGLContext; diff --git a/src/components/gfx/render_task.rs b/src/components/gfx/render_task.rs index 41341554e27..8cb63f885f1 100644 --- a/src/components/gfx/render_task.rs +++ b/src/components/gfx/render_task.rs @@ -22,31 +22,39 @@ use servo_net::util::spawn_listener; use servo_util::time::{ProfilerChan, profile}; use servo_util::time; -pub enum Msg { +pub enum Msg { + AttachCompositorMsg(C), RenderMsg(RenderLayer), ExitMsg(Chan<()>), } -#[deriving(Clone)] -pub struct RenderChan { - chan: SharedChan, +pub struct RenderChan { + chan: SharedChan>, } -impl RenderChan { - pub fn new(chan: Chan) -> RenderChan { +impl Clone for RenderChan { + pub fn clone(&self) -> RenderChan { + RenderChan { + chan: self.chan.clone(), + } + } +} + +impl RenderChan { + pub fn new(chan: Chan>) -> RenderChan { RenderChan { chan: SharedChan::new(chan), } } - pub fn send(&self, msg: Msg) { + pub fn send(&self, msg: Msg) { self.chan.send(msg); } } -pub fn create_render_task(port: Port, - compositor: C, - opts: Opts, - profiler_chan: ProfilerChan) { +pub fn create_render_task(port: Port>, + compositor: C, + opts: Opts, + profiler_chan: ProfilerChan) { let compositor_cell = Cell(compositor); let opts_cell = Cell(opts); let port = Cell(port); @@ -103,7 +111,7 @@ priv struct ThreadRenderContext { } priv struct Renderer { - port: Port, + port: Port>, compositor: C, thread_pool: TaskPool, opts: Opts, @@ -120,6 +128,7 @@ impl Renderer { loop { match self.port.recv() { + AttachCompositorMsg(compositor) => self.compositor = compositor, RenderMsg(render_layer) => self.render(render_layer), ExitMsg(response_ch) => { response_ch.send(()); diff --git a/src/components/main/compositing/mod.rs b/src/components/main/compositing/mod.rs index cf42af2a6b9..ba32b706c41 100644 --- a/src/components/main/compositing/mod.rs +++ b/src/components/main/compositing/mod.rs @@ -132,7 +132,7 @@ impl CompositorTask { } /// Starts the compositor, which listens for messages on the specified port. - pub fn create_compositor_task(port: Port, + pub fn create(port: Port, profiler_chan: ProfilerChan, shutdown_chan: Chan<()>) { let port = Cell(port); diff --git a/src/components/main/engine.rs b/src/components/main/engine.rs index 8a8b30dc226..1abc00537c4 100644 --- a/src/components/main/engine.rs +++ b/src/components/main/engine.rs @@ -24,7 +24,7 @@ use servo_util::time::{ProfilerChan}; pub struct Engine { request_port: Port, compositor_chan: CompositorChan, - render_chan: RenderChan, + render_chan: RenderChan, resource_task: ResourceTask, image_cache_task: ImageCacheTask, layout_chan: LayoutChan, @@ -32,12 +32,6 @@ pub struct Engine { profiler_chan: ProfilerChan, } -impl Drop for Engine { - fn finalize(&self) { - //self.profiler_chan.send(ForcePrintMsg); - } -} - impl Engine { pub fn start(compositor_chan: CompositorChan, opts: &Opts, @@ -63,7 +57,9 @@ impl Engine { // Create the layout port and channel. let (layout_port, layout_chan) = closure_stream!(layout_interface::Msg, LayoutChan); - let (render_port, render_chan) = closure_stream!(render_task::Msg, RenderChan); + let (render_port, render_chan) = comm::stream::>(); + let (render_port, render_chan) = (Cell(render_port), RenderChan::new(render_chan)); + compositor_chan.send(SetLayoutChan(layout_chan.clone())); let compositor_chan = Cell(compositor_chan); diff --git a/src/components/main/layout/layout_task.rs b/src/components/main/layout/layout_task.rs index 506f1d20769..fcdc8cc6b24 100644 --- a/src/components/main/layout/layout_task.rs +++ b/src/components/main/layout/layout_task.rs @@ -5,6 +5,7 @@ //! The layout task. Performs layout on the DOM, builds display lists and sends them to be /// rendered. +use compositing::CompositorChan; use css::matching::MatchMethods; use css::select::new_css_select_ctx; use layout::aux::{LayoutData, LayoutAuxMethods}; @@ -47,7 +48,7 @@ use std::net::url::Url; pub fn create_layout_task(port: Port, script_chan: ScriptChan, - render_chan: RenderChan, + render_chan: RenderChan, img_cache_task: ImageCacheTask, opts: Opts, profiler_chan: ProfilerChan) { @@ -66,7 +67,7 @@ pub fn create_layout_task(port: Port, struct Layout { port: Port, script_chan: ScriptChan, - render_chan: RenderChan, + render_chan: RenderChan, image_cache_task: ImageCacheTask, local_image_cache: @mut LocalImageCache, font_ctx: @mut FontContext, @@ -83,7 +84,7 @@ struct Layout { impl Layout { fn new(port: Port, script_chan: ScriptChan, - render_chan: RenderChan, + render_chan: RenderChan, image_cache_task: ImageCacheTask, opts: &Opts, profiler_chan: ProfilerChan) diff --git a/src/components/main/platform/common/glut_windowing.rs b/src/components/main/platform/common/glut_windowing.rs index a6ee264437c..50e67d6e541 100644 --- a/src/components/main/platform/common/glut_windowing.rs +++ b/src/components/main/platform/common/glut_windowing.rs @@ -12,7 +12,6 @@ use windowing::{ResizeCallback, ScrollCallback, WindowMethods, WindowMouseEvent, use windowing::{WindowMouseDownEvent, WindowMouseUpEvent, ZoomCallback}; use alert::{Alert, AlertMethods}; -use core::cell::Cell; use core::libc::c_int; use geom::point::Point2D; use geom::size::Size2D; diff --git a/src/components/main/servo.rc b/src/components/main/servo.rc index 072d718b824..8357d4136d1 100755 --- a/src/components/main/servo.rc +++ b/src/components/main/servo.rc @@ -93,7 +93,7 @@ fn run(opts: &Opts) { // Create the profiler channel. let (profiler_port, profiler_chan) = comm::stream(); let profiler_chan = ProfilerChan::new(profiler_chan); - Profiler::create_profiler(profiler_port); + Profiler::create(profiler_port); do opts.profiler_period.map |period| { let profiler_chan = profiler_chan.clone(); let period = *period; @@ -109,7 +109,7 @@ fn run(opts: &Opts) { // Create the compositor. let (compositor_port, compositor_chan) = comm::stream(); let compositor_chan = CompositorChan::new(compositor_chan); - CompositorTask::create_compositor_task(compositor_port, profiler_chan.clone(), shutdown_chan); + CompositorTask::create(compositor_port, profiler_chan.clone(), shutdown_chan); // Create a Servo instance. diff --git a/src/components/script/compositor_interface.rs b/src/components/script/compositor_interface.rs index 1f8462f5463..b0041e49298 100644 --- a/src/components/script/compositor_interface.rs +++ b/src/components/script/compositor_interface.rs @@ -14,6 +14,8 @@ pub enum ReadyState { FinishedLoading, } +/// The interface used by the script task to tell the compositor to update its ready state, +/// which is used in displaying the appropriate message in the window's title. pub trait ScriptListener : Clone { fn set_ready_state(&self, ReadyState); } diff --git a/src/components/util/time.rs b/src/components/util/time.rs index 8d1cdfc7091..95bdc207e34 100644 --- a/src/components/util/time.rs +++ b/src/components/util/time.rs @@ -110,7 +110,7 @@ impl ProfilerCategory { } impl Profiler { - pub fn create_profiler(port: Port) { + pub fn create(port: Port) { let port = Cell(port); do spawn { let mut profiler = Profiler::new(port.take()); diff --git a/src/support/css/rust-css b/src/support/css/rust-css index 09d2db847c1..865f5391143 160000 --- a/src/support/css/rust-css +++ b/src/support/css/rust-css @@ -1 +1 @@ -Subproject commit 09d2db847c11bcab7f1832d5daf5947a7c1384ee +Subproject commit 865f539114383a021822583801e8362faf916699 diff --git a/src/support/glut/rust-glut b/src/support/glut/rust-glut index 6f6b6fa9591..453bf81e021 160000 --- a/src/support/glut/rust-glut +++ b/src/support/glut/rust-glut @@ -1 +1 @@ -Subproject commit 6f6b6fa95914fa6322f3277c803fd4921601cb90 +Subproject commit 453bf81e021008f5eba29b135f07f4529e6c8b2e