Files

29 lines
1.8 KiB
Markdown
Raw Permalink Normal View History

# Proposal
## Why
The render loop repaints the full canvas on every frame callback (~60 fps) even though the simulation ticks at only 20 tps and starts paused, so most frames draw an identical image. This keeps CPU usage at ~85% during idle, dominated by the full-canvas clear and the full grid scan.
## What Changes
- Split simulation timing out of `redraw()`; ticks are driven by the event loop, not by the render call.
- Render a frame only when displayed content can have changed: a simulation tick, cell edit or pattern placement, pattern preview movement (pointer motion, tool selection, rotation), grid-line toggle, or canvas resize.
- When nothing changed, commit an empty frame (frame callback without attaching a new buffer), so the idle loop costs nearly nothing.
- Draw incrementally: keep a snapshot of the grid as last rendered, diff it per row against the current grid, and repaint only changed cells (background, grid-line fragments, cell) instead of clearing the whole canvas.
- Report damage for the changed region instead of the whole surface.
- Full-canvas repaint remains for resize, grid-line toggle, and when the diff covers most of the grid.
## Capabilities
### New Capabilities
- `on-demand-rendering`: Scheduling of window repaints — when a frame is produced (only on content change) and how changed cells are drawn incrementally.
### Modified Capabilities
## Impact
- `wlgol.c`: render loop (`redraw`, `wl_callack_done`, `main` dispatch loop), simulation tick timing, buffer commit/damage logic.
- `include/grid.h` / `grid.c`: possible helper for snapshotting the grid (no behavioral change to existing grid functions).
- No protocol, dependency, or configuration changes. Rendering output is visually identical to the current renderer; only the frequency and extent of repainting change.