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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Bobby Holley 2019-09-25 21:46:20 +00:00
parent 8d86dd4c94
commit d599cb6095
4 changed files with 15 additions and 12 deletions

View File

@ -20,7 +20,8 @@ pub enum DebugItem {
position: DevicePoint,
},
Rect {
color: ColorF,
outer_color: ColorF,
inner_color: ColorF,
rect: DeviceRect,
},
}

View File

@ -4173,9 +4173,12 @@ impl TileNode {
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, .. } => {

View File

@ -1753,11 +1753,13 @@ impl PrimitiveScratchBuffer {
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,
});
}
@ -2226,7 +2228,7 @@ impl PrimitiveStore {
};
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));
}
}

View File

@ -4856,22 +4856,19 @@ impl Renderer {
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 } => {