mirror of
https://github.com/servo/servo.git
synced 2025-08-11 00:15:32 +01:00
Use opts as a global, to avoid cloning and passing the struct all over the code.
This commit is contained in:
parent
a983debaf1
commit
076495db94
20 changed files with 108 additions and 132 deletions
|
@ -30,14 +30,14 @@ use glut::glut::{init, init_display_mode, DOUBLE};
|
|||
|
||||
mod window;
|
||||
|
||||
pub fn create_window(opts: &opts::Opts) -> Rc<Window> {
|
||||
pub fn create_window() -> Rc<Window> {
|
||||
// Initialize GLUT.
|
||||
init();
|
||||
init_display_mode(DOUBLE);
|
||||
|
||||
// Read command-line options.
|
||||
let scale_factor = opts.device_pixels_per_px.unwrap_or(ScaleFactor(1.0));
|
||||
let size = opts.initial_window_size.as_f32() * scale_factor;
|
||||
let scale_factor = opts::get().device_pixels_per_px.unwrap_or(ScaleFactor(1.0));
|
||||
let size = opts::get().initial_window_size.as_f32() * scale_factor;
|
||||
|
||||
// Open a window.
|
||||
Window::new(size.as_uint())
|
||||
|
@ -54,11 +54,9 @@ pub extern "C" fn android_start(argc: int, argv: *const *const u8) -> int {
|
|||
}
|
||||
}
|
||||
|
||||
opts::from_cmdline_args(args.as_slice()).map(|mut opts| {
|
||||
// Always use CPU rendering on android.
|
||||
opts.cpu_painting = true;
|
||||
let window = Some(create_window(&opts));
|
||||
servo::run(opts, window);
|
||||
});
|
||||
if opts::from_cmdline_args(args.as_slice()) {
|
||||
let window = Some(create_window());
|
||||
servo::run(window);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -75,8 +75,8 @@ pub extern "C" fn cef_run_message_loop() {
|
|||
dump_flow_tree: false,
|
||||
};
|
||||
native::start(0, 0 as *const *const u8, proc() {
|
||||
let window = Some(glfw_app::create_window(&opts));
|
||||
servo::run(opts, window);
|
||||
let window = Some(glfw_app::create_window());
|
||||
servo::run(window);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -21,10 +21,11 @@ extern crate util;
|
|||
use geom::scale_factor::ScaleFactor;
|
||||
use std::rc::Rc;
|
||||
use window::Window;
|
||||
use util::opts;
|
||||
|
||||
mod window;
|
||||
|
||||
pub fn create_window(opts: &util::opts::Opts) -> Rc<Window> {
|
||||
pub fn create_window() -> Rc<Window> {
|
||||
// Initialize GLFW.
|
||||
let glfw = glfw::init(glfw::LOG_ERRORS).unwrap_or_else(|_| {
|
||||
// handles things like inability to connect to X
|
||||
|
@ -34,9 +35,9 @@ pub fn create_window(opts: &util::opts::Opts) -> Rc<Window> {
|
|||
});
|
||||
|
||||
// Read command-line options.
|
||||
let foreground = opts.output_file.is_none();
|
||||
let scale_factor = opts.device_pixels_per_px.unwrap_or(ScaleFactor(1.0));
|
||||
let size = opts.initial_window_size.as_f32() * scale_factor;
|
||||
let foreground = opts::get().output_file.is_none();
|
||||
let scale_factor = opts::get().device_pixels_per_px.unwrap_or(ScaleFactor(1.0));
|
||||
let size = opts::get().initial_window_size.as_f32() * scale_factor;
|
||||
|
||||
// Open a window.
|
||||
Window::new(glfw, foreground, size.as_uint())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue