Faster busy-client frames: read only the buffer's bytes, cache the wallpaper, cheaper strokes
CI / test (push) Failing after 18s

Profiling a full-screen terminal at 1080p (about 2 fps):
- snapshot_shm_buffer asked the host to copy the pool from byte 0 to the end of the buffer; foot
  puts its buffers deep in a ~135 MB pool, so every commit moved ~135 MB (~185 ms). New
  sys.mmap-read-at(fd, offset, len) copies just the buffer: step 200 ms -> 5 ms per frame.
- The wallpaper (gradient + discs) is rendered once and copied back each frame while unchanged;
  it is split from the desktop card, which changes every second.
- stroke_rounded_rect walked every pixel of the window to draw a 1px outline; it now only
  draws the border strips (exact per-pixel path kept for the corner bands).
- Window shadows only blend the strips that stick out from under the window.
Rasteriser: ~256 ms -> ~93 ms per full-screen frame. Tests compare strokes and fills with the
old per-pixel code, and check the wallpaper cache.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
nandiandClaude Sonnet 5.5 committed 2026-11-25 04:01:25 -08:00
1 parent 70ad87f2d2
commit 66bf293085
21 files changed
+302 -136

No files matched your search

+50
View File
@@ -76,3 +76,53 @@ test "blitting a client buffer matches per-pixel blending, even partly off scree
}
}
}
///| The old per-pixel stroke, as the reference for the span-based one.
fn reference_stroke(dst : Pixmap, rect : @scene.Rect, color : @scene.Rgba, width : Int, radius : Int, clip : @scene.Rect?) -> Unit {
let x0 = if rect.x < 0 { 0 } else { rect.x }
let y0 = if rect.y < 0 { 0 } else { rect.y }
let x1 = if rect.x + rect.w > dst.width { dst.width } else { rect.x + rect.w }
let y1 = if rect.y + rect.h > dst.height { dst.height } else { rect.y + rect.h }
let inner_x = rect.x + width
let inner_y = rect.y + width
let inner_w = rect.w - width * 2
let inner_h = rect.h - width * 2
let inner_r = if radius > width { radius - width } else { 0 }
for y = y0; y < y1; y = y + 1 {
for x = x0; x < x1; x = x + 1 {
let in_outer = in_rounded_rect(x, y, rect.x, rect.y, rect.w, rect.h, radius)
let in_inner = inner_w > 0 && inner_h > 0 && in_rounded_rect(x, y, inner_x, inner_y, inner_w, inner_h, inner_r)
if in_outer && !in_inner {
blend_pixel(dst, x, y, color.r.to_int(), color.g.to_int(), color.b.to_int(), color.a.to_int(), clip)
}
}
}
}
///|
test "span-based strokes match the per-pixel reference" {
let rects = [(0, 0, 40, 30), (5, 7, 33, 21), (-6, -4, 30, 20), (30, 20, 40, 30), (2, 2, 5, 5), (3, 3, 2, 9), (-10, 15, 80, 8), (10, 2, 20, 44)]
let colors = [@scene.Rgba::new(200, 40, 90, 255), @scene.Rgba::new(10, 200, 120, 128)]
let clips : Array[@scene.Rect?] = [None, Some(@scene.Rect::new(8, 6, 25, 20)), Some(@scene.Rect::new(-5, -5, 20, 20))]
for rc in rects {
for radius in [0, 1, 4, 9, 40] {
for width in [1, 2, 3, 7] {
for col in colors {
for clip in clips {
let a = Pixmap::new(64, 48)
let b = Pixmap::new(64, 48)
for i = 0; i < a.data.length(); i = i + 1 {
let v = ((i * 41 + 5) % 251).to_byte()
a.data[i] = v
b.data[i] = v
}
let r = @scene.Rect::new(rc.0, rc.1, rc.2, rc.3)
stroke_rounded_rect(a, r, col, width, radius, clip)
reference_stroke(b, r, col, width, radius, clip)
assert_eq(a.data, b.data)
}
}
}
}
}
}