mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Add debug option to disable vsync for profiling.
This commit is contained in:
parent
0f72049363
commit
6c8905126f
2 changed files with 26 additions and 11 deletions
|
@ -188,6 +188,9 @@ pub struct Opts {
|
||||||
|
|
||||||
/// Do not use native titlebar
|
/// Do not use native titlebar
|
||||||
pub no_native_titlebar: bool,
|
pub no_native_titlebar: bool,
|
||||||
|
|
||||||
|
/// Enable vsync in the compositor
|
||||||
|
pub enable_vsync: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_usage(app: &str, opts: &Options) {
|
fn print_usage(app: &str, opts: &Options) {
|
||||||
|
@ -277,6 +280,9 @@ pub struct DebugOptions {
|
||||||
|
|
||||||
/// Load web fonts synchronously to avoid non-deterministic network-driven reflows.
|
/// Load web fonts synchronously to avoid non-deterministic network-driven reflows.
|
||||||
pub load_webfonts_synchronously: bool,
|
pub load_webfonts_synchronously: bool,
|
||||||
|
|
||||||
|
/// Disable vsync in the compositor
|
||||||
|
pub disable_vsync: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -312,6 +318,7 @@ impl DebugOptions {
|
||||||
"replace-surrogates" => debug_options.replace_surrogates = true,
|
"replace-surrogates" => debug_options.replace_surrogates = true,
|
||||||
"gc-profile" => debug_options.gc_profile = true,
|
"gc-profile" => debug_options.gc_profile = true,
|
||||||
"load-webfonts-synchronously" => debug_options.load_webfonts_synchronously = true,
|
"load-webfonts-synchronously" => debug_options.load_webfonts_synchronously = true,
|
||||||
|
"disable-vsync" => debug_options.disable_vsync = true,
|
||||||
"" => {},
|
"" => {},
|
||||||
_ => return Err(option)
|
_ => return Err(option)
|
||||||
};
|
};
|
||||||
|
@ -358,6 +365,8 @@ pub fn print_debug_usage(app: &str) -> ! {
|
||||||
print_option("gc-profile", "Log GC passes and their durations.");
|
print_option("gc-profile", "Log GC passes and their durations.");
|
||||||
print_option("load-webfonts-synchronously",
|
print_option("load-webfonts-synchronously",
|
||||||
"Load web fonts synchronously to avoid non-deterministic network-driven reflows");
|
"Load web fonts synchronously to avoid non-deterministic network-driven reflows");
|
||||||
|
print_option("disable-vsync",
|
||||||
|
"Disable vsync mode in the compositor to allow profiling at more than monitor refresh rate");
|
||||||
|
|
||||||
println!("");
|
println!("");
|
||||||
|
|
||||||
|
@ -488,6 +497,7 @@ pub fn default_opts() -> Opts {
|
||||||
convert_mouse_to_touch: false,
|
convert_mouse_to_touch: false,
|
||||||
exit_after_load: false,
|
exit_after_load: false,
|
||||||
no_native_titlebar: false,
|
no_native_titlebar: false,
|
||||||
|
enable_vsync: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -722,6 +732,7 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
|
||||||
convert_mouse_to_touch: debug_options.convert_mouse_to_touch,
|
convert_mouse_to_touch: debug_options.convert_mouse_to_touch,
|
||||||
exit_after_load: opt_match.opt_present("x"),
|
exit_after_load: opt_match.opt_present("x"),
|
||||||
no_native_titlebar: opt_match.opt_present("b"),
|
no_native_titlebar: opt_match.opt_present("b"),
|
||||||
|
enable_vsync: !debug_options.disable_vsync,
|
||||||
};
|
};
|
||||||
|
|
||||||
set_defaults(opts);
|
set_defaults(opts);
|
||||||
|
|
|
@ -86,17 +86,21 @@ impl Window {
|
||||||
pub fn new(is_foreground: bool,
|
pub fn new(is_foreground: bool,
|
||||||
window_size: TypedSize2D<DevicePixel, u32>,
|
window_size: TypedSize2D<DevicePixel, u32>,
|
||||||
parent: Option<glutin::WindowID>) -> Rc<Window> {
|
parent: Option<glutin::WindowID>) -> Rc<Window> {
|
||||||
let mut glutin_window = glutin::WindowBuilder::new()
|
let width = window_size.to_untyped().width;
|
||||||
.with_title("Servo".to_string())
|
let height = window_size.to_untyped().height;
|
||||||
|
let mut builder = glutin::WindowBuilder::new().with_title("Servo".to_string())
|
||||||
.with_decorations(!opts::get().no_native_titlebar)
|
.with_decorations(!opts::get().no_native_titlebar)
|
||||||
.with_vsync()
|
.with_dimensions(width, height)
|
||||||
.with_dimensions(window_size.to_untyped().width, window_size.to_untyped().height)
|
|
||||||
.with_gl(Window::gl_version())
|
.with_gl(Window::gl_version())
|
||||||
.with_visibility(is_foreground)
|
.with_visibility(is_foreground)
|
||||||
.with_parent(parent)
|
.with_parent(parent)
|
||||||
.with_multitouch()
|
.with_multitouch();
|
||||||
.build()
|
|
||||||
.unwrap();
|
if opts::get().enable_vsync {
|
||||||
|
builder = builder.with_vsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut glutin_window = builder.build().unwrap();
|
||||||
|
|
||||||
unsafe { glutin_window.make_current().expect("Failed to make context current!") }
|
unsafe { glutin_window.make_current().expect("Failed to make context current!") }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue