Skip to content

Commit b1bdab7

Browse files
Strata Foundercursoragent
andcommitted
feat(render): WebGPU/WASM architecture program — compositor, bridge, and worker pipeline
Add strata-bridge IPC parity, strata-wasm exports, @strata/compositor with Canvas2D/WebGPU scaffold, render worker with stale guards, offline ONNX manifest, baseline bench/goldens, and ADRs 0003–0005. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 35c95aa commit b1bdab7

54 files changed

Lines changed: 2155 additions & 200 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ jobs:
3939
run: cargo test --workspace --all-targets
4040
- name: cargo test (desktop)
4141
run: cargo test --manifest-path apps/desktop/src-tauri/Cargo.toml --features custom-protocol
42+
- name: wasm check
43+
if: runner.os == 'Linux'
44+
run: just wasm-check
4245

4346
js:
4447
name: JS (pnpm)
@@ -63,3 +66,21 @@ jobs:
6366
run: pnpm audit:emoji
6467
- name: test
6568
run: pnpm test
69+
70+
e2e:
71+
name: E2E (Playwright)
72+
runs-on: ubuntu-latest
73+
steps:
74+
- uses: actions/checkout@v4
75+
- uses: pnpm/action-setup@v4
76+
with:
77+
version: 11
78+
- uses: actions/setup-node@v4
79+
with:
80+
node-version: 26
81+
cache: pnpm
82+
- run: pnpm install --frozen-lockfile
83+
- name: Install Playwright browsers
84+
run: pnpm exec playwright install --with-deps chromium
85+
- name: E2E (chromium)
86+
run: pnpm exec playwright test --project=chromium

‎AGENTS.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,21 @@ git log --oneline -3
102102
## Architecture decisions
103103
- **ADR-0001** — native engine renders by **IR-replay** (not pixel-push). Validated empirically on Wayland: 86 fps vs 8.5 fps. Rust computes scene, emits compact IR (~42 KB/frame for 600 shapes); webview replays to canvas2D/WebGPU.
104104
- **ADR-0002** — teal accent (#39d0c6), 12-step neutral+teal ramps, Light/Dark/High-Contrast themes.
105+
- **ADR-0003** — `@strata/compositor` backend router: Canvas2D default, WebGPU opt-in with fallback. Linux Tauri (WebKitGTK) stays Canvas2D until WebGPU ships.
106+
- **ADR-0004** — `strata-bridge` + `strata-wasm` for shared IPC/WASM IR; `createEngine('wasm')` loads `/wasm/strata_wasm_bg.wasm`.
107+
- **ADR-0005** — Offline-first ONNX: bundled `/models/` manifest, remote download explicit only.
108+
109+
## WebGPU + WASM program (2026-07-06)
110+
111+
| Area | Location |
112+
|---|---|
113+
| Baseline bench + goldens | `packages/engine/src/bench/`, `packages/engine/src/__goldens__/` |
114+
| IPC parity | `crates/strata-bridge/`, Tauri `convert_engine_nodes` |
115+
| Compositor | `packages/compositor/` — Canvas2D + WebGPU scaffold |
116+
| Render worker | `packages/editor/src/render/` — OffscreenCanvas + docVersion stale guard |
117+
| WASM build | `just wasm-build` → `apps/desktop/public/wasm/` |
118+
| Offline models | `apps/desktop/public/models/manifest.json` |
119+
| Architecture docs | `docs/architecture/render-pipeline.md`, `docs/architecture/wasm-backends.md`, `docs/perf/ledger.md` |
105120

106121
## Quality gates (Cascade Review, §7) — every task must pass
107122
TDD-first → tests green → token audit → zero emoji → axe-core zero violations

‎Cargo.lock‎

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ members = [
1111
"crates/strata-trace",
1212
"crates/strata-print",
1313
"crates/strata-bgremove",
14+
"crates/strata-bridge",
15+
"crates/strata-wasm",
1416
]
1517

1618
[workspace.package]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"version": 1,
3+
"models": [
4+
{
5+
"id": "u2netp",
6+
"filename": "u2netp.onnx",
7+
"localPath": "/models/u2netp.onnx",
8+
"sha256": null,
9+
"bundled": true,
10+
"remoteUrl": "https://github.com/danielgatis/rembg/releases/download/v0.0.0/u2netp.onnx"
11+
},
12+
{
13+
"id": "birefnet-general-lite",
14+
"filename": "birefnet-general-lite.onnx",
15+
"localPath": "/models/birefnet-general-lite.onnx",
16+
"sha256": null,
17+
"bundled": false,
18+
"remoteUrl": "https://github.com/ZhengPeng7/BiRefNet/releases/download/v1.0/birefnet-general-lite.onnx"
19+
}
20+
]
21+
}

