mirror of
https://github.com/servo/servo.git
synced 2025-06-21 23:59:00 +01:00
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.
This commit is contained in:
commit
01e4ac5266
2 changed files with 35 additions and 19 deletions
|
@ -16,7 +16,7 @@ use gfx::opts::Opts;
|
||||||
use layers::platform::surface::{NativeCompositingGraphicsContext, NativeGraphicsMetadata};
|
use layers::platform::surface::{NativeCompositingGraphicsContext, NativeGraphicsMetadata};
|
||||||
use servo_msg::compositor_msg::{Epoch, RenderListener, LayerBufferSet, RenderState, ReadyState};
|
use servo_msg::compositor_msg::{Epoch, RenderListener, LayerBufferSet, RenderState, ReadyState};
|
||||||
use servo_msg::compositor_msg::{ScriptListener, Tile};
|
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 servo_util::time::ProfilerChan;
|
||||||
use std::comm::{Chan, SharedChan, Port};
|
use std::comm::{Chan, SharedChan, Port};
|
||||||
use std::comm;
|
use std::comm;
|
||||||
|
@ -160,11 +160,11 @@ pub struct CompositorTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CompositorTask {
|
impl CompositorTask {
|
||||||
pub fn new(opts: Opts,
|
fn new(opts: Opts,
|
||||||
port: Port<Msg>,
|
port: Port<Msg>,
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
profiler_chan: ProfilerChan)
|
profiler_chan: ProfilerChan)
|
||||||
-> CompositorTask {
|
-> CompositorTask {
|
||||||
|
|
||||||
let mode: CompositorMode = if opts.headless {
|
let mode: CompositorMode = if opts.headless {
|
||||||
Headless
|
Headless
|
||||||
|
@ -193,10 +193,31 @@ impl CompositorTask {
|
||||||
NativeCompositingGraphicsContext::new()
|
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 {
|
match self.mode {
|
||||||
Windowed(ref app) => run::run_compositor(self, app),
|
Windowed(ref app) => run::run_compositor(self, app),
|
||||||
Headless => run_headless::run_compositor(self),
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ extern mod core_text = "rust-core-text";
|
||||||
|
|
||||||
use compositing::{CompositorChan, CompositorTask};
|
use compositing::{CompositorChan, CompositorTask};
|
||||||
use constellation::Constellation;
|
use constellation::Constellation;
|
||||||
use servo_msg::constellation_msg::{ConstellationChan, ExitMsg, InitLoadUrlMsg};
|
use servo_msg::constellation_msg::{ConstellationChan, InitLoadUrlMsg};
|
||||||
|
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
use gfx::opts;
|
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");
|
debug!("preparing to enter main loop");
|
||||||
compositor_task.run();
|
CompositorTask::create(opts,
|
||||||
|
compositor_port,
|
||||||
// Constellation has to be shut down before the compositor goes out of
|
constellation_chan.clone(),
|
||||||
// scope, as the compositor manages setup/teardown of global subsystems
|
profiler_chan,
|
||||||
debug!("shutting down the constellation");
|
exit_chan,
|
||||||
constellation_chan.send(ExitMsg(exit_chan));
|
exit_response_from_constellation);
|
||||||
exit_response_from_constellation.recv();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue