| 134 |
134 |
|
color: [f32; 4],
|
| 135 |
135 |
|
}
|
| 136 |
136 |
|
|
|
137 |
+ |
|
| 137 |
138 |
|
impl TextRenderer {
|
| 138 |
139 |
|
pub fn new(
|
| 139 |
140 |
|
device: &wgpu::Device,
|
| 296 |
297 |
|
})
|
| 297 |
298 |
|
}
|
| 298 |
299 |
|
|
| 299 |
|
- |
/// Ensure the per-row cache has `rows` slots. Sizing up appends empty
|
| 300 |
|
- |
/// rows (renderer treats them as no glyphs — caller marks them dirty).
|
| 301 |
|
- |
/// Sizing down truncates. Cache contents are otherwise preserved.
|
|
300 |
+ |
/// Ensure the per-row cache has `rows` slots.
|
| 302 |
301 |
|
pub fn ensure_rows(&mut self, rows: u16) {
|
| 303 |
302 |
|
self.row_cache.resize(rows as usize, Vec::new());
|
| 304 |
303 |
|
}
|
| 305 |
304 |
|
|
| 306 |
|
- |
/// Wipe the per-row cache — for alt-screen swap or full grid resize.
|
|
305 |
+ |
/// Wipe the per-row cache — alt-screen swap or full grid resize.
|
| 307 |
306 |
|
pub fn clear_rows(&mut self) {
|
| 308 |
307 |
|
for row in &mut self.row_cache {
|
| 309 |
308 |
|
row.clear();
|
| 312 |
311 |
|
|
| 313 |
312 |
|
/// Rotate the per-row cache to reflect a fullscreen scroll. Positive =
|
| 314 |
313 |
|
/// scrolled up (contents move up N rows, blank appears at bottom).
|
| 315 |
|
- |
/// Caller is responsible for calling `update_row` on the newly-blank
|
| 316 |
|
- |
/// rows to fill in their fresh contents.
|
| 317 |
314 |
|
pub fn scroll(&mut self, delta: i16) {
|
| 318 |
315 |
|
if delta == 0 || self.row_cache.is_empty() {
|
| 319 |
316 |
|
return;
|
| 327 |
324 |
|
}
|
| 328 |
325 |
|
}
|
| 329 |
326 |
|
|
| 330 |
|
- |
/// Replace one row's cached glyph batch with a fresh build from the
|
| 331 |
|
- |
/// supplied cells. `cells` yields `(col, char, fg_color)` for each cell
|
| 332 |
|
- |
/// that should draw a glyph (blanks skipped by caller).
|
|
327 |
+ |
/// Replace one row's cached glyph batch. Blanks pre-filtered by caller.
|
| 333 |
328 |
|
pub fn update_row(
|
| 334 |
329 |
|
&mut self,
|
| 335 |
330 |
|
queue: &wgpu::Queue,
|
| 340 |
335 |
|
return;
|
| 341 |
336 |
|
};
|
| 342 |
337 |
|
slot.clear();
|
| 343 |
|
- |
// We hold &mut self.row_cache[row], so we can't touch self.cache
|
| 344 |
|
- |
// through &mut self. Take the entries out, work with local refs.
|
| 345 |
338 |
|
let atlas = &mut self.atlas;
|
| 346 |
339 |
|
let cache = &mut self.cache;
|
| 347 |
340 |
|
let shaper = &mut self.shaper;
|
| 376 |
369 |
|
}
|
| 377 |
370 |
|
}
|
| 378 |
371 |
|
|
| 379 |
|
- |
/// Draw one frame from the per-row cache + supplied fills. Positions
|
| 380 |
|
- |
/// are computed here so scroll rotation and scale changes don't
|
| 381 |
|
- |
/// invalidate the cache.
|
|
372 |
+ |
/// Draw one frame from cached per-row glyphs + caller-supplied fills
|
|
373 |
+ |
/// (bg, underline, cursor). Fills are cheap to fully rebuild each frame.
|
| 382 |
374 |
|
pub fn draw_cached(
|
| 383 |
375 |
|
&mut self,
|
| 384 |
376 |
|
device: &wgpu::Device,
|