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);
|
||||
}
|
||||
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 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<Msg>) {
|
||||
// Tell the constellation about the initial fake size.
|
||||
constellation_chan.send(ResizedWindowMsg(Size2D(640u, 480u)));
|
||||
pub struct NullCompositor {
|
||||
/// The port on which we receive messages.
|
||||
port: Port<Msg>,
|
||||
}
|
||||
|
||||
loop {
|
||||
match port.recv() {
|
||||
Exit => break,
|
||||
impl NullCompositor {
|
||||
|
||||
GetGraphicsMetadata(chan) => {
|
||||
chan.send(None);
|
||||
fn new(port: Port<Msg>) -> NullCompositor {
|
||||
|
||||
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