feat: add partial update support with caller-declared dirty tracking

- Add PartialUpdate dataclass and supports_partial_updates to EffectPlugin
- Add dirty region tracking to Canvas (mark_dirty, get_dirty_rows, etc.)
- Canvas auto-marks dirty on put_region, put_text, fill
- CanvasStage exposes dirty rows via pipeline context
- EffectChain creates PartialUpdate and calls process_partial() for optimized effects
- HudEffect implements process_partial() to skip processing when rows 0-2 not dirty
- This enables effects to skip work when canvas regions haven't changed
This commit is contained in:
2026-03-16 16:56:45 -07:00
parent f638fb7597
commit 3a3d0c0607
5 changed files with 132 additions and 3 deletions

View File

@@ -530,6 +530,14 @@ class CanvasStage(Stage):
self._canvas = Canvas(width=self._width, height=self._height)
ctx.set("canvas", self._canvas)
# Get dirty regions from canvas and expose via context
# Effects can access via ctx.get_state("canvas.dirty_rows")
if self._canvas.is_dirty():
dirty_rows = self._canvas.get_dirty_rows()
ctx.set_state("canvas.dirty_rows", dirty_rows)
ctx.set_state("canvas.dirty_regions", self._canvas.get_dirty_regions())
return data
def get_canvas(self):