Add debug option to paint rectangles around text primitives

This commit is contained in:
Emil Ernerfeldt 2021-01-10 10:42:15 +01:00
parent d895285482
commit 1b3a5e5b50
2 changed files with 17 additions and 1 deletions

View file

@ -883,6 +883,7 @@ impl paint::TessellationOptions {
anti_alias, anti_alias,
coarse_tessellation_culling, coarse_tessellation_culling,
debug_paint_clip_rects, debug_paint_clip_rects,
debug_paint_text_rects,
debug_ignore_clip_rects, debug_ignore_clip_rects,
} = self; } = self;
ui.checkbox(anti_alias, "Antialias"); ui.checkbox(anti_alias, "Antialias");
@ -890,7 +891,8 @@ impl paint::TessellationOptions {
coarse_tessellation_culling, coarse_tessellation_culling,
"Do coarse culling in the tessellator", "Do coarse culling in the tessellator",
); );
ui.checkbox(debug_paint_clip_rects, "Paint clip rectangles (debug)");
ui.checkbox(debug_ignore_clip_rects, "Ignore clip rectangles (debug)"); ui.checkbox(debug_ignore_clip_rects, "Ignore clip rectangles (debug)");
ui.checkbox(debug_paint_clip_rects, "Paint clip rectangles (debug)");
ui.checkbox(debug_paint_text_rects, "Paint text bounds (debug)");
} }
} }

View file

@ -458,6 +458,8 @@ pub struct TessellationOptions {
pub coarse_tessellation_culling: bool, pub coarse_tessellation_culling: bool,
/// Output the clip rectangles to be painted? /// Output the clip rectangles to be painted?
pub debug_paint_clip_rects: bool, pub debug_paint_clip_rects: bool,
/// Output the text-containing rectangles
pub debug_paint_text_rects: bool,
/// If true, no clipping will be done /// If true, no clipping will be done
pub debug_ignore_clip_rects: bool, pub debug_ignore_clip_rects: bool,
} }
@ -468,6 +470,7 @@ impl Default for TessellationOptions {
aa_size: 1.0, aa_size: 1.0,
anti_alias: true, anti_alias: true,
coarse_tessellation_culling: true, coarse_tessellation_culling: true,
debug_paint_text_rects: false,
debug_paint_clip_rects: false, debug_paint_clip_rects: false,
debug_ignore_clip_rects: false, debug_ignore_clip_rects: false,
} }
@ -789,6 +792,17 @@ impl Tessellator {
text_style, text_style,
color, color,
} => { } => {
if options.debug_paint_text_rects {
self.tessellate_rect(
&PaintRect {
rect: Rect::from_min_size(pos, galley.size).expand(0.5),
corner_radius: 2.0,
fill: Default::default(),
stroke: (0.5, color).into(),
},
out,
);
}
self.tessellate_text(fonts, pos, &galley, text_style, color, out); self.tessellate_text(fonts, pos, &galley, text_style, color, out);
} }
} }