mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Introduce 'NullCompositor'.
This commit is contained in:
parent
513ff0259a
commit
56ba7fc343
2 changed files with 44 additions and 22 deletions
|
@ -197,7 +197,8 @@ impl CompositorTask {
|
||||||
profiler_chan);
|
profiler_chan);
|
||||||
}
|
}
|
||||||
Headless => {
|
Headless => {
|
||||||
run_headless::run_compositor(&constellation_chan, port);
|
run_headless::NullCompositor::create(port,
|
||||||
|
constellation_chan.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,34 +8,55 @@ use geom::size::Size2D;
|
||||||
use servo_msg::constellation_msg::{ConstellationChan, ResizedWindowMsg};
|
use servo_msg::constellation_msg::{ConstellationChan, ResizedWindowMsg};
|
||||||
use std::comm::Port;
|
use std::comm::Port;
|
||||||
|
|
||||||
|
|
||||||
/// Starts the compositor, which listens for messages on the specified 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.
|
/// This is the null compositor which doesn't draw anything to the screen.
|
||||||
/// It's intended for headless testing.
|
/// It's intended for headless testing.
|
||||||
pub fn run_compositor(constellation_chan: &ConstellationChan, port: Port<Msg>) {
|
pub struct NullCompositor {
|
||||||
// Tell the constellation about the initial fake size.
|
/// The port on which we receive messages.
|
||||||
constellation_chan.send(ResizedWindowMsg(Size2D(640u, 480u)));
|
port: Port<Msg>,
|
||||||
|
}
|
||||||
|
|
||||||
loop {
|
impl NullCompositor {
|
||||||
match port.recv() {
|
|
||||||
Exit => break,
|
|
||||||
|
|
||||||
GetGraphicsMetadata(chan) => {
|
fn new(port: Port<Msg>) -> NullCompositor {
|
||||||
chan.send(None);
|
|
||||||
|
NullCompositor {
|
||||||
|
port: port
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn create(port: Port<Msg>, 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(*)
|
||||||
|
=> ()
|
||||||
}
|
}
|
||||||
|
|
||||||
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(*)
|
|
||||||
=> ()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue