From 29e024c83ff7d3d1aa23add5f8369ae37e5de534 Mon Sep 17 00:00:00 2001 From: Pyfisch Date: Sun, 21 Jan 2018 21:31:03 +0100 Subject: [PATCH] Print WebRender display lists The debug options * dump-display-list * dump-display-list-json now print WebRender display lists instead of Servo DLs. --- Cargo.lock | 11 +++++++++++ components/gfx/display_list/mod.rs | 24 ------------------------ components/layout_thread/Cargo.toml | 3 ++- components/layout_thread/lib.rs | 22 ++++++++++++++-------- 4 files changed, 27 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a71b432ef1d8..2ce0a453c7dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1460,6 +1460,7 @@ dependencies = [ "profile_traits 0.0.1", "range 0.0.1", "rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ron 0.2.0 (git+https://github.com/ron-rs/ron)", "script 0.0.1", "script_layout_interface 0.0.1", "script_traits 0.0.1", @@ -2327,6 +2328,15 @@ name = "regex-syntax" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "ron" +version = "0.2.0" +source = "git+https://github.com/ron-rs/ron#d19c857a268ac7d27e5ef8dd5423d2e3542a804d" +dependencies = [ + "bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rust-webvr" version = "0.9.7" @@ -3752,6 +3762,7 @@ dependencies = [ "checksum ref_slice 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "825740057197b7d43025e7faf6477eaabc03434e153233da02d1f44602f71527" "checksum regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1731164734096285ec2a5ec7fea5248ae2f5485b3feeb0115af4fda2183b2d1b" "checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db" +"checksum ron 0.2.0 (git+https://github.com/ron-rs/ron)" = "" "checksum rust-webvr 0.9.7 (registry+https://github.com/rust-lang/crates.io-index)" = "4f0a5115abda9e10f6ea04c475a92d97bf8c4e6ddb6276e4db548c0d3c1524cd" "checksum rust-webvr-api 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "712e22ba3c03a7075b40842ae91029a0ab96a81f95e97c0cf623800ec0cbac07" "checksum rustc-demangle 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3058a43ada2c2d0b92b3ae38007a2d0fa5e9db971be260e0171408a4ff471c95" diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs index d481ef170173..02b6d238a354 100644 --- a/components/gfx/display_list/mod.rs +++ b/components/gfx/display_list/mod.rs @@ -18,7 +18,6 @@ use app_units::Au; use euclid::{Transform3D, Point2D, Vector2D, Rect, Size2D, TypedRect, SideOffsets2D}; use euclid::num::{One, Zero}; use gfx_traits::{self, StackingContextId}; -use gfx_traits::print_tree::PrintTree; use ipc_channel::ipc::IpcSharedMemory; use msg::constellation_msg::PipelineId; use net_traits::image::base::{Image, PixelFormat}; @@ -123,29 +122,6 @@ impl DisplayList { None } - - pub fn print(&self) { - let mut print_tree = PrintTree::new("Display List".to_owned()); - self.print_with_tree(&mut print_tree); - } - - pub fn print_with_tree(&self, print_tree: &mut PrintTree) { - print_tree.new_level("ClipScrollNodes".to_owned()); - for node in &self.clip_scroll_nodes { - print_tree.add_item(format!("{:?}", node)); - } - print_tree.end_level(); - - print_tree.new_level("Items".to_owned()); - for item in &self.list { - print_tree.add_item(format!("{:?} StackingContext: {:?} {:?}", - item, - item.base().stacking_context_id, - item.clipping_and_scrolling()) - ); - } - print_tree.end_level(); - } } impl gfx_traits::DisplayList for DisplayList { diff --git a/components/layout_thread/Cargo.toml b/components/layout_thread/Cargo.toml index 661a7f849de4..229dfe1a62f6 100644 --- a/components/layout_thread/Cargo.toml +++ b/components/layout_thread/Cargo.toml @@ -34,6 +34,7 @@ parking_lot = "0.4" profile_traits = {path = "../profile_traits"} range = {path = "../range"} rayon = "0.8" +ron = {git = "https://github.com/ron-rs/ron"} script = {path = "../script"} script_layout_interface = {path = "../script_layout_interface"} script_traits = {path = "../script_traits"} @@ -47,4 +48,4 @@ servo_geometry = {path = "../geometry"} servo_url = {path = "../url"} style = {path = "../style"} style_traits = {path = "../style_traits"} -webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]} +webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc", "debug-serialization"]} diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index fcd790fe6ec1..d1de1f16ba89 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -33,6 +33,7 @@ extern crate parking_lot; extern crate profile_traits; extern crate range; extern crate rayon; +extern crate ron; extern crate script; extern crate script_layout_interface; extern crate script_traits; @@ -1018,18 +1019,23 @@ impl LayoutThread { } let display_list = (*rw_data.display_list.as_ref().unwrap()).clone(); + debug!("Layout done!"); + + // TODO: Avoid the temporary conversion and build webrender sc/dl directly! + let webrender_display_list = rw_data.display_list.as_ref().unwrap() + .convert_to_webrender(self.id).finalize(); + if opts::get().dump_display_list { - display_list.print(); + println!("// Display List from {:?}\n{}", + self.epoch.get(), + ron::ser::to_string_pretty( + &webrender_display_list, + ron::ser::PrettyConfig::default()).unwrap()); } if opts::get().dump_display_list_json { - println!("{}", serde_json::to_string_pretty(&display_list).unwrap()); + println!("{}", serde_json::to_string_pretty(&webrender_display_list).unwrap()); } - debug!("Layout done!"); - - // TODO: Avoid the temporary conversion and build webrender sc/dl directly! - let builder = rw_data.display_list.as_ref().unwrap().convert_to_webrender(self.id); - let viewport_size = Size2D::new(self.viewport_size.width.to_f32_px(), self.viewport_size.height.to_f32_px()); @@ -1049,7 +1055,7 @@ impl LayoutThread { webrender_api::Epoch(epoch.0), Some(get_root_flow_background_color(layout_root)), viewport_size, - builder.finalize(), + webrender_display_list, true); txn.generate_frame(); self.webrender_api.send_transaction(self.webrender_document, txn);