servo: Move some code to layout/lister for building display lists

Source-Repo: https://github.com/servo/servo
Source-Revision: eaa9b460c354ab570e921953ec67fd3e4c7e2704
This commit is contained in:
Brian Anderson 2012-05-03 15:09:55 -07:00
parent 7128aafe1c
commit 77b195851b
4 changed files with 54 additions and 33 deletions

View File

@ -1,7 +1,7 @@
fn input(
osmain_ch: comm::chan<osmain::msg>,
draw_ch: comm::chan<gfx::renderer::msg>,
model_ch: comm::chan<()>
model_ch: comm::chan<layout::lister::msg>
) {
task::spawn {||
let key_po = comm::port();
@ -9,7 +9,7 @@ fn input(
loop {
alt comm::recv(key_po) {
_ {
comm::send(model_ch, ());
comm::send(model_ch, layout::lister::exit);
let draw_exit_confirm_po = comm::port();
comm::send(draw_ch, gfx::renderer::exit(comm::chan(draw_exit_confirm_po)));
comm::recv(draw_exit_confirm_po);

View File

@ -0,0 +1,48 @@
#[doc = "
Builds display lists on request and passes them to the renderer
"];
import task::*;
import comm::*;
import gfx::renderer;
enum msg {
build,
exit
}
fn lister(renderer: chan<renderer::msg>) -> chan<msg> {
spawn_listener {|po|
let mut x1 = 100;
let mut y1 = 100;
let mut w1 = 200;
let mut h1 = 200;
let mut x2 = 200;
let mut y2 = 200;
let mut w2 = 300;
let mut h2 = 300;
while !peek(po) {
let model = {
x1: x1, y1: y1, w1: w1, h1: h1,
x2: x2, y2: y2, w2: w2, h2: h2
};
send(renderer, gfx::renderer::draw(model));
std::timer::sleep(100u);
x1 += 1;
y1 += 1;
x2 -= 1;
y2 -= 1;
if x1 > 800 { x1 = 0 }
if y1 > 600 { y1 = 0 }
if x2 < 0 { x2 = 800 }
if y2 < 0 { y2 = 600 }
}
}
}

View File

@ -29,6 +29,7 @@ mod image {
mod layout {
mod base;
mod lister;
}
mod widget {

View File

@ -11,37 +11,9 @@ fn main() {
// The compositor
let renderer = gfx::renderer::renderer(osmain_ch);
// Not sure what this is but it decides what to draw
let model_ch = task::spawn_listener {|po|
let mut x1 = 100;
let mut y1 = 100;
let mut w1 = 200;
let mut h1 = 200;
let mut x2 = 200;
let mut y2 = 200;
let mut w2 = 300;
let mut h2 = 300;
while !comm::peek(po) {
let model = {
x1: x1, y1: y1, w1: w1, h1: h1,
x2: x2, y2: y2, w2: w2, h2: h2
};
comm::send(renderer, gfx::renderer::draw(model));
std::timer::sleep(100u);
x1 += 1;
y1 += 1;
x2 -= 1;
y2 -= 1;
if x1 > 800 { x1 = 0 }
if y1 > 600 { y1 = 0 }
if x2 < 0 { x2 = 800 }
if y2 < 0 { y2 = 600 }
}
};
// The display list builder
let lister = layout::lister::lister(renderer);
// The keyboard handler
input::input(osmain_ch, renderer, model_ch);
input::input(osmain_ch, renderer, lister);
}