‎apps/desktop/src-tauri/Cargo.lock‎

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎apps/desktop/src-tauri/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ strata-engine = { path = "../../../crates/strata-engine" }
2727
notify = "6"
2828
strata-sync = { path = "../../../crates/strata-sync" }
2929
strata-print = { path = "../../../crates/strata-print" }
30+
strata-bridge = { path = "../../../crates/strata-bridge" }
3031
strata-bgremove = { path = "../../../crates/strata-bgremove" }
3132
image = "0.25"
3233
tauri-plugin-fs = "2"

‎apps/desktop/src-tauri/src/lib.rs‎

Lines changed: 38 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -2,143 +2,18 @@ mod renderer;
22

33
use notify::Watcher;
44
use serde::{Deserialize, Serialize};
5-
use strata_core::{Circle, Line, Point, Rect, Shape};
5+
use strata_core::Point;
66
use tauri::ipc::Response;
77
use tauri::Emitter;
88
use tauri::Manager;
99
use image::load_from_memory;
1010

11-
use crate::renderer::{generate_ir, generate_pixels, ShapeIr};
12-
13-
#[derive(Debug, Deserialize)]
14-
#[serde(tag = "kind")]
15-
enum IpcShape {
16-
#[serde(rename = "rect")]
17-
Rect { x: f64, y: f64, w: f64, h: f64 },
18-
#[serde(rename = "ellipse")]
19-
Ellipse { cx: f64, cy: f64, rx: f64, ry: f64 },
20-
#[serde(rename = "circle")]
21-
Circle { cx: f64, cy: f64, r: f64 },
22-
#[serde(rename = "line")]
23-
Line { from: [f64; 2], to: [f64; 2], tolerance: f64 },
24-
#[serde(rename = "polygon")]
25-
Polygon { cx: f64, cy: f64, radius: f64, sides: u32, rotation: f64 },
26-
#[serde(rename = "star")]
27-
Star { cx: f64, cy: f64, #[serde(rename = "innerRadius")] inner_radius: f64, #[serde(rename = "outerRadius")] outer_radius: f64, points: u32, rotation: f64 },
28-
#[serde(rename = "text")]
29-
Text {
30-
text: String,
31-
#[serde(rename = "fontSize")]
32-
font_size: f64,
33-
#[serde(rename = "fontFamily")]
34-
font_family: String,
35-
#[serde(rename = "fontWeight")]
36-
font_weight: u16,
37-
#[serde(rename = "fontStyle")]
38-
font_style: String,
39-
#[serde(rename = "textAlign")]
40-
text_align: String,
41-
x: f64,
42-
y: f64,
43-
w: f64,
44-
h: f64,
45-
#[serde(default, rename = "letterSpacing")]
46-
letter_spacing: Option<f64>,
47-
#[serde(default, rename = "lineHeight")]
48-
line_height: Option<f64>,
49-
#[serde(default, rename = "textCase")]
50-
text_case: Option<String>,
51-
#[serde(default, rename = "textDecoration")]
52-
text_decoration: Option<String>,
53-
#[serde(default, rename = "openTypeFeatures")]
54-
open_type_features: Option<serde_json::Value>,
55-
#[serde(default, rename = "variableAxes")]
56-
variable_axes: Option<serde_json::Value>,
57-
},
58-
}
59-
60-
impl IpcShape {
61-
fn into_shape(self) -> Shape {
62-
match self {
63-
IpcShape::Rect { x, y, w, h } => Shape::Rect(Rect::new(x, y, x + w, y + h)),
64-
IpcShape::Ellipse { cx, cy, rx, ry } => Shape::Ellipse { center: Point::new(cx, cy), rx, ry },
65-
IpcShape::Circle { cx, cy, r } => Shape::Circle(Circle::new(Point::new(cx, cy), r)),
66-
IpcShape::Line { from, to, tolerance } => Shape::Line { line: Line::new(Point::new(from[0], from[1]), Point::new(to[0], to[1])), tolerance },
67-
IpcShape::Polygon { cx, cy, radius, sides, rotation } => Shape::Polygon { cx, cy, radius, sides, rotation },
68-
IpcShape::Star { inner_radius, outer_radius, cx, cy, points, rotation } => Shape::Star { cx, cy, inner_radius, outer_radius, points, rotation },
69-
IpcShape::Text { text, font_size, font_family, font_weight, font_style, text_align, x, y, w, h, letter_spacing, line_height, text_case, text_decoration, open_type_features, variable_axes } => Shape::Text {
70-
text,
71-
font_size,
72-
font_family,
73-
font_weight,
74-
font_style,
75-
text_align,
76-
x,
77-
y,
78-
w,
79-
h,
80-
letter_spacing,
81-
line_height,
82-
text_case,
83-
text_decoration,
84-
open_type_features,
85-
variable_axes,
86-
},
87-
}
88-
}
89-
}
90-
91-
#[derive(Debug, Deserialize)]
92-
struct IpcSceneNode {
93-
#[allow(dead_code)]
94-
id: String,
95-
name: String,
96-
#[serde(with = "affine_serde")]
97-
transform: strata_core::Affine,
98-
shape: IpcShape,
99-
fill: [u8; 4],
100-
#[serde(default = "default_opacity")]
101-
opacity: f64,
102-
#[serde(default = "default_blend")]
103-
blend_mode: String,
104-
#[serde(default)]
105-
rotation: f64,
106-
#[serde(default)]
107-
strokes: Vec<strata_core::Stroke>,
108-
#[serde(default)]
109-
effects: Vec<strata_core::Effect>,
110-
}
111-
112-
fn default_opacity() -> f64 { 1.0 }
113-
fn default_blend() -> String { "normal".into() }
11+
use strata_bridge::{convert_engine_nodes, IpcSceneNode};
11412

115-
mod affine_serde {
116-
use serde::{Deserialize, Deserializer};
117-
use strata_core::Affine;
118-
pub fn deserialize<'de, D>(d: D) -> Result<Affine, D::Error> where D: Deserializer<'de> {
119-
let coeffs: [f64; 6] = Deserialize::deserialize(d)?;
120-
Ok(Affine::new(coeffs))
121-
}
122-
}
13+
use crate::renderer::{generate_ir, generate_pixels, ShapeIr};
12314

12415
fn convert_scene(nodes: Vec<IpcSceneNode>) -> Vec<strata_core::SceneNode> {
125-
nodes.into_iter().enumerate().map(|(i, n)| strata_core::SceneNode {
126-
id: strata_core::NodeId(i as u64),
127-
name: n.name,
128-
transform: n.transform,
129-
shape: n.shape.into_shape(),
130-
fill: n.fill,
131-
children: Vec::new(),
132-
component_id: None,
133-
slots: None,
134-
opacity: n.opacity,
135-
blend_mode: n.blend_mode,
136-
rotation: n.rotation,
137-
strokes: n.strokes,
138-
effects: n.effects,
139-
corner_radius: None,
140-
fills: None,
141-
}).collect()
16+
convert_engine_nodes(nodes)
14217
}
14318

14419
#[tauri::command]
@@ -985,6 +860,40 @@ mod tests {
985860
}
986861
}
987862

