Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions docs/DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ artifacts: `$JOB_TMP/map-*.json`).
PSP bin wraps it with QuickJS + sceGu; `wasm32-unknown-unknown` build wraps
it with a deterministic software rasterizer used by BOTH the browser dev
host and headless Bun goldens. One layout engine everywhere.
- **Damage is backend-independent**: `engine/core/src/damage.rs` compares
retained DrawLists and returns logical damage regions for one persistent
framebuffer. RGBA8, PPA-memory ARGB8 and RGB565 software paths clear each
region and replay the complete DrawList under a root clip; framebuffer
format/scale signatures and `Ui::raster_revision()` prevent stale reuse.
Region limits and full-redraw thresholds remain backend policy.
- **ESP32-P4 stays 16-bit**: `engine/backends/esp32p4-ppa/` consumes the same
DrawList into an opaque RGB565 target. It maps flat fills, A8 coverage
blending, and compatible PSM 5650 texture transforms to the PPA, then
Expand Down Expand Up @@ -128,9 +134,11 @@ PocketJS/
handles are exposed as ui.__textures / ui.__sprites [R]
engine/wasm/ Rust cdylib `pocketjs-wasm` — core + rasterizer, no wasm-bindgen
framework/src/lib.rs extern "C" op mirror + byte-exact render() at 480×272;
renderScaled(1..4) rasterizes directly at physical density
renderScaled(1..4) rasterizes directly at physical density;
opt-in incremental exports retain and repaint damage regions
engine/core/src/damage.rs DrawList diff, logical damage plans and per-target snapshots
engine/core/src/raster.rs shared deterministic scanline rasterizer used by wasm and
native capture (blend, gradients, glyphs, textures)
native capture (full and region-clipped RGBA/ARGB/RGB565)
framework/src/ TS/JS runtime shared by all hosts
renderer.ts Solid universal createRenderer; JS mirror tree; setProperty
DISPATCH TABLE [R]: class→styleId, on*→input registry,
Expand Down
2 changes: 1 addition & 1 deletion docs/STRUCTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ directory; nothing else gets a top-level name.
```
pocketjs/
├─ engine/ Cores: the Rust simulation cores
│ ├─ core/ pocketjs-core — retained UI tree, taffy layout, raster (standalone crate)
│ ├─ core/ pocketjs-core — retained UI tree, taffy layout, damage + raster (standalone crate)
│ ├─ backends/ platform render backends (ESP32-P4 PPA is a standalone no_std crate)
│ ├─ wasm/ core compiled to wasm32 for web/sim hosts (standalone crate)
│ ├─ pocket3d/ the 3D core family (bsp, cook, gu, vita) + desktop examples
Expand Down
23 changes: 23 additions & 0 deletions engine/backends/esp32p4-ppa/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,29 @@ Gradients, arbitrary triangles, textured triangles, and unsupported texture
formats fall back to `pocketjs_core::raster::render_scaled_rgb565_over`.
No full-frame RGB888 or ARGB8888 surface is allocated.

## Incremental rendering

`Renderer::render_incremental` uses the backend-independent
`pocketjs_core::damage::DamageTracker` to compare the current DrawList with
the DrawList that produced a persistent RGB565 target. Changed operation
bounds are collected into up to 8 disjoint logical damage rectangles. Each
rectangle is cleared and the current DrawList is replayed through that
rectangle's scissor, preserving normal painter order and translucent
composition without touching unchanged pixels.

Keep one `RenderTargetState` per framebuffer. This is required for
double-buffered hosts because each target contains a different older frame.
The first render and structural DrawList changes use a conservative full
redraw. This backend additionally promotes damage covering at least 75
percent of the viewport; that transaction-cost policy is deliberately kept
outside the common damage planner.

Core-managed texture, font, and style mutations bump `Ui::raster_revision()`,
so every `RenderTargetState` automatically forces a complete repaint and the
renderer drops texture classifications even when DrawList handles stay
unchanged. Call `Renderer::invalidate_resources()` and explicitly invalidate
target states only for output-affecting changes performed outside `Ui`.

## Test

Run the portable renderer and pixel-parity tests on the host:
Expand Down
Loading
Loading