mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Improve layer tree debugging output
Add an option to dump the layer tree, which activates the previously unused layer tree debugging code. Also improve the output using the PrintTree struct.
This commit is contained in:
parent
ad94ef5a96
commit
8b5fe650c8
2 changed files with 65 additions and 16 deletions
|
@ -49,6 +49,7 @@ use time::{precise_time_ns, precise_time_s};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use util::geometry::{PagePx, ScreenPx, ViewportPx};
|
use util::geometry::{PagePx, ScreenPx, ViewportPx};
|
||||||
use util::opts;
|
use util::opts;
|
||||||
|
use util::print_tree::PrintTree;
|
||||||
use windowing::{self, MouseWindowEvent, WindowEvent, WindowMethods, WindowNavigateMsg};
|
use windowing::{self, MouseWindowEvent, WindowEvent, WindowMethods, WindowNavigateMsg};
|
||||||
|
|
||||||
const BUFFER_MAP_SIZE: usize = 10000000;
|
const BUFFER_MAP_SIZE: usize = 10000000;
|
||||||
|
@ -389,6 +390,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.send_buffer_requests_for_all_layers();
|
self.send_buffer_requests_for_all_layers();
|
||||||
|
self.dump_layer_tree();
|
||||||
}
|
}
|
||||||
|
|
||||||
(Msg::GetNativeDisplay(chan),
|
(Msg::GetNativeDisplay(chan),
|
||||||
|
@ -876,6 +878,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
self.pending_subpages.insert(subpage_pipeline_id);
|
self.pending_subpages.insert(subpage_pipeline_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.dump_layer_tree();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_window_size(&self) {
|
fn send_window_size(&self) {
|
||||||
|
@ -1573,6 +1577,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
|
|
||||||
profile(ProfilerCategory::Compositing, None, self.time_profiler_chan.clone(), || {
|
profile(ProfilerCategory::Compositing, None, self.time_profiler_chan.clone(), || {
|
||||||
debug!("compositor: compositing");
|
debug!("compositor: compositing");
|
||||||
|
self.dump_layer_tree();
|
||||||
// Adjust the layer dimensions as necessary to correspond to the size of the window.
|
// Adjust the layer dimensions as necessary to correspond to the size of the window.
|
||||||
self.scene.viewport = Rect {
|
self.scene.viewport = Rect {
|
||||||
origin: Point2D::zero(),
|
origin: Point2D::zero(),
|
||||||
|
@ -1750,28 +1755,63 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
fn dump_layer_tree(&self) {
|
fn dump_layer_tree(&self) {
|
||||||
|
if !opts::get().dump_layer_tree {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut print_tree = PrintTree::new("Layer tree".to_owned());
|
||||||
if let Some(ref layer) = self.scene.root {
|
if let Some(ref layer) = self.scene.root {
|
||||||
println!("Layer tree:");
|
self.dump_layer_tree_layer(&**layer, &mut print_tree);
|
||||||
self.dump_layer_tree_with_indent(&**layer, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
fn dump_layer_tree_with_indent(&self, layer: &Layer<CompositorData>, level: u32) {
|
fn dump_layer_tree_layer(&self, layer: &Layer<CompositorData>, print_tree: &mut PrintTree) {
|
||||||
let mut indentation = String::new();
|
let data = layer.extra_data.borrow();
|
||||||
for _ in 0..level {
|
let layer_string = if data.id == LayerId::null() {
|
||||||
indentation.push_str(" ");
|
format!("Root Layer (pipeline={})", data.pipeline_id)
|
||||||
}
|
} else {
|
||||||
|
"Layer".to_owned()
|
||||||
|
};
|
||||||
|
|
||||||
println!("{}Layer {:x}: {:?} @ {:?} masks to bounds: {:?} establishes 3D context: {:?}",
|
let masks_string = if *layer.masks_to_bounds.borrow() {
|
||||||
indentation,
|
" (masks children)"
|
||||||
layer as *const _ as usize,
|
} else {
|
||||||
layer.extra_data,
|
""
|
||||||
*layer.bounds.borrow(),
|
};
|
||||||
*layer.masks_to_bounds.borrow(),
|
|
||||||
layer.establishes_3d_context);
|
let establishes_3d_context_string = if layer.establishes_3d_context {
|
||||||
for kid in &*layer.children() {
|
" (3D context)"
|
||||||
self.dump_layer_tree_with_indent(&**kid, level + 1)
|
} else {
|
||||||
|
""
|
||||||
|
};
|
||||||
|
|
||||||
|
let fixed_string = if data.scroll_policy == ScrollPolicy::FixedPosition {
|
||||||
|
" (fixed)"
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
};
|
||||||
|
|
||||||
|
let layer_string = format!("{} ({:?}) ({},{} at {},{}){}{}{}",
|
||||||
|
layer_string,
|
||||||
|
layer.extra_data.borrow().id,
|
||||||
|
(*layer.bounds.borrow()).size.to_untyped().width,
|
||||||
|
(*layer.bounds.borrow()).size.to_untyped().height,
|
||||||
|
(*layer.bounds.borrow()).origin.to_untyped().x,
|
||||||
|
(*layer.bounds.borrow()).origin.to_untyped().y,
|
||||||
|
masks_string,
|
||||||
|
establishes_3d_context_string,
|
||||||
|
fixed_string);
|
||||||
|
|
||||||
|
let children = layer.children();
|
||||||
|
if !children.is_empty() {
|
||||||
|
print_tree.new_level(layer_string);
|
||||||
|
for kid in &*children {
|
||||||
|
self.dump_layer_tree_layer(&**kid, print_tree);
|
||||||
|
}
|
||||||
|
print_tree.end_level();
|
||||||
|
} else {
|
||||||
|
print_tree.add_item(layer_string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,6 +150,9 @@ pub struct Opts {
|
||||||
/// Dumps the display list after optimization (post layout, at painting time).
|
/// Dumps the display list after optimization (post layout, at painting time).
|
||||||
pub dump_display_list_optimized: bool,
|
pub dump_display_list_optimized: bool,
|
||||||
|
|
||||||
|
/// Dumps the layer tree when it changes.
|
||||||
|
pub dump_layer_tree: bool,
|
||||||
|
|
||||||
/// Emits notifications when there is a relayout.
|
/// Emits notifications when there is a relayout.
|
||||||
pub relayout_event: bool,
|
pub relayout_event: bool,
|
||||||
|
|
||||||
|
@ -205,6 +208,9 @@ pub struct DebugOptions {
|
||||||
/// Print optimized display list (at paint time).
|
/// Print optimized display list (at paint time).
|
||||||
pub dump_display_list_optimized: bool,
|
pub dump_display_list_optimized: bool,
|
||||||
|
|
||||||
|
/// Print the layer tree whenever it changes.
|
||||||
|
pub dump_layer_tree: bool,
|
||||||
|
|
||||||
/// Print notifications when there is a relayout.
|
/// Print notifications when there is a relayout.
|
||||||
pub relayout_event: bool,
|
pub relayout_event: bool,
|
||||||
|
|
||||||
|
@ -264,6 +270,7 @@ impl DebugOptions {
|
||||||
"dump-display-list" => debug_options.dump_display_list = true,
|
"dump-display-list" => debug_options.dump_display_list = true,
|
||||||
"dump-display-list-json" => debug_options.dump_display_list_json = true,
|
"dump-display-list-json" => debug_options.dump_display_list_json = true,
|
||||||
"dump-display-list-optimized" => debug_options.dump_display_list_optimized = true,
|
"dump-display-list-optimized" => debug_options.dump_display_list_optimized = true,
|
||||||
|
"dump-layer-tree" => debug_options.dump_layer_tree = true,
|
||||||
"relayout-event" => debug_options.relayout_event = true,
|
"relayout-event" => debug_options.relayout_event = true,
|
||||||
"profile-tasks" => debug_options.profile_tasks = true,
|
"profile-tasks" => debug_options.profile_tasks = true,
|
||||||
"profile-script-events" => debug_options.profile_script_events = true,
|
"profile-script-events" => debug_options.profile_script_events = true,
|
||||||
|
@ -406,6 +413,7 @@ pub fn default_opts() -> Opts {
|
||||||
dump_display_list: false,
|
dump_display_list: false,
|
||||||
dump_display_list_json: false,
|
dump_display_list_json: false,
|
||||||
dump_display_list_optimized: false,
|
dump_display_list_optimized: false,
|
||||||
|
dump_layer_tree: false,
|
||||||
relayout_event: false,
|
relayout_event: false,
|
||||||
validate_display_list_geometry: false,
|
validate_display_list_geometry: false,
|
||||||
profile_tasks: false,
|
profile_tasks: false,
|
||||||
|
@ -613,6 +621,7 @@ pub fn from_cmdline_args(args: &[String]) {
|
||||||
dump_display_list: debug_options.dump_display_list,
|
dump_display_list: debug_options.dump_display_list,
|
||||||
dump_display_list_json: debug_options.dump_display_list_json,
|
dump_display_list_json: debug_options.dump_display_list_json,
|
||||||
dump_display_list_optimized: debug_options.dump_display_list_optimized,
|
dump_display_list_optimized: debug_options.dump_display_list_optimized,
|
||||||
|
dump_layer_tree: debug_options.dump_layer_tree,
|
||||||
relayout_event: debug_options.relayout_event,
|
relayout_event: debug_options.relayout_event,
|
||||||
validate_display_list_geometry: debug_options.validate_display_list_geometry,
|
validate_display_list_geometry: debug_options.validate_display_list_geometry,
|
||||||
sniff_mime_types: opt_match.opt_present("sniff-mime-types"),
|
sniff_mime_types: opt_match.opt_present("sniff-mime-types"),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue