Make angle and disable-vsync embedder options

The angle and disable-vsync options were declared as global options but
only used in the Glutin embedding for desktop builds. Moving them to
the Glutin embedding code makes them easier to update.

Partially fixes #23009
This commit is contained in:
glowe 2019-10-22 19:28:03 -04:00
parent 24b8408916
commit 6eca38aea3
6 changed files with 40 additions and 41 deletions

View file

@ -49,6 +49,7 @@ vslatestinstalled = ["libservo/vslatestinstalled"]
backtrace = "0.3"
clipboard = "0.5"
euclid = "0.20"
getopts = "0.2.11"
gleam = "0.6"
glutin = "0.21.0"
keyboard-types = "0.4.3"

View file

@ -24,6 +24,7 @@ mod window_trait;
use app::App;
use backtrace::Backtrace;
use getopts::Options;
use servo::config::opts::{self, ArgumentParsingResult};
use servo::config::servo_version;
use std::env;
@ -76,16 +77,32 @@ pub fn main() {
// Parse the command line options and store them globally
let args: Vec<String> = env::args().collect();
let opts_result = opts::from_cmdline_args(&args);
let mut opts = Options::new();
opts.optflag(
"",
"angle",
"Use ANGLE to create a GL context (Windows-only)",
);
opts.optflag(
"",
"disable-vsync",
"Disable vsync mode in the compositor to allow profiling at more than monitor refresh rate",
);
let content_process_token = if let ArgumentParsingResult::ContentProcess(token) = opts_result {
Some(token)
} else {
if opts::get().is_running_problem_test && env::var("RUST_LOG").is_err() {
env::set_var("RUST_LOG", "compositing::constellation");
}
None
let opts_matches;
let content_process_token;
match opts::from_cmdline_args(opts, &args) {
ArgumentParsingResult::ContentProcess(matches, token) => {
opts_matches = matches;
content_process_token = Some(token);
if opts::get().is_running_problem_test && env::var("RUST_LOG").is_err() {
env::set_var("RUST_LOG", "compositing::constellation");
}
},
ArgumentParsingResult::ChromeProcess(matches) => {
opts_matches = matches;
content_process_token = None;
},
};
// TODO: once log-panics is released, can this be replaced by
@ -128,7 +145,9 @@ pub fn main() {
process::exit(0);
}
App::run(opts::get().angle, opts::get().enable_vsync);
let angle = opts_matches.opt_present("angle");
let enable_vsync = !opts_matches.opt_present("disable-vsync");
App::run(angle, enable_vsync);
platform::deinit()
}

View file

@ -25,6 +25,7 @@ simpleservo = { path = "../libsimpleservo/api", features = ["no_static_freetype"
rust-webvr = { version = "0.16", features = ["magicleap"] }
webxr-api = { git = "https://github.com/servo/webxr", features = ["ipc"] }
webxr = { git = "https://github.com/servo/webxr", features = ["ipc", "magicleap"] }
getopts = "0.2.11"
libc = "0.2"
log = "0.4"
servo-egl = "0.2"

View file

@ -171,7 +171,7 @@ pub fn init(
gfx.subpixel_text_antialiasing.enabled,
init_opts.enable_subpixel_text_antialiasing
);
opts::from_cmdline_args(&args);
opts::from_cmdline_args(Options::new(), &args);
}
let embedder_url = init_opts.url.as_ref().and_then(|s| ServoUrl::parse(s).ok());