Skip to content

Commit

Permalink
Extract 3 more embedder options
Browse files Browse the repository at this point in the history
Extracted clean-shutdown, msaa, and no-native-titlebar embedder
specific options out from the global options.

Partially fixes #23009
  • Loading branch information
glowe committed Oct 26, 2019
1 parent 6eca38a commit 74f1e2e
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 0 additions & 28 deletions components/config/opts.rs
Expand Up @@ -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,

Expand All @@ -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<PathBuf>,

Expand All @@ -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) {
Expand Down Expand Up @@ -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,

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.");
Expand Down Expand Up @@ -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,
Expand All @@ -593,7 +577,6 @@ pub fn default_opts() -> Opts {
certificate_path: None,
unminify_js: false,
print_pwm: false,
clean_shutdown: false,
}
}

Expand Down Expand Up @@ -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", "");
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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,
Expand All @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion ports/glutin/app.rs
Expand Up @@ -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.
Expand All @@ -47,6 +47,8 @@ impl App {
events_loop.clone(),
angle,
enable_vsync,
use_msaa,
no_native_titlebar,
))
};

Expand Down
16 changes: 12 additions & 4 deletions ports/glutin/headed_window.rs
Expand Up @@ -73,6 +73,8 @@ pub struct Window {
xr_rotation: Cell<Rotation3D<f32, UnknownUnit, UnknownUnit>>,
angle: bool,
enable_vsync: bool,
use_msaa: bool,
no_native_titlebar: bool,
}

#[cfg(not(target_os = "windows"))]
Expand All @@ -94,23 +96,25 @@ impl Window {
events_loop: Rc<RefCell<EventsLoop>>,
angle: bool,
enable_vsync: bool,
use_msaa: bool,
no_native_titlebar: bool,
) -> Window {
let opts = opts::get();

// If there's no chrome, start off with the window invisible. It will be set to visible in
// `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;
let height = win_size.to_untyped().height;

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();
Expand All @@ -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)
}

Expand Down Expand Up @@ -204,6 +208,8 @@ impl Window {
xr_rotation: Cell::new(Rotation3D::identity()),
angle,
enable_vsync,
use_msaa,
no_native_titlebar,
};

window.present();
Expand Down Expand Up @@ -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)
Expand Down
18 changes: 15 additions & 3 deletions ports/glutin/main2.rs
Expand Up @@ -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;
Expand All @@ -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")))]
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
}
5 changes: 2 additions & 3 deletions ports/glutin/platform/macos/mod.rs
Expand Up @@ -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 {
Expand All @@ -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() };
Expand Down
1 change: 0 additions & 1 deletion ports/libmlservo/Cargo.toml
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions ports/libsimpleservo/api/Cargo.toml
Expand Up @@ -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" }
Expand Down

0 comments on commit 74f1e2e

Please sign in to comment.