Move windowing code out of the compositor

This is mainly just moving code around, in preparation for further changes to
the "windowing" API.
This commit is contained in:
Matt Brubeck 2014-09-29 14:22:02 -07:00
parent bfb81a5d10
commit 77d32ee447
23 changed files with 828 additions and 206 deletions

View file

@ -33,6 +33,8 @@ extern crate url;
#[cfg(not(test))]
use compositing::{CompositorChan, CompositorTask, Constellation};
#[cfg(not(test))]
use compositing::windowing::WindowMethods;
#[cfg(not(test))]
use servo_msg::constellation_msg::{ConstellationChan, InitLoadUrlMsg};
#[cfg(not(test))]
use script::dom::bindings::codegen::RegisterBindings;
@ -55,36 +57,12 @@ use green::GreenTaskBuilder;
#[cfg(not(test))]
use std::os;
#[cfg(not(test))]
use std::rc::Rc;
#[cfg(not(test))]
use std::task::TaskBuilder;
#[cfg(not(test), target_os="android")]
use std::string;
#[cfg(not(test), target_os="android")]
#[no_mangle]
#[allow(dead_code)]
pub extern "C" fn android_start(argc: int, argv: *const *const u8) -> int {
native::start(argc, argv, proc() {
let mut args: Vec<String> = vec!();
for i in range(0u, argc as uint) {
unsafe {
args.push(string::raw::from_buf(*argv.offset(i as int) as *const u8));
}
}
let opts = opts::from_cmdline_args(args.as_slice());
match opts {
Some(mut o) => {
// Always use CPU rendering on android.
o.cpu_painting = true;
run(o);
},
None => {}
}
})
}
#[cfg(not(test))]
pub fn run(opts: opts::Opts) {
pub fn run<Window: WindowMethods>(opts: opts::Opts, window: Option<Rc<Window>>) {
::servo_util::opts::set_experimental_enabled(opts.enable_experimental);
RegisterBindings::RegisterProxyHandlers();
@ -149,7 +127,8 @@ pub fn run(opts: opts::Opts) {
let constellation_chan = result_port.recv();
debug!("preparing to enter main loop");
CompositorTask::create(opts,
CompositorTask::create(window,
opts,
compositor_port,
constellation_chan,
time_profiler_chan,

View file

@ -11,6 +11,9 @@ extern crate servo;
extern crate native;
extern crate "util" as servo_util;
#[cfg(not(test),not(target_os="android"))]
extern crate glfw_app;
#[cfg(not(test),not(target_os="android"))]
use servo_util::opts;
@ -20,13 +23,19 @@ use servo::run;
#[cfg(not(test),not(target_os="android"))]
use std::os;
#[cfg(not(test), target_os="linux")]
#[cfg(not(test), target_os="macos")]
#[cfg(not(test), not(target_os="android"))]
#[start]
#[allow(dead_code)]
fn start(argc: int, argv: *const *const u8) -> int {
native::start(argc, argv, proc() {
opts::from_cmdline_args(os::args().as_slice()).map(run);
opts::from_cmdline_args(os::args().as_slice()).map(|opts| {
let window = if opts.headless {
None
} else {
Some(glfw_app::create_window(&opts))
};
run(opts, window);
});
})
}