perf: clear only the actual margin instead of the whole pixel buffer
Profiling (see ROADMAP.md's "Performance profiling infrastructure"
entry) found render.draw's unconditional fill_rect over the entire
pixel buffer -- there only so the right/bottom margin past
grid.cols*cell_w/grid.rows*cell_h picks up the theme background when
the window size isn't an exact multiple of the cell size -- costing
9.4ms/frame, tied with all of draw_row_backgrounds combined. Every
cell draw_row_backgrounds covers gets repainted right after anyway,
so clearing the whole buffer was redundant everywhere but the true
margin.
Fixed by clearing only the right/bottom margin rectangles (skipped
entirely when there's no margin in a given dimension), decomposed so
the bottom-right corner is covered exactly once. Re-profiling the
identical workload confirms it: render.draw_clear dropped from
9.4ms/frame to 0.19ms/frame (~50x), and render.draw's own average
fell from 24.3ms/frame to 16.3ms/frame -- now essentially at the 60Hz
frame budget on average, though the heaviest frame still exceeds it.
draw_row_backgrounds is now clearly the largest remaining cost; see
ROADMAP.md's revised "Damage tracking" entry for what that changes.
render/render_test.odin gains a regression test for the
exact-multiple-in-one-dimension-only case the two-rect decomposition
introduces (the existing margin test only covered margin in both
dimensions).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>