diff options
author | bors-servo <release+servo@mozilla.com> | 2013-12-16 08:19:17 -0800 |
---|---|---|
committer | bors-servo <release+servo@mozilla.com> | 2013-12-16 08:19:17 -0800 |
commit | 01e4ac5266d58bc5f295bf525bb4cac78e45103f (patch) | |
tree | ad6fec10afd8537b01e3cefcee8206a6e28a9d92 /src | |
parent | 5302d870f48415aa879761017e068cf2f84a1e1d (diff) | |
parent | 43b3d7bcfe7c8efe1d86ea45485647f6c35f1732 (diff) | |
download | servo-01e4ac5266d58bc5f295bf525bb4cac78e45103f.tar.gz servo-01e4ac5266d58bc5f295bf525bb4cac78e45103f.zip |
auto merge of #1419 : saneyuki/servo/create, r=pcwalton
This hide initializing steps of `CompositorTask` to make it easy to handle variables which related to compositor code.
Related: #1351.
Diffstat (limited to 'src')
-rw-r--r-- | src/components/main/compositing/mod.rs | 35 | ||||
-rwxr-xr-x | src/components/main/servo.rc | 19 |
2 files changed, 35 insertions, 19 deletions
diff --git a/src/components/main/compositing/mod.rs b/src/components/main/compositing/mod.rs index 6d7ab4afa3b..a6c1a0ffbd0 100644 --- a/src/components/main/compositing/mod.rs +++ b/src/components/main/compositing/mod.rs @@ -16,7 +16,7 @@ use gfx::opts::Opts; use layers::platform::surface::{NativeCompositingGraphicsContext, NativeGraphicsMetadata}; use servo_msg::compositor_msg::{Epoch, RenderListener, LayerBufferSet, RenderState, ReadyState}; use servo_msg::compositor_msg::{ScriptListener, Tile}; -use servo_msg::constellation_msg::{ConstellationChan, PipelineId}; +use servo_msg::constellation_msg::{ConstellationChan, PipelineId, ExitMsg}; use servo_util::time::ProfilerChan; use std::comm::{Chan, SharedChan, Port}; use std::comm; @@ -160,11 +160,11 @@ pub struct CompositorTask { } impl CompositorTask { - pub fn new(opts: Opts, - port: Port<Msg>, - constellation_chan: ConstellationChan, - profiler_chan: ProfilerChan) - -> CompositorTask { + fn new(opts: Opts, + port: Port<Msg>, + constellation_chan: ConstellationChan, + profiler_chan: ProfilerChan) + -> CompositorTask { let mode: CompositorMode = if opts.headless { Headless @@ -193,10 +193,31 @@ impl CompositorTask { NativeCompositingGraphicsContext::new() } - pub fn run(&self) { + pub fn create(opts: Opts, + port: Port<Msg>, + constellation_chan: ConstellationChan, + profiler_chan: ProfilerChan, + exit_chan: Chan<()>, + exit_response_from_constellation: Port<()>) { + let compositor = CompositorTask::new(opts, + port, + constellation_chan, + profiler_chan); + compositor.run(exit_chan, exit_response_from_constellation); + } + + fn run(&self, + exit_chan: Chan<()>, + exit_response_from_constellation: Port<()>) { match self.mode { Windowed(ref app) => run::run_compositor(self, app), Headless => run_headless::run_compositor(self), } + + // Constellation has to be shut down before the compositor goes out of + // scope, as the compositor manages setup/teardown of global subsystems + debug!("shutting down the constellation"); + self.constellation_chan.send(ExitMsg(exit_chan)); + exit_response_from_constellation.recv(); } } diff --git a/src/components/main/servo.rc b/src/components/main/servo.rc index 78b4fea12ec..b5a177c91c1 100755 --- a/src/components/main/servo.rc +++ b/src/components/main/servo.rc @@ -41,7 +41,7 @@ extern mod core_text = "rust-core-text"; use compositing::{CompositorChan, CompositorTask}; use constellation::Constellation; -use servo_msg::constellation_msg::{ConstellationChan, ExitMsg, InitLoadUrlMsg}; +use servo_msg::constellation_msg::{ConstellationChan, InitLoadUrlMsg}; #[cfg(not(test))] use gfx::opts; @@ -160,18 +160,13 @@ fn run(opts: Opts) { } } - let compositor_task = CompositorTask::new(opts, - compositor_port, - constellation_chan.clone(), - profiler_chan); debug!("preparing to enter main loop"); - compositor_task.run(); - - // Constellation has to be shut down before the compositor goes out of - // scope, as the compositor manages setup/teardown of global subsystems - debug!("shutting down the constellation"); - constellation_chan.send(ExitMsg(exit_chan)); - exit_response_from_constellation.recv(); + CompositorTask::create(opts, + compositor_port, + constellation_chan.clone(), + profiler_chan, + exit_chan, + exit_response_from_constellation); } |