Bug 1583998 - Refactor debug rectangles to allow the outer and inner colors to be explicitly specified. r=gw
authorBobby Holley <bobbyholley@gmail.com>
Wed, 25 Sep 2019 21:46:20 +0000
changeset 494994 90162306864cefa2889b2fe56701c8149ea25433
parent 494993 344ae0abff73dd19d0a2c4d04f22db45c8bd335b
child 494995 f59ec3966f5f3242b18a188b52217496ec65b42a
push id114131
push userdluca@mozilla.com
push dateThu, 26 Sep 2019 09:47:34 +0000
treeherdermozilla-inbound@1dc1a755079a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgw
bugs1583998
milestone71.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1583998 - Refactor debug rectangles to allow the outer and inner colors to be explicitly specified. r=gw The current code doesn't permit fully opaque debug rects. Differential Revision: https://phabricator.services.mozilla.com/D47154
gfx/wr/webrender/src/debug_render.rs
gfx/wr/webrender/src/picture.rs
gfx/wr/webrender/src/prim_store/mod.rs
gfx/wr/webrender/src/renderer.rs
--- a/gfx/wr/webrender/src/debug_render.rs
+++ b/gfx/wr/webrender/src/debug_render.rs
@@ -15,17 +15,18 @@ use std::f32;
 #[cfg_attr(feature = "replay", derive(Deserialize))]
 pub enum DebugItem {
     Text {
         msg: String,
         color: ColorF,
         position: DevicePoint,
     },
     Rect {
-        color: ColorF,
+        outer_color: ColorF,
+        inner_color: ColorF,
         rect: DeviceRect,
     },
 }
 
 #[derive(Debug, Copy, Clone)]
 enum DebugSampler {
     Font,
 }
--- a/gfx/wr/webrender/src/picture.rs
+++ b/gfx/wr/webrender/src/picture.rs
@@ -4168,19 +4168,22 @@ impl TileNode {
                     debug_colors::GREEN
                 } else {
                     debug_colors::YELLOW
                 };
 
                 let world_rect = pic_to_world_mapper.map(&self.rect).unwrap();
                 let device_rect = world_rect * global_device_pixel_scale;
 
+                let outer_color = color.scale_alpha(0.6);
+                let inner_color = outer_color.scale_alpha(0.5);
                 scratch.push_debug_rect(
                     device_rect.inflate(-3.0, -3.0),
-                    color.scale_alpha(0.6),
+                    outer_color,
+                    inner_color
                 );
             }
             TileNodeKind::Node { ref children, .. } => {
                 for child in children.iter() {
                     child.draw_debug_rects(
                         pic_to_world_mapper,
                         is_opaque,
                         scratch,
--- a/gfx/wr/webrender/src/prim_store/mod.rs
+++ b/gfx/wr/webrender/src/prim_store/mod.rs
@@ -1748,21 +1748,23 @@ impl PrimitiveScratchBuffer {
         assert!(self.recorded_dirty_regions.is_empty(), "Should have sent to Renderer");
         assert!(self.dirty_rects.is_empty(), "Should have sent to Renderer");
     }
 
     #[allow(dead_code)]
     pub fn push_debug_rect(
         &mut self,
         rect: DeviceRect,
-        color: ColorF,
+        outer_color: ColorF,
+        inner_color: ColorF,
     ) {
         self.debug_items.push(DebugItem::Rect {
             rect,
-            color,
+            outer_color,
+            inner_color,
         });
     }
 
     #[allow(dead_code)]
     pub fn push_debug_string(
         &mut self,
         position: DevicePoint,
         color: ColorF,
@@ -2221,17 +2223,17 @@ impl PrimitiveStore {
                             PrimitiveInstanceKind::Image { .. } => debug_colors::BLUE,
                             PrimitiveInstanceKind::LinearGradient { .. } => debug_colors::PINK,
                             PrimitiveInstanceKind::RadialGradient { .. } => debug_colors::PINK,
                             PrimitiveInstanceKind::Clear { .. } => debug_colors::CYAN,
                             PrimitiveInstanceKind::Backdrop { .. } => debug_colors::MEDIUMAQUAMARINE,
                         };
                         if debug_color.a != 0.0 {
                             let debug_rect = clipped_world_rect * frame_context.global_device_pixel_scale;
-                            frame_state.scratch.push_debug_rect(debug_rect, debug_color);
+                            frame_state.scratch.push_debug_rect(debug_rect, debug_color, debug_color.scale_alpha(0.5));
                         }
                     }
 
                     let vis_index = PrimitiveVisibilityIndex(frame_state.scratch.prim_info.len() as u32);
                     if prim_instance.is_chased() {
                         println!("\tvisible {:?} with {:?}", vis_index, combined_local_clip_rect);
                     }
 
--- a/gfx/wr/webrender/src/renderer.rs
+++ b/gfx/wr/webrender/src/renderer.rs
@@ -4851,32 +4851,29 @@ impl Renderer {
 
         let debug_renderer = match self.debug.get_mut(&mut self.device) {
             Some(render) => render,
             None => return,
         };
 
         for item in items {
             match item {
-                DebugItem::Rect { rect, color } => {
-                    let inner_color = color.scale_alpha(0.5).into();
-                    let outer_color = (*color).into();
-
+                DebugItem::Rect { rect, outer_color, inner_color } => {
                     debug_renderer.add_quad(
                         rect.origin.x,
                         rect.origin.y,
                         rect.origin.x + rect.size.width,
                         rect.origin.y + rect.size.height,
-                        inner_color,
-                        inner_color,
+                        (*inner_color).into(),
+                        (*inner_color).into(),
                     );
 
                     debug_renderer.add_rect(
                         &rect.to_i32(),
-                        outer_color,
+                        (*outer_color).into(),
                     );
                 }
                 DebugItem::Text { ref msg, position, color } => {
                     debug_renderer.add_text(
                         position.x,
                         position.y,
                         msg,
                         (*color).into(),