From 74f1e2ec322b22ef9a1370d56d7cf3b1d38479ef Mon Sep 17 00:00:00 2001 From: glowe Date: Wed, 23 Oct 2019 18:13:57 -0400 Subject: [PATCH] Extract 3 more embedder options Extracted clean-shutdown, msaa, and no-native-titlebar embedder specific options out from the global options. Partially fixes #23009 --- Cargo.lock | 2 +- components/config/opts.rs | 28 ---------------------------- ports/glutin/app.rs | 4 +++- ports/glutin/headed_window.rs | 16 ++++++++++++---- ports/glutin/main2.rs | 18 +++++++++++++++--- ports/glutin/platform/macos/mod.rs | 5 ++--- ports/libmlservo/Cargo.toml | 1 - ports/libsimpleservo/api/Cargo.toml | 1 + 8 files changed, 34 insertions(+), 41 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 15c435e6ebae..ca10d5ef330a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2673,7 +2673,6 @@ dependencies = [ name = "libmlservo" version = "0.0.1" dependencies = [ - "getopts", "libc", "libservo", "log", @@ -4809,6 +4808,7 @@ name = "simpleservo" version = "0.0.1" dependencies = [ "core-foundation", + "getopts", "gl_generator 0.11.0", "libc", "libloading", diff --git a/components/config/opts.rs b/components/config/opts.rs index 2e2cb20a45fb..8fe8fb62d5da 100644 --- a/components/config/opts.rs +++ b/components/config/opts.rs @@ -181,9 +181,6 @@ pub struct Opts { /// True to exit after the page load (`-x`). pub exit_after_load: bool, - /// Do not use native titlebar - pub no_native_titlebar: bool, - /// True to show webrender profiling stats on screen. pub webrender_stats: bool, @@ -201,9 +198,6 @@ pub struct Opts { /// after each change is made. pub precache_shaders: bool, - /// True if WebRender should use multisample antialiasing. - pub use_msaa: bool, - /// Directory for a default config directory pub config_dir: Option, @@ -225,9 +219,6 @@ pub struct Opts { /// Print Progressive Web Metrics to console. pub print_pwm: bool, - - /// Only shutdown once all theads are finished. - pub clean_shutdown: bool, } fn print_usage(app: &str, opts: &Options) { @@ -317,9 +308,6 @@ pub struct DebugOptions { /// Enable webrender instanced draw call batching. pub webrender_disable_batch: bool, - /// Use multisample antialiasing in WebRender. - pub use_msaa: bool, - // don't skip any backtraces on panic pub full_backtraces: bool, @@ -362,7 +350,6 @@ impl DebugOptions { "wr-stats" => self.webrender_stats = true, "wr-record" => self.webrender_record = true, "wr-no-batch" => self.webrender_disable_batch = true, - "msaa" => self.use_msaa = true, "full-backtraces" => self.full_backtraces = true, "precache-shaders" => self.precache_shaders = true, "signpost" => self.signpost = true, @@ -453,7 +440,6 @@ fn print_debug_usage(app: &str) -> ! { "Load web fonts synchronously to avoid non-deterministic network-driven reflows", ); print_option("wr-stats", "Show WebRender profiler on screen."); - print_option("msaa", "Use multisample antialiasing in WebRender."); print_option("full-backtraces", "Print full backtraces for all errors"); print_option("wr-debug", "Display webrender tile borders."); print_option("wr-no-batch", "Disable webrender instanced batching."); @@ -579,9 +565,7 @@ pub fn default_opts() -> Opts { style_sharing_stats: false, convert_mouse_to_touch: false, exit_after_load: false, - no_native_titlebar: false, webrender_stats: false, - use_msaa: false, config_dir: None, full_backtraces: false, is_printing_version: false, @@ -593,7 +577,6 @@ pub fn default_opts() -> Opts { certificate_path: None, unminify_js: false, print_pwm: false, - clean_shutdown: false, } } @@ -745,11 +728,6 @@ pub fn from_cmdline_args(mut opts: Options, args: &[String]) -> ArgumentParsingR "config directory following xdg spec on linux platform", "", ); - opts.optflag( - "", - "clean-shutdown", - "Do not shutdown until all threads have finished (macos only)", - ); opts.optflag("v", "version", "Display servo version information"); opts.optflag("", "unminify-js", "Unminify Javascript"); opts.optopt("", "profiler-db-user", "Profiler database user", ""); @@ -964,9 +942,6 @@ pub fn from_cmdline_args(mut opts: Options, args: &[String]) -> ArgumentParsingR }) .collect(); - let do_not_use_native_titlebar = - opt_match.opt_present("b") || !(pref!(shell.native_titlebar.enabled)); - let enable_subpixel_text_antialiasing = !debug_options.disable_subpixel_aa && pref!(gfx.subpixel_text_antialiasing.enabled); @@ -1017,9 +992,7 @@ pub fn from_cmdline_args(mut opts: Options, args: &[String]) -> ArgumentParsingR style_sharing_stats: debug_options.style_sharing_stats, convert_mouse_to_touch: debug_options.convert_mouse_to_touch, exit_after_load: opt_match.opt_present("x"), - no_native_titlebar: do_not_use_native_titlebar, webrender_stats: debug_options.webrender_stats, - use_msaa: debug_options.use_msaa, config_dir: opt_match.opt_str("config-dir").map(Into::into), full_backtraces: debug_options.full_backtraces, is_printing_version: is_printing_version, @@ -1031,7 +1004,6 @@ pub fn from_cmdline_args(mut opts: Options, args: &[String]) -> ArgumentParsingR certificate_path: opt_match.opt_str("certificate-path"), unminify_js: opt_match.opt_present("unminify-js"), print_pwm: opt_match.opt_present("print-pwm"), - clean_shutdown: opt_match.opt_present("clean-shutdown"), }; set_options(opts); diff --git a/ports/glutin/app.rs b/ports/glutin/app.rs index d5371bf1e93a..44c8d52e6a74 100644 --- a/ports/glutin/app.rs +++ b/ports/glutin/app.rs @@ -34,7 +34,7 @@ pub struct App { } impl App { - pub fn run(angle: bool, enable_vsync: bool) { + pub fn run(angle: bool, enable_vsync: bool, use_msaa: bool, no_native_titlebar: bool) { let events_loop = EventsLoop::new(opts::get().headless); // Implements window methods, used by compositor. @@ -47,6 +47,8 @@ impl App { events_loop.clone(), angle, enable_vsync, + use_msaa, + no_native_titlebar, )) }; diff --git a/ports/glutin/headed_window.rs b/ports/glutin/headed_window.rs index 37af152a2a20..10c69ba59c64 100644 --- a/ports/glutin/headed_window.rs +++ b/ports/glutin/headed_window.rs @@ -73,6 +73,8 @@ pub struct Window { xr_rotation: Cell>, angle: bool, enable_vsync: bool, + use_msaa: bool, + no_native_titlebar: bool, } #[cfg(not(target_os = "windows"))] @@ -94,6 +96,8 @@ impl Window { events_loop: Rc>, angle: bool, enable_vsync: bool, + use_msaa: bool, + no_native_titlebar: bool, ) -> Window { let opts = opts::get(); @@ -101,7 +105,7 @@ impl Window { // `load_end()`. This avoids an ugly flash of unstyled content (especially important since // unstyled content is white and chrome often has a transparent background). See issue // #9996. - let visible = opts.output_file.is_none() && !opts.no_native_titlebar; + let visible = opts.output_file.is_none() && !no_native_titlebar; let win_size: DeviceIntSize = (win_size.to_f32() * window_creation_scale_factor()).to_i32(); let width = win_size.to_untyped().width; @@ -109,8 +113,8 @@ impl Window { let mut window_builder = glutin::WindowBuilder::new() .with_title("Servo".to_string()) - .with_decorations(!opts.no_native_titlebar) - .with_transparency(opts.no_native_titlebar) + .with_decorations(!no_native_titlebar) + .with_transparency(no_native_titlebar) .with_dimensions(LogicalSize::new(width as f64, height as f64)) .with_visibility(visible) .with_multitouch(); @@ -121,7 +125,7 @@ impl Window { .with_gl(app::gl_version(angle)) .with_vsync(enable_vsync); - if opts.use_msaa { + if use_msaa { context_builder = context_builder.with_multisampling(MULTISAMPLES) } @@ -204,6 +208,8 @@ impl Window { xr_rotation: Cell::new(Rotation3D::identity()), angle, enable_vsync, + use_msaa, + no_native_titlebar, }; window.present(); @@ -553,6 +559,8 @@ impl webxr::glwindow::GlWindow for Window { self.events_loop.clone(), self.angle, self.enable_vsync, + self.use_msaa, + self.no_native_titlebar, )); app::register_window(window.clone()); Ok(window) diff --git a/ports/glutin/main2.rs b/ports/glutin/main2.rs index e0224e64daa7..c6aff92f5e06 100644 --- a/ports/glutin/main2.rs +++ b/ports/glutin/main2.rs @@ -27,6 +27,7 @@ use backtrace::Backtrace; use getopts::Options; use servo::config::opts::{self, ArgumentParsingResult}; use servo::config::servo_version; +use servo::servo_config::pref; use std::env; use std::panic; use std::process; @@ -40,7 +41,7 @@ pub mod platform { pub mod macos; #[cfg(not(target_os = "macos"))] - pub fn deinit() {} + pub fn deinit(_clean_shutdown: bool) {} } #[cfg(not(any(target_os = "macos", target_os = "linux")))] @@ -83,11 +84,18 @@ pub fn main() { "angle", "Use ANGLE to create a GL context (Windows-only)", ); + opts.optflag( + "", + "clean-shutdown", + "Do not shutdown until all threads have finished (macos only)", + ); opts.optflag( "", "disable-vsync", "Disable vsync mode in the compositor to allow profiling at more than monitor refresh rate", ); + opts.optflag("", "msaa", "Use multisample antialiasing in WebRender."); + opts.optflag("b", "no-native-titlebar", "Do not use native titlebar"); let opts_matches; let content_process_token; @@ -146,8 +154,12 @@ pub fn main() { } let angle = opts_matches.opt_present("angle"); + let clean_shutdown = opts_matches.opt_present("clean-shutdown"); + let do_not_use_native_titlebar = + opts_matches.opt_present("no-native-titlebar") || !(pref!(shell.native_titlebar.enabled)); let enable_vsync = !opts_matches.opt_present("disable-vsync"); - App::run(angle, enable_vsync); + let use_msaa = opts_matches.opt_present("msaa"); + App::run(angle, enable_vsync, use_msaa, do_not_use_native_titlebar); - platform::deinit() + platform::deinit(clean_shutdown) } diff --git a/ports/glutin/platform/macos/mod.rs b/ports/glutin/platform/macos/mod.rs index 730f40725769..d9d14bb9ee83 100644 --- a/ports/glutin/platform/macos/mod.rs +++ b/ports/glutin/platform/macos/mod.rs @@ -2,12 +2,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use servo::config::opts; use std::ptr; use std::thread; use std::time::Duration; -pub fn deinit() { +pub fn deinit(clean_shutdown: bool) { // An unfortunate hack to make sure the linker's dead code stripping doesn't strip our // `Info.plist`. unsafe { @@ -21,7 +20,7 @@ pub fn deinit() { "{} threads are still running after shutdown (bad).", thread_count ); - if opts::get().clean_shutdown { + if clean_shutdown { println!("Waiting until all threads have shutdown"); loop { let thread_count = unsafe { macos_count_running_threads() }; diff --git a/ports/libmlservo/Cargo.toml b/ports/libmlservo/Cargo.toml index 4809675761c6..4c4ef0e8b1b2 100644 --- a/ports/libmlservo/Cargo.toml +++ b/ports/libmlservo/Cargo.toml @@ -25,7 +25,6 @@ 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" diff --git a/ports/libsimpleservo/api/Cargo.toml b/ports/libsimpleservo/api/Cargo.toml index e0204f3ebb6e..afbd3f4c8007 100644 --- a/ports/libsimpleservo/api/Cargo.toml +++ b/ports/libsimpleservo/api/Cargo.toml @@ -7,6 +7,7 @@ edition = "2018" publish = false [dependencies] +getopts = "0.2.11" libservo = { path = "../../../components/servo" } log = "0.4" servo-media = { git = "https://github.com/servo/media" }