TASK 31: SceneGraph component + baked-crust compositor optimization

- Add ElementKind (Static/Dynamic) to SceneElement base; Source/WebcamSceneConfig classify
- Services/SceneGraph.cs: owns the Scenes collection (ViewModel's Scenes delegates to it),
  the element mutation surface (Add/Insert/Remove/Move, each invalidating the bake), and the
  queries that were scattered LINQ (GetBackground/GetWebcam/GetChatBoxes/GetSplitPoint/IsStatic)
- SceneCompositor: split-aware BakeStaticBase + CompositeLayers + Render(.., staticBase, split);
  builds/caches the static base below the split point in source-rect space
- FramePump: optional SceneGraph -> optimized bake+composite path; falls back to full render
- MainViewModel: routes element mutations through the graph; invalidates the bake on static
  layout/opacity/visibility/useDefaultBackground changes and after background heal/Ensure
- Integration test SceneGraphTests.BakedStaticBase_WithDynamicLayer_CompositesCorrectly

Derivative survey (mandated): tried before writing — OBS does per-source opacity/visibility
caching and static-scene baking; this mirrors OBS's 'cached static source' optimization.
3 documented defensive deviations from the spec (ChatOverlayLayer stays decoupled;
background helpers stay VM-static for direct testability; full facade peel deferred post-1.0)
in TASKS.md + ai.md. Scope check passed; clean build 0 warnings.
This commit is contained in:
2026-08-31 17:53:34 -07:00
parent 3bf053a3b1
commit 670fe3a10a
15 changed files with 618 additions and 54 deletions
+29 -12
View File
@@ -2,13 +2,15 @@
## Branch / Commit State
**`main`**, working tree is **CLEAN**. `origin/main` == `85893ea` (pushed).
**`main`**. TASK 31 (SceneGraph + baked-crust compositor) implemented, tests green,
docs updated — **uncommitted**, ready to commit as one work unit (pending push at
the user's checkpoint).
**Pushed** (reached `origin/main` == `85893ea`, incl. tags): Phase 1 commit `0` +
refactor commits `1..11` + **Phase 2 commits `12..18`** + the `Controls/index.md`
docs commit `cb54637` + **Phase 3 splits A–E** (tags `refactor-commit-A..E`) +
**Commit F (Recording, `refactor-commit-F`)** + **Commit G (ChatOverlayLayer,
`refactor-commit-G`)**. Everything is pushed; nothing local-only.
`refactor-commit-G`)**. Everything before TASK 31 is pushed; nothing local-only.
**Commit log (all pushed):**
@@ -25,10 +27,16 @@ docs commit `cb54637` + **Phase 3 splits A–E** (tags `refactor-commit-A..E`) +
## What's In Flight
Nothing code-in-flight — working tree clean.
**TASK 31 designed:** SceneGraph component + baked-crust compositor optimization.
Design captured in `TASKS.md`, pattern note in `ai.md`. Ready to implement.
**TASK 31 (SceneGraph + baked-crust compositor) implemented — uncommitted, tests green.**
Files touched (see `git status`): `Models/SceneElement.cs`, `Models/Source.cs`,
`Models/WebcamSceneConfig.cs`, `Services/SceneGraph.cs` (new), `Services/Compositor/SceneCompositor.cs`,
`Services/Encoder/FramePump.cs`, `ViewModels/MainViewModel.cs`, `MainViewModel.Scenes.cs`,
`MainViewModel.Sources.cs`, `MainViewModel.Webcam.cs`, `MainViewModel.Background.cs`,
`ytLive.Tests/SceneGraphTests.cs` (new), `ai.md`, `TASKS.md`, `HANDOFF.md`.
Verification: SceneCompositorTests 4, StretchMathTests 4, BackgroundTests 16,
SceneCatalogTests 18, LayoutStorePersistenceTests 12, FramePumpTests 9,
SceneGraphTests 1 — all green. RealAppHost GUI tests hang headless (pre-existing).
Next: run `scripts/verify.sh`/`scope-check.sh`, commit, await user's push go-ahead.
**The directive (2026-08-31, user):** rewrite the project, breaking files into
**functional components to compliment AI retrieval/processing** — NOT line-count
@@ -48,11 +56,13 @@ extracted services** (`AudioMixer`, `CameraManager`, `ScreenCaptureManager`,
`ChatBoxRenderer`, `SocialValidator`). They have no cohesive owner-state blob to
peel — forcing extraction adds coupling. **Chat was the one clean peel.**
**Next (recommended):** the one remaining *genuine* big decomposition is the
**scene-graph segment** (the `Scenes`/`StagedScene`/element-inventory backbone
every feature hangs off). This is a real architectural redesign — a `SceneGraph`
owner-object with narrow seams — that touches the binding surface and needs
design review, NOT an unsupervised autonomous peel. Do not attempt it blind pre-1.0.
**Next (recommended):** TASK 31 landed the *core* of the scene-graph architecture
(the `SceneGraph` owner-object owning the collection + mutation surface, and the
baked-crust compositor optimization) without the full binding-surface peel. The
remaining step is the ViewModel-as-thin-facade migration (moving the many
`Scenes`/`StagedScene`/`LiveScene` binding call sites onto the graph) — deferred
as post-1.0 in `TASKS.md` because it is exactly the "unsupervised blind peel"
regression risk. Do it at a real Windows session where the GUI tests can run.
**Pending bus:** `ViewModels/index.md` Phase 3 tracker has rows A–E (closed);
Phase 3 marked COMPLETE. Watch-list (under limit, no action): `Controls/PreviewPane.xaml.cs`
@@ -88,7 +98,7 @@ Phase 3 marked COMPLETE. Watch-list (under limit, no action): `Controls/PreviewP
- MainWindow.xaml refactor: **Phase 2 complete (6/6 controls)**, pushed at `1f4624c`.
- 500-line compliance: **Phase 3 complete (A–E, all ≤500)**, pushed.
- **True decomposition: Commit G — `Services/ChatOverlayLayer.cs` shipped + pushed** (first owner-state component; pattern recorded in `ai.md`).
- **Next (design-needed, do NOT blind-peel):** the scene-graph segment (`SceneGraph` owner-object) — the one remaining genuine big decomposition; touches binding surface, needs review.
- **TASK 31 — SceneGraph + baked-crust compositor: implemented, tests green, uncommitted** (core optimization + collection/mutation ownership + integration test; see `TASKS.md` for the 3 documented defensive deviations). The full ViewModel-as-thin-facade peel (moving the entire binding surface) is intentionally deferred post-1.0 — flagged in `TASKS.md`.
- TASK 3: 27/30 (preview compositor 16, text source 17, alerts 20 still open).
- TASK 4: ✅ shipped. TASK 9: items 1–3 shipped; 4–7 open. TASK 10: steps 1–7; Velopack pending.
- TASK 18: shipped, creator verification pending. TASK 19/23, 20, 21-A: shipped.
@@ -114,3 +124,10 @@ Phase 3 marked COMPLETE. Watch-list (under limit, no action): `Controls/PreviewP
`git checkout --`, re-ran from temp files. **Lesson** in `MyMistakes.md`: never
`awk … > SRC` while awking SRC; stage cuts into temp files, then assemble.
- Everything through G is **pushed to `origin/main` (`85893ea`)** with tags A–G.
- **TASK 31 implemented (uncommitted, tests green):** added `ElementKind` (Static/Dynamic);
created `Services/SceneGraph.cs` owning the collection + mutation surface + bake cache;
made `SceneCompositor` split-aware (`BakeStaticBase`/`CompositeLayers`/`Render(staticBase,split)`);
wired `FramePump` to the optimized path; invalidated the bake on static mutations; added
`SceneGraphTests.BakedStaticBase_WithDynamicLayer_CompositesCorrectly`. 3 documented defensive
deviations from the spec (ChatOverlayLayer stays decoupled; background helpers stay VM-static for
direct testability; full facade peel deferred post-1.0). See `TASKS.md` → TASK 31.