From a0980091cfa8400f553449e180f6466564ae6270 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Thu, 14 May 2015 15:45:41 -0700 Subject: [PATCH] gfx: Implement paint flashing, which will be useful for debugging invalidation. --- components/gfx/Cargo.toml | 1 + components/gfx/lib.rs | 1 + components/gfx/paint_task.rs | 9 +++++++++ components/servo/Cargo.lock | 1 + components/util/opts.rs | 7 +++++++ ports/cef/Cargo.lock | 1 + ports/gonk/Cargo.lock | 1 + 7 files changed, 21 insertions(+) diff --git a/components/gfx/Cargo.toml b/components/gfx/Cargo.toml index a8551de5965..5e26c6a7e0c 100644 --- a/components/gfx/Cargo.toml +++ b/components/gfx/Cargo.toml @@ -74,3 +74,4 @@ time = "0.1.12" bitflags = "*" rustc-serialize = "0.3" libc = "*" +rand = "*" diff --git a/components/gfx/lib.rs b/components/gfx/lib.rs index 52d5a705de8..57633303bfb 100644 --- a/components/gfx/lib.rs +++ b/components/gfx/lib.rs @@ -31,6 +31,7 @@ extern crate net_traits; #[macro_use] extern crate util; extern crate msg; +extern crate rand; extern crate string_cache; extern crate style; extern crate skia; diff --git a/components/gfx/paint_task.rs b/components/gfx/paint_task.rs index 8b11614971f..4b9f2c6f6d1 100644 --- a/components/gfx/paint_task.rs +++ b/components/gfx/paint_task.rs @@ -26,6 +26,7 @@ use msg::constellation_msg::Msg as ConstellationMsg; use msg::constellation_msg::{ConstellationChan, Failure, PipelineId}; use msg::constellation_msg::PipelineExitType; use profile_traits::time::{self, profile}; +use rand::{self, Rng}; use skia::SkiaGrGLNativeContextRef; use std::borrow::ToOwned; use std::mem; @@ -591,6 +592,14 @@ impl WorkerThread { Au::from_px(size.height))), color); } + if opts::get().paint_flashing { + // Overlay a random transparent color. + let color = *rand::thread_rng().choose(&THREAD_TINT_COLORS[..]).unwrap(); + paint_context.draw_solid_color(&Rect(Point2D(Au(0), Au(0)), + Size2D(Au::from_px(size.width), + Au::from_px(size.height))), + color); + } } draw_target diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index 02601a41ffb..4c48122f79e 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -369,6 +369,7 @@ dependencies = [ "plugins 0.0.1", "png 0.1.0 (git+https://github.com/servo/rust-png)", "profile_traits 0.0.1", + "rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "script_traits 0.0.1", "skia 0.0.20130412 (git+https://github.com/servo/skia)", diff --git a/components/util/opts.rs b/components/util/opts.rs index 7183095dd03..8db1abf7574 100644 --- a/components/util/opts.rs +++ b/components/util/opts.rs @@ -90,6 +90,10 @@ pub struct Opts { /// True if we should paint borders around flows based on which thread painted them. pub show_debug_parallel_layout: bool, + /// True if we should paint tiles a random color whenever they're repainted. Useful for + /// debugging invalidation. + pub paint_flashing: bool, + /// If set with --disable-text-aa, disable antialiasing on fonts. This is primarily useful for reftests /// where pixel perfect results are required when using fonts such as the Ahem /// font for layout tests. @@ -167,6 +171,7 @@ pub fn print_debug_usage(app: &str) { print_option("show-fragment-borders", "Paint borders along fragment boundaries."); print_option("show-parallel-paint", "Overlay tiles with colors showing which thread painted them."); print_option("show-parallel-layout", "Mark which thread laid each flow out with colors."); + print_option("paint-flashing", "Overlay repainted areas with a random color."); print_option("trace-layout", "Write layout trace to an external file for debugging."); print_option("validate-display-list-geometry", "Display an error when display list geometry escapes overflow region."); @@ -213,6 +218,7 @@ pub fn default_opts() -> Opts { show_debug_fragment_borders: false, show_debug_parallel_paint: false, show_debug_parallel_layout: false, + paint_flashing: false, enable_text_antialiasing: false, trace_layout: false, devtools_port: None, @@ -388,6 +394,7 @@ pub fn from_cmdline_args(args: &[String]) -> bool { show_debug_fragment_borders: debug_options.contains(&"show-fragment-borders"), show_debug_parallel_paint: debug_options.contains(&"show-parallel-paint"), show_debug_parallel_layout: debug_options.contains(&"show-parallel-layout"), + paint_flashing: debug_options.contains(&"paint-flashing"), enable_text_antialiasing: !debug_options.contains(&"disable-text-aa"), dump_flow_tree: debug_options.contains(&"dump-flow-tree"), dump_display_list: debug_options.contains(&"dump-display-list"), diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index 9b6a0a4cc8f..6d264c1307a 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -378,6 +378,7 @@ dependencies = [ "plugins 0.0.1", "png 0.1.0 (git+https://github.com/servo/rust-png)", "profile_traits 0.0.1", + "rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "script_traits 0.0.1", "skia 0.0.20130412 (git+https://github.com/servo/skia)", diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock index 1f94f0d944a..01ef555ec5b 100644 --- a/ports/gonk/Cargo.lock +++ b/ports/gonk/Cargo.lock @@ -357,6 +357,7 @@ dependencies = [ "plugins 0.0.1", "png 0.1.0 (git+https://github.com/servo/rust-png)", "profile_traits 0.0.1", + "rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "script_traits 0.0.1", "skia 0.0.20130412 (git+https://github.com/servo/skia)",