perf: fast display (row runs, bulk fills, pixel scroll), terminal draws changed cells only + scrolls pixels, print! batched (was IPC per fmt fragment), snake sleeps on timer
This commit is contained in:
@@ -10,4 +10,18 @@ pub trait Framebuffer {
|
||||
fn fill_rect(&mut self, x: ScreenCoord, y: ScreenCoord, w: Dimension, h: Dimension, color: Color);
|
||||
fn clear(&mut self, color: Color);
|
||||
fn flush(&mut self);
|
||||
|
||||
/// A run of pixels from (x, y) rightwards, clipped at the screen edge.
|
||||
fn write_row(&mut self, x: ScreenCoord, y: ScreenCoord, pixels: &[Color]) {
|
||||
for (i, c) in pixels.iter().enumerate() {
|
||||
let Some(px) = u16::try_from(i).ok().and_then(|i| x.raw().checked_add(i)) else {
|
||||
return;
|
||||
};
|
||||
self.write_pixel(ScreenCoord::new(px), y, *c);
|
||||
}
|
||||
}
|
||||
|
||||
/// Moves the band of rows from `top`, `height` tall, up by `by` rows,
|
||||
/// and fills the `by` rows left at its bottom with `fill`.
|
||||
fn scroll_up(&mut self, top: ScreenCoord, height: Dimension, by: Dimension, fill: Color);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user