863+
#[test]
864+
fn ipc_parity_fills_filters_corner_radius() {
865+
let json = serde_json::json!([{
866+
"id": "n0",
867+
"name": "Rounded",
868+
"transform": [1.0, 0.0, 0.0, 1.0, 0.0, 0.0],
869+
"shape": { "kind": "rect", "x": 0.0, "y": 0.0, "w": 20.0, "h": 20.0, "cornerRadius": 8 },
870+
"fill": { "space": "rgb", "r": 57, "g": 208, "b": 198, "a": 255 },
871+
"fills": [{
872+
"type": "solid",
873+
"color": [57, 208, 198, 255],
874+
"opacity": 1.0,
875+
"blendMode": "normal",
876+
"visible": true
877+
}],
878+
"filters": [{ "type": "exposure", "exposure": 0.5 }]
879+
}]);
880+
let nodes: Vec<IpcSceneNode> = serde_json::from_value(json).expect("deserialize");
881+
let scene = convert_scene(nodes);
882+
assert!(scene[0].fills.is_some());
883+
assert!(scene[0].filters.is_some());
884+
assert!(scene[0].corner_radius.is_some());
885+
assert_eq!(scene[0].fill, [57, 208, 198, 255]);
886+
887+
let ir = strata_engine::build_render_ir(&scene);
888+
assert!(ir[0].fills.is_some());
889+
assert!(ir[0].filters.is_some());
890+
if let strata_engine::Primitive::Rect { corner_radius, .. } = &ir[0].primitive {
891+
assert!(corner_radius.is_some());
892+
} else {
893+
panic!("expected rect");
894+
}
895+
}
896+
988897
#[test]
989898
fn round_trip_hit_test() {
990899
let json = ts_wire_json();

‎crates/strata-bridge/Cargo.toml‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "strata-bridge"
3+
description = "TS wire-format to strata-core SceneNode conversion (Tauri IPC + WASM)."
4+
version.workspace = true
5+
edition.workspace = true
6+
rust-version.workspace = true
7+
license.workspace = true
8+
9+
[dependencies]
10+
strata-core = { path = "../strata-core" }
11+
serde = { version = "1", features = ["derive"] }
12+
serde_json = "1"
13+
14+
[lints]
15+
workspace = true

0 commit comments

Comments
 (0)