diff --git a/gfx/wr/webrender/src/debug_item.rs b/gfx/wr/webrender/src/debug_item.rs index 1efea167ff4c..63789d4f2bdb 100644 --- a/gfx/wr/webrender/src/debug_item.rs +++ b/gfx/wr/webrender/src/debug_item.rs @@ -16,6 +16,7 @@ pub enum DebugItem { outer_color: ColorF, inner_color: ColorF, rect: DeviceRect, + thickness: i32, }, } diff --git a/gfx/wr/webrender/src/frame_builder.rs b/gfx/wr/webrender/src/frame_builder.rs index 692d8d4cb011..a74ccb99ecfd 100644 --- a/gfx/wr/webrender/src/frame_builder.rs +++ b/gfx/wr/webrender/src/frame_builder.rs @@ -844,7 +844,7 @@ impl FrameBuilder { world_rect.min + WorldVector2D::new(STROKE_WIDTH, STROKE_WIDTH), world_rect.max - WorldVector2D::new(STROKE_WIDTH, STROKE_WIDTH) ); - scratch.push_debug_rect(interior_world_rect * DevicePixelScale::new(1.0), border, fill_color); + scratch.push_debug_rect(interior_world_rect * DevicePixelScale::new(1.0), 1, border, fill_color); } Some(()) diff --git a/gfx/wr/webrender/src/picture.rs b/gfx/wr/webrender/src/picture.rs index 34b75287bd08..8774b5f18b1b 100644 --- a/gfx/wr/webrender/src/picture.rs +++ b/gfx/wr/webrender/src/picture.rs @@ -7021,6 +7021,7 @@ impl PicturePrimitive { ) { fn draw_debug_border( local_rect: &PictureRect, + thickness: i32, pic_to_world_mapper: &SpaceMapper, global_device_pixel_scale: DevicePixelScale, color: ColorF, @@ -7030,6 +7031,7 @@ impl PicturePrimitive { let device_rect = world_rect * global_device_pixel_scale; scratch.push_debug_rect( device_rect, + thickness, color, ColorF::TRANSPARENT, ); @@ -7079,6 +7081,7 @@ impl PicturePrimitive { if let Some(rect) = rect { draw_debug_border( &rect, + 1, &map_pic_to_world, frame_context.global_device_pixel_scale, ColorF::new(0.0, 1.0, 0.0, 0.2), @@ -7089,7 +7092,7 @@ impl PicturePrimitive { } } else { // Non-tiled picture - layer_color = ColorF::new(1.0, 0.0, 0.0, 0.8); + layer_color = ColorF::new(1.0, 0.0, 0.0, 0.5); } // Draw a rectangle for the whole picture. @@ -7099,6 +7102,7 @@ impl PicturePrimitive { draw_debug_border( &pic_rect, + 3, &map_pic_to_world, frame_context.global_device_pixel_scale, layer_color, @@ -7409,6 +7413,7 @@ impl TileNode { let inner_color = outer_color.scale_alpha(0.5); scratch.push_debug_rect( device_rect.inflate(-3.0, -3.0), + 1, outer_color, inner_color ); diff --git a/gfx/wr/webrender/src/prim_store/mod.rs b/gfx/wr/webrender/src/prim_store/mod.rs index a6b0ed66dd14..6c0301105117 100644 --- a/gfx/wr/webrender/src/prim_store/mod.rs +++ b/gfx/wr/webrender/src/prim_store/mod.rs @@ -1380,31 +1380,32 @@ impl PrimitiveScratchBuffer { WorldPoint::new(rect.min.x + stroke_width, rect.min.y), WorldPoint::new(rect.max.x - stroke_width, rect.min.y + stroke_width) ); - self.push_debug_rect(top_edge * DevicePixelScale::new(1.0), border, border); + self.push_debug_rect(top_edge * DevicePixelScale::new(1.0), 1, border, border); let bottom_edge = WorldRect::new( WorldPoint::new(rect.min.x + stroke_width, rect.max.y - stroke_width), WorldPoint::new(rect.max.x - stroke_width, rect.max.y) ); - self.push_debug_rect(bottom_edge * DevicePixelScale::new(1.0), border, border); + self.push_debug_rect(bottom_edge * DevicePixelScale::new(1.0), 1, border, border); let right_edge = WorldRect::new( WorldPoint::new(rect.max.x - stroke_width, rect.min.y), rect.max ); - self.push_debug_rect(right_edge * DevicePixelScale::new(1.0), border, border); + self.push_debug_rect(right_edge * DevicePixelScale::new(1.0), 1, border, border); let left_edge = WorldRect::new( rect.min, WorldPoint::new(rect.min.x + stroke_width, rect.max.y) ); - self.push_debug_rect(left_edge * DevicePixelScale::new(1.0), border, border); + self.push_debug_rect(left_edge * DevicePixelScale::new(1.0), 1, border, border); } #[allow(dead_code)] pub fn push_debug_rect( &mut self, rect: DeviceRect, + thickness: i32, outer_color: ColorF, inner_color: ColorF, ) { @@ -1412,6 +1413,7 @@ impl PrimitiveScratchBuffer { rect, outer_color, inner_color, + thickness, }); } diff --git a/gfx/wr/webrender/src/renderer/debug.rs b/gfx/wr/webrender/src/renderer/debug.rs index 7e16d15d763b..d31d53cc23f3 100644 --- a/gfx/wr/webrender/src/renderer/debug.rs +++ b/gfx/wr/webrender/src/renderer/debug.rs @@ -285,13 +285,23 @@ impl DebugRenderer { } - pub fn add_rect(&mut self, rect: &DeviceIntRect, color: ColorU) { + pub fn add_rect(&mut self, rect: &DeviceIntRect, thickness: i32, color: ColorU) { let p0 = rect.min; let p1 = rect.max; - self.add_line(p0.x, p0.y, color, p1.x, p0.y, color); - self.add_line(p1.x, p0.y, color, p1.x, p1.y, color); - self.add_line(p1.x, p1.y, color, p0.x, p1.y, color); - self.add_line(p0.x, p1.y, color, p0.x, p0.y, color); + if thickness > 1 && rect.width() > thickness * 2 && rect.height() > thickness * 2 { + let w = thickness as f32; + let p0 = p0.to_f32(); + let p1 = p1.to_f32(); + self.add_quad(p0.x, p0.y, p1.x, p0.y + w, color, color); + self.add_quad(p1.x - w, p0.y + w, p1.x, p1.y - w, color, color); + self.add_quad(p0.x, p1.y - w, p1.x, p1.y, color, color); + self.add_quad(p0.x, p0.y + w, p0.x + w, p1.y - w, color, color); + } else { + self.add_line(p0.x, p0.y, color, p1.x, p0.y, color); + self.add_line(p1.x, p0.y, color, p1.x, p1.y, color); + self.add_line(p1.x, p1.y, color, p0.x, p1.y, color); + self.add_line(p0.x, p1.y, color, p0.x, p0.y, color); + } } pub fn render( diff --git a/gfx/wr/webrender/src/renderer/mod.rs b/gfx/wr/webrender/src/renderer/mod.rs index 446a2f4be3fe..eb6ce8db76c4 100644 --- a/gfx/wr/webrender/src/renderer/mod.rs +++ b/gfx/wr/webrender/src/renderer/mod.rs @@ -4960,20 +4960,26 @@ impl Renderer { for item in items { match item { - DebugItem::Rect { rect, outer_color, inner_color } => { - debug_renderer.add_quad( - rect.min.x, - rect.min.y, - rect.max.x, - rect.max.y, - (*inner_color).into(), - (*inner_color).into(), - ); + DebugItem::Rect { rect, outer_color, inner_color, thickness } => { + if inner_color.a > 0.001 { + let rect = rect.inflate(-thickness as f32, -thickness as f32); + debug_renderer.add_quad( + rect.min.x, + rect.min.y, + rect.max.x, + rect.max.y, + (*inner_color).into(), + (*inner_color).into(), + ); + } - debug_renderer.add_rect( - &rect.to_i32(), - (*outer_color).into(), - ); + if outer_color.a > 0.001 { + debug_renderer.add_rect( + &rect.to_i32(), + *thickness, + (*outer_color).into(), + ); + } } DebugItem::Text { ref msg, position, color } => { debug_renderer.add_text( @@ -5059,6 +5065,7 @@ impl Renderer { debug_renderer.add_rect( &target_rect.inflate(1, 1), + 1, debug_colors::RED.into(), );