mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
auto merge of #1425 : saneyuki/servo/compositor, r=metajack
Related: #1351.
This commit is contained in:
commit
d4fcbf5e1d
5 changed files with 72 additions and 51 deletions
|
@ -189,7 +189,6 @@ impl IOCompositor {
|
|||
}
|
||||
|
||||
fn handle_message(&mut self) {
|
||||
// Handle messages
|
||||
while self.port.peek() {
|
||||
match self.port.recv() {
|
||||
Exit => {
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
62
src/components/main/compositing/headless.rs
Normal file
62
src/components/main/compositing/headless.rs
Normal file
|
@ -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<Msg>,
|
||||
}
|
||||
|
||||
impl NullCompositor {
|
||||
|
||||
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(*)
|
||||
=> ()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<Msg>) {
|
||||
// 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(*)
|
||||
=> ()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue