Improve terminal rendering performance (#33345)
Closes #18263 Improvements: • **Batch text rendering** - Combine adjacent cells with identical styling into single text runs to reduce draw calls • **Throttle hyperlink searches** - Limit hyperlink detection to every 100ms or when mouse moves >5px to reduce CPU usage • **Pre-allocate collections** - Use `Vec::with_capacity()` for cells, runs, and regions to minimize reallocations • **Optimize background regions** - Merge adjacent background rectangles to reduce number of draw operations • **Cache selection text** - Only compute terminal selection string when selection exists Release Notes: - Improved terminal rendering performance. --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
parent
bcac748c2b
commit
925464cfc6
9 changed files with 609 additions and 177 deletions
|
@ -357,6 +357,7 @@ impl WindowTextSystem {
|
|||
text: SharedString,
|
||||
font_size: Pixels,
|
||||
runs: &[TextRun],
|
||||
force_width: Option<Pixels>,
|
||||
) -> ShapedLine {
|
||||
debug_assert!(
|
||||
text.find('\n').is_none(),
|
||||
|
@ -384,7 +385,7 @@ impl WindowTextSystem {
|
|||
});
|
||||
}
|
||||
|
||||
let layout = self.layout_line(&text, font_size, runs);
|
||||
let layout = self.layout_line(&text, font_size, runs, force_width);
|
||||
|
||||
ShapedLine {
|
||||
layout,
|
||||
|
@ -524,6 +525,7 @@ impl WindowTextSystem {
|
|||
text: Text,
|
||||
font_size: Pixels,
|
||||
runs: &[TextRun],
|
||||
force_width: Option<Pixels>,
|
||||
) -> Arc<LineLayout>
|
||||
where
|
||||
Text: AsRef<str>,
|
||||
|
@ -544,9 +546,9 @@ impl WindowTextSystem {
|
|||
});
|
||||
}
|
||||
|
||||
let layout = self
|
||||
.line_layout_cache
|
||||
.layout_line(text, font_size, &font_runs);
|
||||
let layout =
|
||||
self.line_layout_cache
|
||||
.layout_line_internal(text, font_size, &font_runs, force_width);
|
||||
|
||||
font_runs.clear();
|
||||
self.font_runs_pool.lock().push(font_runs);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue