diff --git a/src/components/main/compositing/run.rs b/src/components/main/compositing/compositor.rs similarity index 99% rename from src/components/main/compositing/run.rs rename to src/components/main/compositing/compositor.rs index 880beb82aa6..7add72d2a0c 100644 --- a/src/components/main/compositing/run.rs +++ b/src/components/main/compositing/compositor.rs @@ -189,7 +189,6 @@ impl IOCompositor { } fn handle_message(&mut self) { - // Handle messages while self.port.peek() { match self.port.recv() { Exit => { diff --git a/src/components/main/compositing/mod.rs b/src/components/main/compositing/compositor_task.rs similarity index 93% rename from src/components/main/compositing/mod.rs rename to src/components/main/compositing/compositor_task.rs index d22258170c1..5cdf310ce59 100644 --- a/src/components/main/compositing/mod.rs +++ b/src/components/main/compositing/compositor_task.rs @@ -28,8 +28,8 @@ use azure::azure_hl; mod quadtree; mod compositor_layer; -mod run; -mod run_headless; +mod compositor; +mod headless; /// The implementation of the layers-based compositor. #[deriving(Clone)] @@ -190,14 +190,15 @@ impl CompositorTask { match compositor.mode { Windowed(ref app) => { - run::IOCompositor::create(app, - opts, - port, - constellation_chan.clone(), - profiler_chan); + compositor::IOCompositor::create(app, + opts, + port, + constellation_chan.clone(), + profiler_chan); } Headless => { - run_headless::run_compositor(&constellation_chan, port); + headless::NullCompositor::create(port, + constellation_chan.clone()); } } diff --git a/src/components/main/compositing/headless.rs b/src/components/main/compositing/headless.rs new file mode 100644 index 00000000000..4ec179c7e05 --- /dev/null +++ b/src/components/main/compositing/headless.rs @@ -0,0 +1,62 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * 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/. */ + +use compositing::*; + +use geom::size::Size2D; +use servo_msg::constellation_msg::{ConstellationChan, ResizedWindowMsg}; +use std::comm::Port; + + +/// Starts the compositor, which listens for messages on the specified port. +/// +/// This is the null compositor which doesn't draw anything to the screen. +/// It's intended for headless testing. +pub struct NullCompositor { + /// The port on which we receive messages. + port: Port, +} + +impl NullCompositor { + + fn new(port: Port) -> NullCompositor { + + NullCompositor { + port: port + } + } + + pub fn create(port: Port, constellation_chan: ConstellationChan) { + let compositor = NullCompositor::new(port); + + // Tell the constellation about the initial fake size. + constellation_chan.send(ResizedWindowMsg(Size2D(640u, 480u))); + compositor.handle_message(); + } + + fn handle_message(&self) { + loop { + match self.port.recv() { + Exit => break, + + GetGraphicsMetadata(chan) => { + chan.send(None); + } + + SetIds(_, response_chan, _) => { + response_chan.send(()); + } + + // Explicitly list ignored messages so that when we add a new one, + // we'll notice and think about whether it needs a response, like + // SetIds. + + NewLayer(*) | SetLayerPageSize(*) | SetLayerClipRect(*) | DeleteLayer(*) | + Paint(*) | InvalidateRect(*) | ChangeReadyState(*) | ChangeRenderState(*)| + ScrollFragmentPoint(*) | SetUnRenderedColor(*) + => () + } + } + } +} diff --git a/src/components/main/compositing/run_headless.rs b/src/components/main/compositing/run_headless.rs deleted file mode 100644 index 0d663aeb580..00000000000 --- a/src/components/main/compositing/run_headless.rs +++ /dev/null @@ -1,41 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -use compositing::*; - -use geom::size::Size2D; -use servo_msg::constellation_msg::{ConstellationChan, ResizedWindowMsg}; -use std::comm::Port; - -/// Starts the compositor, which listens for messages on the specified port. -/// -/// This is the null compositor which doesn't draw anything to the screen. -/// It's intended for headless testing. -pub fn run_compositor(constellation_chan: &ConstellationChan, port: Port) { - // Tell the constellation about the initial fake size. - constellation_chan.send(ResizedWindowMsg(Size2D(640u, 480u))); - - loop { - match port.recv() { - Exit => break, - - GetGraphicsMetadata(chan) => { - chan.send(None); - } - - SetIds(_, response_chan, _) => { - response_chan.send(()); - } - - // Explicitly list ignored messages so that when we add a new one, - // we'll notice and think about whether it needs a response, like - // SetIds. - - NewLayer(*) | SetLayerPageSize(*) | SetLayerClipRect(*) | DeleteLayer(*) | - Paint(*) | InvalidateRect(*) | ChangeReadyState(*) | ChangeRenderState(*)| - ScrollFragmentPoint(*) | SetUnRenderedColor(*) - => () - } - } -} diff --git a/src/components/main/servo.rc b/src/components/main/servo.rc index b5a177c91c1..e6584df38c7 100755 --- a/src/components/main/servo.rc +++ b/src/components/main/servo.rc @@ -58,7 +58,7 @@ use std::comm; use std::os; use std::task::spawn_with; -#[path="compositing/mod.rs"] +#[path="compositing/compositor_task.rs"] pub mod compositing; pub mod macros;