xbintsc 0.7.8 → 0.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/cli/help.d.ts +1 -1
- package/dist/src/cli/help.js +1 -1
- package/dist/src/codegen/generator/context.d.ts +4 -3
- package/dist/src/codegen/generator/context.js +6 -5
- package/dist/src/codegen/generator/context.js.map +1 -1
- package/dist/src/codegen/generator/expressions/assignment.js +3 -3
- package/dist/src/driver/config.d.ts +1 -1
- package/dist/src/driver/options.d.ts +1 -1
- package/dist/src/driver/version.d.ts +1 -1
- package/dist/src/driver/version.js +1 -1
- package/dist/src/extensions/gui/features.d.ts +14 -6
- package/dist/src/extensions/gui/features.js +34 -6
- package/dist/src/extensions/gui/features.js.map +1 -1
- package/dist/src/extensions/gui/index.js +3 -3
- package/dist/tests/codegen/llvm.test.js +1 -1
- package/dist/tests/e2e/gui-audio.test.js +24 -0
- package/dist/tests/e2e/gui-audio.test.js.map +1 -1
- package/dist/tests/e2e/gui-draw-perf.test.js +9 -0
- package/dist/tests/e2e/gui-draw-perf.test.js.map +1 -1
- package/dist/tests/e2e/gui-font-face.test.d.ts +3 -1
- package/dist/tests/e2e/gui-font-face.test.js +99 -7
- package/dist/tests/e2e/gui-font-face.test.js.map +1 -1
- package/dist/tests/e2e/gui-frame-pacing.test.d.ts +15 -0
- package/dist/tests/e2e/gui-frame-pacing.test.js +68 -0
- package/dist/tests/e2e/gui-frame-pacing.test.js.map +1 -0
- package/dist/tests/e2e/gui-initial-url.test.d.ts +10 -0
- package/dist/tests/e2e/gui-initial-url.test.js +49 -0
- package/dist/tests/e2e/gui-initial-url.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl-depth-range.test.d.ts +18 -0
- package/dist/tests/e2e/gui-webgl-depth-range.test.js +140 -0
- package/dist/tests/e2e/gui-webgl-depth-range.test.js.map +1 -0
- package/dist/tests/extensions/gui-features.test.js +27 -2
- package/dist/tests/extensions/gui-features.test.js.map +1 -1
- package/doc/ai/extensions.md +10 -4
- package/doc/ai/zh-CN/extensions.md +8 -3
- package/doc/gui/api.md +35 -2
- package/doc/gui/build.md +34 -15
- package/doc/gui/known-issues.md +1 -1
- package/doc/gui/rendering.md +45 -8
- package/doc/gui/runtime.md +13 -0
- package/doc/gui/webgl.md +11 -2
- package/doc/gui.md +9 -4
- package/doc/implemented/codegen.md +3 -2
- package/doc/zh-CN/gui/api.md +25 -2
- package/doc/zh-CN/gui/build.md +20 -7
- package/doc/zh-CN/gui/known-issues.md +1 -1
- package/doc/zh-CN/gui/rendering.md +33 -8
- package/doc/zh-CN/gui/runtime.md +9 -0
- package/doc/zh-CN/gui/webgl.md +3 -2
- package/doc/zh-CN/gui.md +10 -5
- package/doc/zh-CN/implemented/codegen.md +3 -2
- package/package.json +7 -7
- package/runtime/ext_gui/audio_graph_commands.cpp +127 -0
- package/runtime/ext_gui/audio_mixer.cpp +84 -163
- package/runtime/ext_gui/audio_mixer.h +59 -3
- package/runtime/ext_gui/audio_mixer_extra.cpp +8 -0
- package/runtime/ext_gui/audio_param_apply.cpp +160 -0
- package/runtime/ext_gui/browser.cpp +6 -19
- package/runtime/ext_gui/browser_location.cpp +78 -0
- package/runtime/ext_gui/css_sheet.cpp +4 -2
- package/runtime/ext_gui/document_animation.cpp +7 -0
- package/runtime/ext_gui/dom_api_computed_style.cpp +3 -2
- package/runtime/ext_gui/dom_api_webgl.cpp +31 -0
- package/runtime/ext_gui/dom_api_webgl_internal.h +4 -0
- package/runtime/ext_gui/dom_api_webgl_shader.cpp +19 -4
- package/runtime/ext_gui/dom_api_webgl_state.cpp +6 -3
- package/runtime/ext_gui/gui.cpp +100 -1
- package/runtime/ext_gui/gui_events.cpp +8 -2
- package/runtime/ext_gui/perf.cpp +18 -6
- package/runtime/ext_gui/perf.h +37 -0
- package/runtime/ext_gui/style.cpp +27 -10
- package/runtime/ext_gui/style.h +10 -1
- package/runtime/ext_gui/text.cpp +4 -0
- package/runtime/ext_gui/text_font_bytes.cpp +117 -0
- package/runtime/ext_gui/text_font_bytes.h +65 -0
- package/runtime/ext_gui/text_font_db.cpp +5 -0
- package/runtime/ext_gui/text_font_sfnt.cpp +71 -24
- package/runtime/ext_gui/text_font_sfnt.h +5 -2
- package/runtime/ext_gui/text_hb.cpp +34 -5
- package/runtime/ext_gui/text_stb.cpp +7 -30
- package/runtime/ext_gui/text_webfont.cpp +217 -0
- package/runtime/ext_gui/warnings.cpp +26 -0
- package/runtime/ext_gui/warnings.h +8 -0
- package/runtime/ext_gui/webfont_bridge.c +23 -0
- package/runtime/ext_gui/webgl.h +34 -39
- package/runtime/ext_gui/webgl_blit_color.cpp +5 -0
- package/runtime/ext_gui/webgl_buffer_objects.cpp +19 -5
- package/runtime/ext_gui/webgl_draw.cpp +72 -12
- package/runtime/ext_gui/webgl_draw_setup.cpp +8 -2
- package/runtime/ext_gui/webgl_draw_state.h +13 -2
- package/runtime/ext_gui/webgl_objects.h +4 -0
- package/runtime/ext_gui/webgl_program.h +64 -0
- package/runtime/ext_gui/webgl_state.cpp +7 -0
- package/runtime/ext_gui/webgl_uniform.cpp +78 -0
- package/runtime/ext_gui/window.cpp +6 -0
- package/runtime/rt_object.h +6 -0
- package/runtime/rt_profile.h +6 -0
- package/runtime/xt_containers/access.inc +2 -47
- package/runtime/xt_containers/ic_get.inc +70 -0
- package/runtime/xt_containers/method_cache.inc +24 -10
- package/runtime/xt_containers/objects.inc +12 -1
- package/runtime/xt_containers/shapes.inc +78 -0
- package/runtime/xt_containers.c +1 -0
- package/runtime/xt_profile.c +3 -0
- package/scripts/build-gui.ts +43 -49
- package/scripts/gui-engine-build.ts +58 -0
- package/scripts/gui-vendor-source.ts +53 -0
- package/scripts/gui-webfont-build.ts +138 -0
- package/src/cli/help.ts +1 -1
- package/src/codegen/generator/context.ts +6 -6
- package/src/codegen/generator/expressions/assignment.ts +3 -3
- package/src/driver/config.ts +1 -1
- package/src/driver/options.ts +1 -1
- package/src/driver/version.ts +1 -1
- package/src/extensions/gui/features.ts +34 -6
- package/src/extensions/gui/index.ts +3 -3
|
@@ -192,12 +192,17 @@ HTML/CSS/TS(导入的 `.html` 与内联 CSS 都属于 bundle),按程序自
|
|
|
192
192
|
- **`shaping`** —— HarfBuzz + FreeType 提供的完整 OpenType 整形(连字、复杂文种)
|
|
193
193
|
与 CFF/OTF/可变字体支持。非 ASCII 文本(或转义/实体码点)或作者的
|
|
194
194
|
`@font-face` 规则会自动选中;纯拉丁页面保持 stb_truetype 后端,两个库都不链接。
|
|
195
|
+
- **`webfonts`** —— 供作者 `@font-face` 的 `.woff`/`.woff2` 来源使用的 miniz +
|
|
196
|
+
Brotli + woff2 参考解码器。程序的 HTML/CSS 出现压缩字体时会自动选中;文件会
|
|
197
|
+
一次性解压成普通 sfnt,因此两个文本后端与该字体的元数据读取的是同一份字节。
|
|
198
|
+
字体是系统字体或 `.ttf`/`.otf` 文件的页面完全不会链接它。
|
|
195
199
|
- **`webgl`** —— WebGL context 与 DOM 绑定。由 WebGL 的 `getContext(...)` 或
|
|
196
200
|
`webgl` 字符串触发;它依赖 `gpu`,两者一起激活。不用 WebGL 的页面两者都不链接。
|
|
197
201
|
|
|
198
|
-
用 `--feature media,gpu,images,shaping,webgl`(或 `all`)覆盖扫描,用
|
|
199
|
-
强制不链接。`--verbose` 会打印选中的集合。只渲染
|
|
200
|
-
FFmpeg、glslang,也不链接图片解码器、
|
|
202
|
+
用 `--feature media,gpu,images,shaping,webfonts,webgl`(或 `all`)覆盖扫描,用
|
|
203
|
+
`--no-feature media` 强制不链接。`--verbose` 会打印选中的集合。只渲染
|
|
204
|
+
HTML/CSS/2D canvas 的程序既不链接 FFmpeg、glslang,也不链接图片解码器、
|
|
205
|
+
HarfBuzz/FreeType、Web 字体解压器或 WebGL context;用运行时数据拼 HTML/CSS 的
|
|
201
206
|
页面应传 `--feature all`,因为扫描看不到它。
|
|
202
207
|
自动检测到的特性归档缺失时构建打印 warning,能力在运行时降级(媒体元素触发
|
|
203
208
|
`error`);显式强制的特性则报错。
|
package/doc/gui/api.md
CHANGED
|
@@ -173,6 +173,27 @@ runs the same equal-power path (no HRIR data set is shipped). The two media
|
|
|
173
173
|
sources are valid nodes with no signal — the engine has no media-capture or
|
|
174
174
|
element-audio pipeline, so they are silent rather than absent.
|
|
175
175
|
|
|
176
|
+
Graph mutations (`connect`, `start`/`stop`, the effect setup calls) and every
|
|
177
|
+
`AudioParam` schedule are **queued** instead of taking the mixer's render lock.
|
|
178
|
+
The page appends a command to a FIFO and the audio thread applies the batch at
|
|
179
|
+
the next quantum boundary, with the mutex already held. A convolver send makes a
|
|
180
|
+
single 128-frame quantum take a few milliseconds, so taking that lock from the
|
|
181
|
+
page made a per-frame `gain.value = …` wait for the current quantum — on a
|
|
182
|
+
scene that schedules sound every frame that was the largest main-thread audio
|
|
183
|
+
cost. Ordering is preserved (one FIFO for parameter updates and graph changes);
|
|
184
|
+
`AudioContext.currentTime` is an atomic read, and `AudioParam.value` drains the
|
|
185
|
+
queue first so a getter observes a just-written value. A node the audio thread
|
|
186
|
+
has not inserted yet is a special case: writes to it are applied directly to the
|
|
187
|
+
pending node (which `AudioParam.value` reads), because on a host with no audio
|
|
188
|
+
device — a headless runner, or any program that builds its graph before the
|
|
189
|
+
first `start()` — nothing would ever drain the FIFO.
|
|
190
|
+
|
|
191
|
+
Two environment variables separate the audio costs while profiling:
|
|
192
|
+
`XT_GUI_AUDIO_SILENT=1` renders silence but keeps the clock and the locking
|
|
193
|
+
(isolates the mixer's DSP cost from the page's Web Audio calls), and
|
|
194
|
+
`XT_AUDIO_PROFILE=1` prints the audio thread's wall time, lock wait, render duty
|
|
195
|
+
and worst quantum at shutdown (`xt_audio: …` on stderr).
|
|
196
|
+
|
|
176
197
|
Every `AudioParam` has a live `value` plus `setValueAtTime` /
|
|
177
198
|
`linearRampToValueAtTime` / `exponentialRampToValueAtTime` / `setTargetAtTime` /
|
|
178
199
|
`cancelScheduledValues` / `cancelAndHoldAtTime`. The automation timeline is
|
|
@@ -279,13 +300,15 @@ program has done in total, which is how rendering cost is measured (see
|
|
|
279
300
|
|
|
280
301
|
| Field | Meaning |
|
|
281
302
|
| --- | --- |
|
|
282
|
-
| `frameMs`, `restyleMs`, `layoutMs`, `paintMs`, `uploadMs`, `drawMs` | phase timings of the last frame (milliseconds) |
|
|
303
|
+
| `frameMs`, `scriptMs`, `restyleMs`, `layoutMs`, `paintMs`, `uploadMs`, `drawMs` | phase timings of the last frame (milliseconds). `scriptMs` is the time inside `requestAnimationFrame` callbacks — the page's own AOT code plus the WebGL command recording it does — so `frameMs - scriptMs - restyleMs - paintMs - uploadMs - drawMs` is the loop's own overhead |
|
|
304
|
+
| `webglDrawMs`, `webglUniformMs` | WebGL draw recording and uniform uploads (both are part of `scriptMs`; recorded only while `XT_GUI_PERF` is set) |
|
|
283
305
|
| `frames`, `presents`, `exposes`, `deferred`, `skippedFrames`, `starvedFrames`, `transitionFrames` | frame loop activity: `presents` counts swapchain frames, `exposes` the presents the window system asked for with an expose/shown/restore event, `deferred` the presents a starved frame postponed, `skippedFrames` the frames nothing needed and `starvedFrames` the frames that asked to present and got no drawable target |
|
|
284
306
|
| `restyles`, `restyleNodes`, `rulesEvaluated`, `mediaEvaluated`, `layouts`, `layoutBoxes` | cascade and layout work |
|
|
285
307
|
| `textShapeCalls`, `textShapeHits`, `textCacheBytes`, `textCacheEntries` | shaping cache misses/hits and its occupancy |
|
|
286
308
|
| `paints`, `paintOps`, `drawRuns`, `drawCalls`, `uploadSubmits`, `vertices`, `syncNodes` | display-list, draw-call and upload work |
|
|
287
309
|
| `canvasDraws`, `canvasUploads`, `canvasUploadBytes` | Canvas 2D draw calls, texture uploads and the bytes copied (a partial redraw uploads only its dirty rectangle) |
|
|
288
310
|
| `webglDraws`, `webglPasses`, `webglPipelineMisses`, `webglBufferUploadBytes` | WebGL draw calls, render passes opened, pipelines created and buffer bytes copied |
|
|
311
|
+
| `webglSetupMisses`, `webglSamplerBinds`, `webglStateBinds` | prepared-draw cache misses, sampler-set binds and dynamic-state binds; a steady scene misses only on layouts it has not seen and binds samplers when the texture/uniform set actually changes |
|
|
289
312
|
|
|
290
313
|
Every field except the `*Ms` timings is cumulative, so subtract two snapshots to
|
|
291
314
|
get one frame. `restyleMs` covers the cascade **and** the layout pass it
|
|
@@ -296,7 +319,17 @@ at a time the window server chooses, and a deferred present replays work an
|
|
|
296
319
|
earlier frame built when no swapchain image was available (`starvedFrames` counts
|
|
297
320
|
those frames — a climbing value means the window is not being updated at all).
|
|
298
321
|
`XT_GUI_PERF=1` prints the same numbers on stderr (one line per frame;
|
|
299
|
-
`XT_GUI_PERF=<N>` averages over N frames)
|
|
322
|
+
`XT_GUI_PERF=<N>` averages over N frames), including `script=`, `gldraw=` and
|
|
323
|
+
`gluni=` for the page's own work.
|
|
324
|
+
|
|
325
|
+
Two environment variables shape how a program is driven. `XT_GUI_URL` supplies
|
|
326
|
+
the page's initial `location`: a bare `?query`, a `#hash`, or
|
|
327
|
+
`path?query#hash` (the origin stays `xbintsc://localhost`). A compiled program
|
|
328
|
+
has no address bar, so this is how a browser build's `?bench=1`, `?q=low` or
|
|
329
|
+
`#shot` entry points stay reachable. `XT_GUI_FRAME_MS` overrides the `run()`
|
|
330
|
+
frame period: unset follows the display refresh rate, a positive value fixes the
|
|
331
|
+
period and `0` restores the historical uncapped loop (for benchmarks and tests
|
|
332
|
+
that want the old timing).
|
|
300
333
|
|
|
301
334
|
They are used by `tests/e2e/gui-*.test.ts` to assert parsing, selector matching,
|
|
302
335
|
specificity, inheritance, `!important` and layout geometry. They will stay useful
|
package/doc/gui/build.md
CHANGED
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
- Sources live in `runtime/ext_gui/` (C/C++) plus vendored libs under `vendor/`
|
|
7
7
|
(gitignored; fetched on demand). `npm run vendor` fetches the pinned
|
|
8
8
|
stb/NanoSVG headers (and the miniz/SQLite sources the link features compile);
|
|
9
|
-
`npm run gui` fetches
|
|
10
|
-
|
|
9
|
+
`npm run gui` fetches the vendored sources it compiles (stb, NanoSVG, miniz,
|
|
10
|
+
plus Brotli and woff2 for `webfonts`).
|
|
11
|
+
Media decoding lives in `runtime/xt_media/` and is built separately.
|
|
11
12
|
- `npm run gui` (`scripts/build-gui.ts`) fetches a pinned SDL3 (`SDL3_TAG`,
|
|
12
13
|
default `release-3.2.10`), builds a static SDL3, fetches and builds static
|
|
13
14
|
**FreeType** (`FREETYPE_VERSION`, default `2.13.3`) and **HarfBuzz**
|
|
@@ -15,16 +16,21 @@
|
|
|
15
16
|
and fetches and builds static **glslang** (`GLSLANG_VERSION`, default
|
|
16
17
|
`16.6.0`) against the pinned SPIR-V headers (`SPIRV_HEADERS_VERSION`), and —
|
|
17
18
|
**on macOS only** — **SPIRV-Cross** (`SPIRV_CROSS_VERSION`, default
|
|
18
|
-
`vulkan-sdk-1.4.313.0`).
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
`vulkan-sdk-1.4.313.0`). It also fetches the **Brotli** sources
|
|
20
|
+
(`BROTLI_VERSION`, default `1.1.0`) and the **woff2** reference decoder
|
|
21
|
+
(`WOFF2_VERSION`, default `1.0.2`) and compiles both — plus miniz's inflater —
|
|
22
|
+
into the archive for the optional `webfonts` feature. glslang is the runtime
|
|
23
|
+
GLSL ES compiler behind WebGL and SPIRV-Cross turns its SPIR-V into MSL for
|
|
24
|
+
the Metal backend (see [WebGL](./webgl.md)); both are merged into the archive
|
|
25
|
+
like the other libraries. Metal is the only SDL_GPU backend that consumes MSL,
|
|
26
|
+
so on Windows/Linux the script neither fetches nor merges SPIRV-Cross:
|
|
23
27
|
`webgl_msl.cpp` compiles to nothing there and the ~2.5 MiB it contributes
|
|
24
28
|
would be unreachable. The default text path uses the bundled
|
|
25
29
|
**stb_truetype** (`vendor/stb/stb_truetype.h`); HarfBuzz + FreeType are
|
|
26
|
-
only extracted when the `shaping` feature is active
|
|
27
|
-
|
|
30
|
+
only extracted when the `shaping` feature is active, and miniz/Brotli/woff2
|
|
31
|
+
only when `webfonts` is.
|
|
32
|
+
Every library (SDL3, FreeType, HarfBuzz, glslang, SPIRV-Cross, Brotli, woff2
|
|
33
|
+
and the engine)
|
|
28
34
|
is compiled with `-ffunction-sections -fdata-sections`, and SDL is configured
|
|
29
35
|
without the subsystems the engine never calls (`SDL_JOYSTICK`, `SDL_HAPTIC`,
|
|
30
36
|
`SDL_SENSOR`, `SDL_CAMERA`, `SDL_RENDER`, `SDL_OPENGL`/`SDL_OPENGLES`,
|
|
@@ -57,11 +63,14 @@
|
|
|
57
63
|
- `src/extensions/gui/index.ts` exposes the engine archive through
|
|
58
64
|
`nativeObjects()` (via `findRuntimeLibrary`, so `.a`/`.lib` both work) and the
|
|
59
65
|
OS frameworks through `linkerFlags()`. Its `linkFeatures()` (in
|
|
60
|
-
`src/extensions/gui/features.ts`) declares `media`, `gpu`, `images`, `shaping
|
|
61
|
-
compiles their bridges only when a feature
|
|
66
|
+
`src/extensions/gui/features.ts`) declares `media`, `gpu`, `images`, `shaping`,
|
|
67
|
+
`webfonts` and `webgl`; the driver compiles their bridges only when a feature
|
|
68
|
+
is active.
|
|
62
69
|
- glslang (and SPIRV-Cross on macOS) is merged into `gui.a` like SDL3, but the
|
|
63
70
|
engine reaches it only through the `gpu` feature's dispatch table. A program
|
|
64
|
-
that never compiles GLSL does not extract those archive members.
|
|
71
|
+
that never compiles GLSL does not extract those archive members. The same
|
|
72
|
+
holds for the miniz/Brotli/woff2 objects: they answer only the `webfonts`
|
|
73
|
+
decoder table.
|
|
65
74
|
- `scripts/build-gui.ts` compiles with the *same* clang the driver resolves
|
|
66
75
|
(`src/driver/toolchain-provider.ts`); on Windows that is the MSVC-targeting
|
|
67
76
|
LLVM bundled with Visual Studio, and its sibling `clang++`/`llvm-ar` are used
|
|
@@ -129,8 +138,8 @@
|
|
|
129
138
|
|
|
130
139
|
## Link features
|
|
131
140
|
|
|
132
|
-
`gui` is the only user-facing extension, but
|
|
133
|
-
features** selected per program:
|
|
141
|
+
`gui` is the only user-facing extension, but several heavy halves are **optional
|
|
142
|
+
link features** selected per program:
|
|
134
143
|
|
|
135
144
|
| Feature | What it links | Selected when the program may use it |
|
|
136
145
|
| --- | --- | --- |
|
|
@@ -138,6 +147,7 @@ features** selected per program:
|
|
|
138
147
|
| `gpu` | `gpu_bridge.c` (the implementation is already in `gui.a`) | a `getContext("webgl"/"webgl2"/"experimental-webgl")` (or a kind decided at run time), any `webgl` string, `mix-blend-mode`/`mixBlendMode`, or runtime-built markup |
|
|
139
148
|
| `images` | `image_bridge.c` (the implementation is already in `gui.a`) | `<img>`, inline `<svg>`, `background-image`/`url(...)`, a `.svg` path, `drawImage`/`createImageBitmap`/`Image`, or runtime-built markup |
|
|
140
149
|
| `shaping` | `text_bridge.c` (the implementation is already in `gui.a`) | non-ASCII text (CJK/Cyrillic/Greek/…), an escaped/entity codepoint, an author `@font-face` rule (custom fonts may be CFF/OTF), or runtime-built markup |
|
|
150
|
+
| `webfonts` | `webfont_bridge.c` (the implementation is already in `gui.a`) | a `.woff`/`.woff2` source in the program's HTML/CSS, or runtime-built markup |
|
|
141
151
|
| `webgl` | `webgl_bridge.c` (the implementation is already in `gui.a`; requires `gpu`) | a WebGL `getContext(...)`, a `webgl` string, or runtime-built markup |
|
|
142
152
|
|
|
143
153
|
The driver scans the bundled AST (`src/driver/usage.ts`): every string literal
|
|
@@ -165,6 +175,11 @@ build** and links it before `gui.a`:
|
|
|
165
175
|
`TextApi` via `text_hb.cpp`, which references HarfBuzz and FreeType. Without
|
|
166
176
|
it the engine uses the built-in stb_truetype backend, so a Latin-only page
|
|
167
177
|
links neither library.
|
|
178
|
+
- `webfonts` → `runtime/ext_gui/webfont_bridge.c`; its constructor installs the
|
|
179
|
+
WOFF/WOFF2 decoder via `text_webfont.cpp`, which references miniz's inflater,
|
|
180
|
+
Brotli and the woff2 reference decoder. Without it the font loader returns
|
|
181
|
+
only plain sfnt files, so a page that names `.ttf`/`.otf` faces links none of
|
|
182
|
+
the three and a compressed source is skipped with a warning.
|
|
168
183
|
- `webgl` → `runtime/ext_gui/webgl_bridge.c`; its constructor installs
|
|
169
184
|
`XtWebglApi` via `webgl_feature.cpp`, which references the WebGL context and
|
|
170
185
|
DOM bindings. The core reaches `getContext`, the canvas width/height setters,
|
|
@@ -176,7 +191,7 @@ no bridge, the engine's table stays null and the implementation members are neve
|
|
|
176
191
|
extracted. That is why the large libraries can stay in the existing archives
|
|
177
192
|
without a new package layout.
|
|
178
193
|
|
|
179
|
-
Overrides: `--feature media,gpu,images,shaping,webgl` (or `all`) forces a
|
|
194
|
+
Overrides: `--feature media,gpu,images,shaping,webfonts,webgl` (or `all`) forces a
|
|
180
195
|
feature on; `--no-feature media` keeps it out even when detection finds a use.
|
|
181
196
|
`webgl` requires `gpu`, and the resolver activates both together. An app icon
|
|
182
197
|
forces `images` because the icon is decoded through the same pipeline. `--ext media`
|
|
@@ -203,6 +218,10 @@ relative ranking is the same.
|
|
|
203
218
|
|
|
204
219
|
WebGL and images/SVG are link features (roughly 0.4 MiB of WebGL context/DOM
|
|
205
220
|
code and 0.23 MiB of stb_image/NanoSVG that a DOM-only page does not link).
|
|
221
|
+
WOFF/WOFF2 decompression is one too (roughly 0.45 MiB: Brotli's decoder and its
|
|
222
|
+
~120 KiB static dictionary, the woff2 table reconstruction, and miniz's
|
|
223
|
+
inflater). A page whose fonts are system or `.ttf`/`.otf` files never links it,
|
|
224
|
+
while a `.woff2` source adds that much to the binary.
|
|
206
225
|
Canvas2D, Web Audio and the `mix-blend-mode` compositor are not gated yet; a
|
|
207
226
|
program that uses none of them still pays for their API surface (roughly
|
|
208
227
|
0.1–0.2 MiB each).
|
package/doc/gui/known-issues.md
CHANGED
|
@@ -181,7 +181,7 @@
|
|
|
181
181
|
rendered as colour. This is the price of the ~3 MiB DOM-only binary; the
|
|
182
182
|
optional `shaping` feature restores HarfBuzz + FreeType (and full
|
|
183
183
|
complex-script shaping).
|
|
184
|
-
- **Link-feature detection is static.** `media`/`gpu`/`images`/`shaping`/`webgl` are selected from the
|
|
184
|
+
- **Link-feature detection is static.** `media`/`gpu`/`images`/`shaping`/`webfonts`/`webgl` are selected from the
|
|
185
185
|
bundled HTML/CSS/TS (including imported `.html` and the CSS inlined from it).
|
|
186
186
|
A page that builds markup or CSS from runtime data (`fetch`, `readFileSync`,
|
|
187
187
|
a value returned by a function) cannot be seen; the scanner falls back to
|
package/doc/gui/rendering.md
CHANGED
|
@@ -200,8 +200,10 @@ backend table. The default backend is the bundled **stb_truetype**
|
|
|
200
200
|
(`text_stb.cpp`, `vendor/stb/stb_truetype.h`). The optional **`shaping`**
|
|
201
201
|
link feature installs `text_hb.cpp`, a HarfBuzz + FreeType backend, and is
|
|
202
202
|
selected automatically for non-ASCII text or an author `@font-face` rule. Both
|
|
203
|
-
backends share the font database in `text_font_db.cpp` (discovery and indexing)
|
|
204
|
-
|
|
203
|
+
backends share the font database in `text_font_db.cpp` (discovery and indexing),
|
|
204
|
+
the CSS matcher in `text_fonts.cpp`, the font-bytes cache in
|
|
205
|
+
`text_font_bytes.cpp` (which decompresses WOFF/WOFF2 through the optional
|
|
206
|
+
**`webfonts`** link feature) and the sfnt metadata reader in
|
|
205
207
|
`text_font_sfnt.cpp`, so a CSS style resolves to the same real face whichever
|
|
206
208
|
shaper is linked.
|
|
207
209
|
|
|
@@ -214,16 +216,28 @@ shaper is linked.
|
|
|
214
216
|
family without an italic face uses its upright face — there is no synthetic
|
|
215
217
|
bold or oblique. Faces are cached per `(file, collection index, size)`.
|
|
216
218
|
`XT_GUI_FONT` / `XT_GUI_FONT_MONO` still override the generic defaults.
|
|
217
|
-
- Author **`@font-face`** rules load local
|
|
218
|
-
|
|
219
|
+
- Author **`@font-face`** rules load local font files in every container the
|
|
220
|
+
engine understands: sfnt faces (`.ttf`, `.ttc`, `.otf`, `.otc`) directly, and
|
|
221
|
+
the compressed webfont formats (`.woff`, `.woff2`) through the optional
|
|
222
|
+
**`webfonts`** link feature, which decompresses the file to a plain sfnt
|
|
223
|
+
before either backend — or the metadata reader — sees it. The feature is
|
|
224
|
+
selected automatically when the program's HTML/CSS names a `.woff`/`.woff2`
|
|
225
|
+
source (or the markup is runtime-built); `--no-feature webfonts` keeps it out,
|
|
226
|
+
and a compressed source is then skipped with a warning instead of silently
|
|
227
|
+
falling through. Both the metadata read and the glyph load use the same
|
|
228
|
+
decoded bytes, so a WOFF2 face has exactly the metrics of its `.ttf` original.
|
|
229
|
+
The `src` list is tried from left to right; `local(...)`, remote and
|
|
219
230
|
`data:` entries are skipped. A relative URL is a local `file:` path resolved
|
|
220
231
|
against the process working directory — the same policy as image sources — and
|
|
221
232
|
`file://` URLs (including percent-encoded paths) are accepted. The
|
|
222
233
|
`font-weight`/`font-style` descriptors select the face; a weight range
|
|
223
234
|
(`font-weight: 100 900`) is honoured, and later rules with the same family and
|
|
224
235
|
descriptors replace earlier ones. CSS matches the declared family name even
|
|
225
|
-
when it differs from the font file's internal name.
|
|
226
|
-
|
|
236
|
+
when it differs from the font file's internal name. The `format(...)` hint is
|
|
237
|
+
advisory: the container is detected from the file's signature, so a mislabelled
|
|
238
|
+
source still loads when its bytes are a format the engine can decode. When no
|
|
239
|
+
source is readable the family simply falls through to the next family in the
|
|
240
|
+
CSS list.
|
|
227
241
|
- The default candidates prefer a **CJK-capable TrueType/TTC** face (Microsoft
|
|
228
242
|
YaHei on Windows, PingFang/STHeiti on macOS, Noto Sans CJK/WenQuanYi on Linux)
|
|
229
243
|
before the Latin-only ones. A family's weight/style variants are resolved
|
|
@@ -268,8 +282,11 @@ lays it out, rebuilds the display list and uploads vertex arrays; a frame that
|
|
|
268
282
|
changes nothing does no CPU or GPU work. A document with thousands of elements
|
|
269
283
|
is kept interactive by budgeting each stage, and every stage is measured. Set
|
|
270
284
|
`XT_GUI_PERF=1` to print one line per frame (or `XT_GUI_PERF=<N>` for an
|
|
271
|
-
aggregated line every N frames);
|
|
272
|
-
|
|
285
|
+
aggregated line every N frames); the line separates the page's own callback time
|
|
286
|
+
(`script`), the WebGL recording inside it (`gldraw`, `gluni`) and the retained
|
|
287
|
+
pipeline stages, and includes `setupMiss`/`samplerBinds`/`stateBinds` for the
|
|
288
|
+
WebGL draw path. `win.stats()` returns the same counters, which is what
|
|
289
|
+
`tests/e2e/gui-perf.test.ts` asserts on.
|
|
273
290
|
|
|
274
291
|
- **Cascade.** An `@media` prelude is evaluated **once per rule** per restyle
|
|
275
292
|
(it used to be parsed once per rule *and* node, which was the largest cost on
|
|
@@ -277,6 +294,17 @@ is what `tests/e2e/gui-perf.test.ts` asserts on.
|
|
|
277
294
|
content entirely, the declaration candidate list is reused across the
|
|
278
295
|
depth-first walk instead of allocated per element, and `:hover`/`:focus` only
|
|
279
296
|
restyle when the sheet actually has such a rule.
|
|
297
|
+
- **Computed style allocation.** `computeNode` writes into the style map entry
|
|
298
|
+
in place instead of building a local style and copy-assigning it, and a style
|
|
299
|
+
inherits the parent's custom-property map by **shared pointer** (copy-on-write
|
|
300
|
+
only when the node declares its own `--x`). A token-heavy `:root` block
|
|
301
|
+
therefore no longer costs one deep property-map copy per element per restyle.
|
|
302
|
+
- **One display update per frame.** When the document is already dirty,
|
|
303
|
+
`advance()` only moves the clock: the pending `restyle()` is about to call
|
|
304
|
+
`updateDisplay()` with the same time, so the old path rebuilt the displayed
|
|
305
|
+
style map (and the layout) twice on every dirty frame of an animating page —
|
|
306
|
+
the normal case for a HUD that rewrites a transform every frame while a
|
|
307
|
+
transition runs.
|
|
280
308
|
- **Text.** Layout and paint share a bounded shaping cache (`text_cache.cpp`):
|
|
281
309
|
`(face, text) -> glyphs + advance`. It uses two generations of up to 2 MiB of
|
|
282
310
|
glyphs / 8,192 entries; when a generation is full the *spare* one is dropped
|
|
@@ -333,6 +361,15 @@ is what `tests/e2e/gui-perf.test.ts` asserts on.
|
|
|
333
361
|
upload per frame, no steady-state pipeline creation, only the dirty bytes), so
|
|
334
362
|
the wall-clock numbers stay informational and a software GPU in CI is not
|
|
335
363
|
penalised.
|
|
364
|
+
- **WebGL draw path.** A prepared draw is keyed by the bound VAO's identity and
|
|
365
|
+
its own revision, so binding the same geometry on a later frame keeps the
|
|
366
|
+
cached pipeline/layout (the key used to include the context-wide counter that
|
|
367
|
+
every VAO bind bumps, which rebuilt every prepared draw once per frame).
|
|
368
|
+
Viewport, scissor, blend constants and the sampler set are only re-recorded
|
|
369
|
+
when they actually change in the current pass, and a `Float32Array` uniform is
|
|
370
|
+
copied as raw bytes instead of being expanded into a `double` vector one
|
|
371
|
+
runtime call per element. `setupMiss`/`samplerBinds`/`stateBinds` in the perf
|
|
372
|
+
line report what is left.
|
|
336
373
|
|
|
337
374
|
Known limits: a mutation still restyles and relayouts the **whole** document
|
|
338
375
|
(there is no incremental subtree invalidation), and a paint-only change (for
|
package/doc/gui/runtime.md
CHANGED
|
@@ -39,6 +39,19 @@ swapchain image was available) is counted as `deferred`, and
|
|
|
39
39
|
prints what each frame did (see
|
|
40
40
|
[Performance](./rendering.md#performance-m20)).
|
|
41
41
|
|
|
42
|
+
`run()` also paces the loop to the display refresh rate (the mode of the
|
|
43
|
+
window's display; 60 Hz when the backend cannot report one). Before starting the
|
|
44
|
+
next frame it blocks on an `SDL_WaitEventTimeout` slice, dispatching events and
|
|
45
|
+
servicing the runtime's timers/microtasks while it waits, instead of draining
|
|
46
|
+
the `requestAnimationFrame` queue on every idle loop iteration — the old loop
|
|
47
|
+
ran a page's logic, WebGL recording and DOM updates hundreds of times per
|
|
48
|
+
second and asked the GPU for frames the compositor never showed. A frame that
|
|
49
|
+
overruns its slot starts the next one immediately (the deadline is clamped to
|
|
50
|
+
now, so a page slower than the display still runs as fast as it can).
|
|
51
|
+
`XT_GUI_FRAME_MS` overrides the period: unset follows the refresh rate, a
|
|
52
|
+
positive value fixes it and `0` restores the historical uncapped loop (tests and
|
|
53
|
+
benchmarks that want the old timing).
|
|
54
|
+
|
|
42
55
|
The `xt_loop_set_main` hook remains available for hosts that want to own the
|
|
43
56
|
loop themselves.
|
|
44
57
|
|
package/doc/gui/webgl.md
CHANGED
|
@@ -284,7 +284,7 @@ available from GLSL ES 3.00, which is what the instanced example uses.
|
|
|
284
284
|
clears only the scissor rectangle, for colour, depth and stencil), `blendColor`,
|
|
285
285
|
`blendFunc`/`blendFuncSeparate`,
|
|
286
286
|
`blendEquation`/`blendEquationSeparate`, `depthFunc`,
|
|
287
|
-
`depthMask`, `colorMask`, `stencilFunc`/`stencilFuncSeparate`,
|
|
287
|
+
`depthMask`, `depthRange`, `colorMask`, `stencilFunc`/`stencilFuncSeparate`,
|
|
288
288
|
`stencilOp`/`stencilOpSeparate`, `stencilMask`/`stencilMaskSeparate`,
|
|
289
289
|
`cullFace`, `frontFace`, `viewport`, `scissor`,
|
|
290
290
|
`pixelStorei`, `finish`. The stencil test takes part in rasterisation and
|
|
@@ -344,7 +344,12 @@ buffer. A vertex shader can sample textures just like a fragment shader:
|
|
|
344
344
|
`MAX_VERTEX_TEXTURE_IMAGE_UNITS` reports 16, vertex samplers live in set 0 and
|
|
345
345
|
are bound with `SDL_BindGPUVertexSamplers` on every draw. Depth values use the
|
|
346
346
|
backend's `[0, 1]` clip space rather than GL's `[-1, 1] → [0, 1]` remap:
|
|
347
|
-
`gl_Position.z = 0.5` stores depth `0.5` (real WebGL stores `0.75`).
|
|
347
|
+
`gl_Position.z = 0.5` stores depth `0.5` (real WebGL stores `0.75`). `depthRange`
|
|
348
|
+
narrows that space through the SDL_GPU viewport's depth bounds, which apply to
|
|
349
|
+
the depth test and the depth write alike: after rendering the world at the
|
|
350
|
+
default range, a first-person renderer draws its view model with
|
|
351
|
+
`depthRange(0, 0.05)` and it lands in the first 5% of the buffer, in front of
|
|
352
|
+
everything the world wrote.
|
|
348
353
|
|
|
349
354
|
## Not implemented
|
|
350
355
|
|
|
@@ -404,6 +409,10 @@ SPIRV-Cross, nor any `webgl_*` member (see [Link features](./build.md#link-featu
|
|
|
404
409
|
render target the page never depth-cleared, and `uniform1fv` with a plain
|
|
405
410
|
JavaScript array — the two WebGL behaviours three.js's `PMREMGenerator`
|
|
406
411
|
needs for a non-black environment map.
|
|
412
|
+
- `tests/e2e/gui-webgl-depth-range.test.ts` covers `depthRange`: the default
|
|
413
|
+
range leaves the depth order alone, a narrowed range pulls a farther fragment
|
|
414
|
+
in front, the range also rewrites the depth a fragment writes, and
|
|
415
|
+
`getParameter(DEPTH_RANGE)` reports the live values.
|
|
407
416
|
- `tests/e2e/gui-media.test.ts` also uploads the latest decoded `<video>` frame
|
|
408
417
|
as a texture and reads it back.
|
|
409
418
|
- `tests/e2e/gui-webgl2-3d.test.ts` covers 2D-array and 3D texture layer
|
package/doc/gui.md
CHANGED
|
@@ -142,18 +142,22 @@ with `nativeObjects()`, `linkerFlags()` and `modules()`.
|
|
|
142
142
|
| Window + input + multi-window | **SDL3** | cross-platform windows, HiDPI, IME, clipboard, DnD, close/hide events |
|
|
143
143
|
| GPU | **SDL_GPU** (SDL3) | one render path over Metal / Vulkan / D3D12; avoids three backends |
|
|
144
144
|
| Text shaping | **stb_truetype** simple shaper; optional **`shaping`** feature links HarfBuzz + FreeType | default keeps the DOM-only binary near 3 MiB; `shaping` restores ligatures and complex-script shaping |
|
|
145
|
+
| Webfont decoding | **miniz** + **Brotli** + the **woff2** reference decoder (vendored; optional **`webfonts`** feature) | `@font-face` sources in WOFF/WOFF2 decompress to sfnt once at load, so both text backends read the same bytes; plain-sfnt pages link none of it |
|
|
145
146
|
| Glyph raster | **stb_truetype**; FreeType only under `shaping` | TrueType outlines → grayscale atlas by default |
|
|
146
147
|
| Images | **stb_image** (vendored header) for bitmaps, **NanoSVG** (vendored headers) for SVG | single headers to start; SVG files rasterise on demand |
|
|
147
148
|
| Video + audio | **FFmpeg** (statically vendored, minimal build, optional `media` link feature) | decodes the common container/codec set; no WebView or platform media framework |
|
|
148
149
|
|
|
149
150
|
Pinned versions: SDL3 `release-3.2.10`, FreeType `2.13.3`, HarfBuzz `10.1.0`
|
|
150
151
|
(for the optional `shaping` feature), glslang `16.6.0`, SPIRV-Cross
|
|
151
|
-
`vulkan-sdk-1.4.313.0`,
|
|
152
|
+
`vulkan-sdk-1.4.313.0`, Brotli `1.1.0` and woff2 `1.0.2` (for the optional
|
|
153
|
+
`webfonts` feature), FFmpeg `7.1` for the optional `media` archive
|
|
152
154
|
(overridable with `SDL3_TAG` / `FREETYPE_VERSION` / `HARFBUZZ_VERSION` /
|
|
153
|
-
`GLSLANG_VERSION` / `SPIRV_CROSS_VERSION` / `
|
|
155
|
+
`GLSLANG_VERSION` / `SPIRV_CROSS_VERSION` / `BROTLI_VERSION` / `WOFF2_VERSION` /
|
|
156
|
+
`FFMPEG_VERSION`). The default text
|
|
154
157
|
backend is the bundled `vendor/stb/stb_truetype.h`; it accepts TrueType outlines (not
|
|
155
158
|
CFF/OTF or variable fonts). The `shaping` feature swaps in HarfBuzz + FreeType
|
|
156
|
-
for full OpenType shaping
|
|
159
|
+
for full OpenType shaping, and the `webfonts` feature decompresses author
|
|
160
|
+
`.woff`/`.woff2` sources before either backend reads them.
|
|
157
161
|
|
|
158
162
|
Alternative if SDL3 is rejected: **GLFW + OpenGL 3.3** (simpler, but OpenGL is
|
|
159
163
|
deprecated on macOS and gives no modern GPU abstraction). **wgpu-native** if the
|
|
@@ -186,7 +190,8 @@ engine were Rust.
|
|
|
186
190
|
(`measureText`/`fontMetrics`); the CSS family list, weight and italic style
|
|
187
191
|
select real installed faces, and author `@font-face` rules load local font
|
|
188
192
|
files (relative URLs resolve as `file:` paths against the process working
|
|
189
|
-
directory)
|
|
193
|
+
directory), including WOFF/WOFF2 sources through the `webfonts` link
|
|
194
|
+
feature. Originally HarfBuzz + FreeType, now the bundled stb_truetype.
|
|
190
195
|
- **M4b-2 — glyph rendering** ✅ stb_truetype rasterisation, a shared shelf-packed
|
|
191
196
|
glyph atlas, textured text quads in the display list and HiDPI-aware raster
|
|
192
197
|
scaling. Gradients remain.
|
|
@@ -6,8 +6,9 @@ Location: `src/codegen/llvm.ts`
|
|
|
6
6
|
|
|
7
7
|
- Emits LLVM IR text (`.ll`); no custom register allocation (relies on `alloca` + mem2reg).
|
|
8
8
|
- Statement / block boundary values live in `alloca`; conditionals and short-circuits materialize into temporary slots instead of `phi`.
|
|
9
|
-
- Property reads are inline-cached per source site: each access owns a zeroed `[
|
|
10
|
-
- Property **writes** get the same per-site cache: each `obj.name = value` owns a `[
|
|
9
|
+
- Property reads are inline-cached per source site: each access owns a zeroed `[8 x i64]` global (`@ic.N`) passed to `xt_get_ic`. The cache holds four `(shape, property index)` entries and is filled FIFO, because real call sites are polymorphic (a helper shared by several three.js classes, a generic layout routine): a single entry made most accesses at those sites miss and pay the full lookup. Ordinary objects carry an interned hidden-class shape (`xt_shape`, a `(parent, key)` transition tree) and a hit is a shape-pointer compare plus one key check instead of a linear property scan. Inserts/deletes and integer-key reordering rebuild or transition the shape, which invalidates stale caches; arrays, functions and containers fall back to `xt_get`.
|
|
10
|
+
- Property **writes** get the same per-site cache: each `obj.name = value` owns a `[8 x i64]` global (`@st.N`) passed to `xt_set_ic`. A hit compares the receiver's shape and the slot's key and writes the value field; a miss goes through `xt_set` (new property, delete, accessor, frozen object, host view, array, typed array) and refills the cache when the key ended up as an own data property. That removes the own-property scan, the inherited-setter walk and the typed-array kind probe from every hot store.
|
|
11
|
+
- A shape also carries a lazily built key → property-index table (`xt_shape_lookup`, created for layouts with at least eight keys and shared by every object with that layout), so a cache miss is an O(1) hash lookup instead of a scan of the property array. The shape chain order *is* the property order, which is what makes the index usable as the object's slot directly.
|
|
11
12
|
- `Math.<fn>(...)` with a fixed arity lowers to a direct runtime entry (`xt_math1_floor`, `xt_math2_imul`, `xt_math0_random`, …) instead of `xt_math_call(name, argc, argv)`: the name and arity are known at compile time, so the arguments are passed in registers and the runtime skips the name dispatch and the argument array. Any other shape (a spread argument, a wrong argument count, `min`/`max`, a first-class `Math` alias) keeps `xt_math_call`, which dispatches on the first byte of the name instead of a linear `strcmp` chain.
|
|
12
13
|
- Shape transitions are interned by the key's **text**, not by the address of the string that holds it: `xt_shape_transition` hashes the string bytes and compares keys by value. A key built at run time — a typed array's `byteLength`, a DOM handle's `length`, `obj["k" + i]` — is a fresh string with the same bytes, so pointer-keyed interning created a new shape on every insert; past the 16K limit each new object then had no shape at all, which silently disabled both inline caches for the rest of the program (a 1.4 MB bundled page interned 260 000+ transitions and spent about a minute in level setup). The table has 4096 buckets and interns up to 262 144 transitions; `XT_SHAPE_TRACE=1` reports the count as it grows, so a page that outgrows it is visible instead of merely slow.
|
|
13
14
|
- Element access `obj[key]` is inlined into the IR (`calls/element-inline.ts`) instead of being a runtime call. The emitted fast path guards the key to a canonical array index (integral, `0 .. 2^32-2` — `ta[1.5]` and `ta[-1]` stay ordinary property accesses), then loads the live `length`/`items` (or a typed-array view's `view_bytes`/kind) straight out of the container header and does the element load/store itself; strings, `Map`s, host views, out-of-range indices and the integer typed-array *stores* (which need `ToUintN`/`ToIntN` wrapping) branch to `xt_get_element` / `xt_set_element`, so semantics stay exactly the runtime's. The field offsets live in `layout.ts` and are checked against `runtime/rt_object.h` by `tests/codegen/element-layout.test.ts`. Without this, every element access was a call clang could not inline (no LTO), which cost geometry code ~50x a plain array on typed arrays.
|
package/doc/zh-CN/gui/api.md
CHANGED
|
@@ -153,6 +153,20 @@ requestAnimationFrame(frame);
|
|
|
153
153
|
`panningModel = "HRTF"` 会被接受但走同一条等功率路径(引擎不带 HRIR 数据集)。
|
|
154
154
|
两个媒体源是**合法的静音节点**——引擎没有采集或媒体元素音频管线,所以它们静音而不是缺失。
|
|
155
155
|
|
|
156
|
+
图变更(`connect`、`start`/`stop`、效果节点设置)以及所有 `AudioParam` 调度现在都改为
|
|
157
|
+
**排队**,不再直接获取 mixer 的渲染锁:页面把命令追加到 FIFO,音频线程在下一个量子边界
|
|
158
|
+
持锁批量应用。一次卷积混响会让单个 128 帧量子耗时数毫秒,因此页面若直接取锁,每帧的
|
|
159
|
+
`gain.value = …` 都要等当前量子渲染完——在每帧都调度声音的场景里,这是主线程音频开销的
|
|
160
|
+
最大来源。命令顺序保持不变(参数更新与图变更共用一个 FIFO);`AudioContext.currentTime`
|
|
161
|
+
是原子读取,`AudioParam.value` 读取前会先清空队列,因此 getter 能看到刚写入的值。
|
|
162
|
+
音频线程尚未插入的节点是例外:对它的参数写入直接作用于 pending 节点(`AudioParam.value`
|
|
163
|
+
正是读取这张表),因为在没有音频设备的宿主上——无头 CI,或在第一次 `start()` 之前就
|
|
164
|
+
建好图的程序——没有任何线程会去清空这个 FIFO。
|
|
165
|
+
|
|
166
|
+
性能分析时可用两个环境变量把音频开销拆开:`XT_GUI_AUDIO_SILENT=1` 渲染静音但保留时钟与
|
|
167
|
+
锁(用于区分 mixer 的 DSP 开销与页面的 Web Audio 调用),`XT_AUDIO_PROFILE=1` 在退出时
|
|
168
|
+
打印音频线程的墙钟时间、取锁等待、渲染占比与最坏量子(stderr 上的 `xt_audio: …`)。
|
|
169
|
+
|
|
156
170
|
每个 `AudioParam` 都有实时 `value`,以及 `setValueAtTime` / `linearRampToValueAtTime` /
|
|
157
171
|
`exponentialRampToValueAtTime` / `setTargetAtTime` / `cancelScheduledValues` /
|
|
158
172
|
`cancelAndHoldAtTime`。自动化时间线**逐采样**求值,因此页面空闲时斜坡仍会继续推进;
|
|
@@ -250,13 +264,15 @@ win.stats() // 引擎/运行时计数器(内存排
|
|
|
250
264
|
|
|
251
265
|
| 字段 | 含义 |
|
|
252
266
|
| --- | --- |
|
|
253
|
-
| `frameMs`、`restyleMs`、`layoutMs`、`paintMs`、`uploadMs`、`drawMs` |
|
|
267
|
+
| `frameMs`、`scriptMs`、`restyleMs`、`layoutMs`、`paintMs`、`uploadMs`、`drawMs` | 上一帧各阶段耗时(毫秒)。`scriptMs` 是 `requestAnimationFrame` 回调内部的时间——页面自身的 AOT 代码加上它执行的 WebGL 命令录制——因此 `frameMs - scriptMs - restyleMs - paintMs - uploadMs - drawMs` 是循环自身的开销 |
|
|
268
|
+
| `webglDrawMs`、`webglUniformMs` | WebGL 绘制录制与 uniform 上传耗时(都属于 `scriptMs`;仅在设置 `XT_GUI_PERF` 时记录) |
|
|
254
269
|
| `frames`、`presents`、`exposes`、`deferred`、`skippedFrames`、`starvedFrames`、`transitionFrames` | 帧循环活动:`presents` 是提交呈现的帧数,`exposes` 是窗口系统用 expose/shown/restore 事件要求的呈现帧数,`deferred` 是取不到可绘制目标而被推迟的呈现帧数,`skippedFrames` 是无需提交的帧数,`starvedFrames` 是要求呈现却拿不到可绘制目标的帧数 |
|
|
255
270
|
| `restyles`、`restyleNodes`、`rulesEvaluated`、`mediaEvaluated`、`layouts`、`layoutBoxes` | 层叠与布局的工作量 |
|
|
256
271
|
| `textShapeCalls`、`textShapeHits`、`textCacheBytes`、`textCacheEntries` | 整形缓存的未命中/命中与占用 |
|
|
257
272
|
| `paints`、`paintOps`、`drawRuns`、`drawCalls`、`uploadSubmits`、`vertices`、`syncNodes` | 显示列表、绘制调用与上传的工作量 |
|
|
258
273
|
| `canvasDraws`、`canvasUploads`、`canvasUploadBytes` | Canvas 2D 绘制次数、纹理上传次数与拷贝字节数(局部重绘只上传脏矩形) |
|
|
259
274
|
| `webglDraws`、`webglPasses`、`webglPipelineMisses`、`webglBufferUploadBytes` | WebGL 绘制次数、打开的渲染 pass 数、新建管线数与缓冲拷贝字节数 |
|
|
275
|
+
| `webglSetupMisses`、`webglSamplerBinds`、`webglStateBinds` | 预构建绘制缓存的未命中数、sampler 集合绑定次数与动态状态绑定次数;稳定场景只会在没见过的布局上未命中,并且只在纹理/uniform 集合真正变化时重绑 sampler |
|
|
260
276
|
|
|
261
277
|
除 `*Ms` 时间外,所有字段都是累计值,因此两次快照相减即得到一帧的工作量。
|
|
262
278
|
`restyleMs` 覆盖层叠**以及**它触发的布局过程(布局过程本身也单独报告为
|
|
@@ -265,7 +281,14 @@ expose/shown/restore 事件表示窗口内容已丢失、必须重绘,而具
|
|
|
265
281
|
决定;deferred 呈现则是重放某一帧在取不到交换链图像时已经构建好的内容,
|
|
266
282
|
`starvedFrames` 统计这些帧(该值持续增长说明窗口完全没有被更新)。
|
|
267
283
|
`XT_GUI_PERF=1` 会把同样的数字打印到 stderr(逐帧一行;`XT_GUI_PERF=<N>` 则每
|
|
268
|
-
N
|
|
284
|
+
N 帧取平均),其中也包含页面自身工作的 `script=`、`gldraw=` 与 `gluni=`。
|
|
285
|
+
|
|
286
|
+
两个环境变量决定程序的驱动方式。`XT_GUI_URL` 提供页面的初始 `location`:可以是
|
|
287
|
+
裸 `?query`、`#hash`,或 `path?query#hash`(origin 始终是
|
|
288
|
+
`xbintsc://localhost`)。编译后的程序没有地址栏,这是浏览器版本的
|
|
289
|
+
`?bench=1`、`?q=low`、`#shot` 等入口在原生版仍然可达的方式。`XT_GUI_FRAME_MS`
|
|
290
|
+
覆盖 `run()` 的帧周期:未设置时跟随显示器刷新率,正数固定周期,`0` 恢复历史上
|
|
291
|
+
不节流的循环(供基准与测试保留旧时序)。
|
|
269
292
|
|
|
270
293
|
它们被 `tests/e2e/gui-*.test.ts` 用来断言解析、选择器匹配、特异性、继承、
|
|
271
294
|
`!important` 与布局几何。它们在之后仍可用于调试。
|
package/doc/zh-CN/gui/build.md
CHANGED
|
@@ -6,22 +6,27 @@
|
|
|
6
6
|
|
|
7
7
|
- 源码位于 `runtime/ext_gui/`(C/C++),外加 `vendor/` 下的 vendored 库
|
|
8
8
|
(被 gitignore;按需获取)。`npm run vendor` 获取固定版本的 stb/NanoSVG 头文件
|
|
9
|
-
(以及链接特性要编译的 miniz/SQLite 源码);`npm run gui`
|
|
10
|
-
|
|
9
|
+
(以及链接特性要编译的 miniz/SQLite 源码);`npm run gui` 获取它要编译的
|
|
10
|
+
vendored 源码(stb、NanoSVG、miniz,以及 `webfonts` 用的 Brotli 与 woff2)。
|
|
11
|
+
媒体解码位于 `runtime/xt_media/`,单独构建。
|
|
11
12
|
- `npm run gui`(`scripts/build-gui.ts`)获取固定版本的 SDL3(`SDL3_TAG`,
|
|
12
13
|
默认 `release-3.2.10`),构建静态 SDL3,获取并构建静态 **FreeType**
|
|
13
14
|
(`FREETYPE_VERSION`,默认 `2.13.3`)与 **HarfBuzz**(`HARFBUZZ_VERSION`,
|
|
14
15
|
默认 `10.1.0`)供可选的 `shaping` 特性使用,并获取、构建静态
|
|
15
16
|
**glslang**(`GLSLANG_VERSION`,默认 `16.6.0`)、固定版本的 SPIR-V 头文件
|
|
16
17
|
(`SPIRV_HEADERS_VERSION`)以及——**仅 macOS**——**SPIRV-Cross**
|
|
17
|
-
(`SPIRV_CROSS_VERSION`,默认 `vulkan-sdk-1.4.313.0
|
|
18
|
+
(`SPIRV_CROSS_VERSION`,默认 `vulkan-sdk-1.4.313.0`)。它还会获取 **Brotli**
|
|
19
|
+
源码(`BROTLI_VERSION`,默认 `1.1.0`)和 **woff2** 参考解码器
|
|
20
|
+
(`WOFF2_VERSION`,默认 `1.0.2`),并把这两者加上 miniz 的 inflate 一起编译进
|
|
21
|
+
归档,供可选的 `webfonts` 特性使用。glslang 是 WebGL
|
|
18
22
|
背后的运行时 GLSL ES 编译器,SPIRV-Cross 把它的 SPIR-V 转成 Metal 后端使用的
|
|
19
23
|
MSL(见 [WebGL](./webgl.md)),两者都与其他库一样合并进归档。Metal 是唯一消费
|
|
20
24
|
MSL 的 SDL_GPU 后端,因此 Windows/Linux 上脚本既不获取也不合并 SPIRV-Cross:
|
|
21
25
|
那里的 `webgl_msl.cpp` 编译为空,合并进来只会多出约 2.5 MiB 不可达代码。
|
|
22
26
|
默认文本路径使用内置的 **stb_truetype**(`vendor/stb/stb_truetype.h`);
|
|
23
|
-
HarfBuzz/FreeType 只在 `shaping`
|
|
24
|
-
|
|
27
|
+
HarfBuzz/FreeType 只在 `shaping` 特性启用时被取出,miniz/Brotli/woff2 只在
|
|
28
|
+
`webfonts` 启用时被取出。
|
|
29
|
+
每个库(SDL3、FreeType、HarfBuzz、glslang、SPIRV-Cross、Brotli、woff2 与引擎)都用
|
|
25
30
|
`-ffunction-sections -fdata-sections` 编译;SDL 关闭引擎从不调用的子系统
|
|
26
31
|
(`SDL_JOYSTICK`、`SDL_HAPTIC`、`SDL_SENSOR`、`SDL_CAMERA`、`SDL_RENDER`、
|
|
27
32
|
`SDL_OPENGL`/`SDL_OPENGLES`、`SDL_OFFSCREEN`、`SDL_HIDAPI`);HarfBuzz 关闭
|
|
@@ -114,6 +119,7 @@
|
|
|
114
119
|
| `gpu` | `gpu_bridge.c`(实现本身已在 `gui.a`) | `getContext("webgl"/"webgl2"/"experimental-webgl")`(或运行时决定的 kind)、任意 `webgl` 字符串、`mix-blend-mode`/`mixBlendMode`,或运行时拼出的 HTML |
|
|
115
120
|
| `images` | `image_bridge.c`(实现本身已在 `gui.a`) | `<img>`、内联 `<svg>`、`background-image`/`url(...)`、`.svg` 路径、`drawImage`/`createImageBitmap`/`Image`,或运行时拼出的 HTML |
|
|
116
121
|
| `shaping` | `text_bridge.c`(实现本身已在 `gui.a`) | 非 ASCII 文本(CJK/西里尔/希腊文等)、转义或实体码点、作者的 `@font-face` 规则(自定义字体可能是 CFF/OTF),或运行时拼出的 HTML |
|
|
122
|
+
| `webfonts` | `webfont_bridge.c`(实现本身已在 `gui.a`) | 程序的 HTML/CSS 里的 `.woff`/`.woff2` 来源,或运行时拼出的 HTML |
|
|
117
123
|
| `webgl` | `webgl_bridge.c`(实现本身已在 `gui.a`,依赖 `gpu`) | WebGL 的 `getContext(...)`、`webgl` 字符串,或运行时拼出的 HTML |
|
|
118
124
|
|
|
119
125
|
driver 会扫描打包后的 AST(`src/driver/usage.ts`):所有字符串字面量(包括导入的
|
|
@@ -134,6 +140,10 @@ markup 会让程序按“动态 markup”保守处理,启用可选特性。
|
|
|
134
140
|
- `shaping` → `runtime/ext_gui/text_bridge.c`;构造函数通过 `text_hb.cpp` 安装
|
|
135
141
|
`TextApi`,其引用取出 HarfBuzz 与 FreeType。没有它时引擎使用内置 stb_truetype,
|
|
136
142
|
纯拉丁页面两个库都不链接。
|
|
143
|
+
- `webfonts` → `runtime/ext_gui/webfont_bridge.c`;构造函数通过 `text_webfont.cpp`
|
|
144
|
+
安装 WOFF/WOFF2 解码器,其引用取出 miniz 的 inflater、Brotli 与 woff2 参考
|
|
145
|
+
解码器。没有它时字体加载只接受普通 sfnt 文件,因此只用 `.ttf`/`.otf` 字面的
|
|
146
|
+
页面三个库都不链接,压缩来源会被跳过并打印 warning。
|
|
137
147
|
- `webgl` → `runtime/ext_gui/webgl_bridge.c`;构造函数通过 `webgl_feature.cpp` 安装
|
|
138
148
|
`XtWebglApi`,其引用取出 WebGL context 与 DOM 绑定。core 的 `getContext`、
|
|
139
149
|
canvas 宽高 setter、`createImageBitmap`、host type 与 renderer 都走这张表,因此
|
|
@@ -142,7 +152,7 @@ markup 会让程序按“动态 markup”保守处理,启用可选特性。
|
|
|
142
152
|
bridge 就是让链接器搜索归档的“强引用”;没有 bridge 时引擎的表保持 null,
|
|
143
153
|
实现成员永不被取出。因此大库可以留在现有归档里,不需要新的包布局。
|
|
144
154
|
|
|
145
|
-
覆盖方式:`--feature media,gpu,images,shaping,webgl`(或 `all`)强制开启;
|
|
155
|
+
覆盖方式:`--feature media,gpu,images,shaping,webfonts,webgl`(或 `all`)强制开启;
|
|
146
156
|
`--no-feature media` 即使检测到也不链接。`webgl` 依赖 `gpu`,resolver 会一起
|
|
147
157
|
激活;配置应用图标会强制 `images`,因为图标走同一条解码管线。`--ext media` 是
|
|
148
158
|
`--ext gui --feature media` 的弃用别名。
|
|
@@ -164,7 +174,10 @@ stb_truetype 而不是 HarfBuzz + FreeType。剩余重量主要是静态 CRT、l
|
|
|
164
174
|
`-dead_strip`),数字会有差异,但相对排序相同。
|
|
165
175
|
|
|
166
176
|
WebGL 与图片/SVG 是链接特性(约 0.4 MiB 的 WebGL context/DOM 代码与 0.23 MiB 的
|
|
167
|
-
stb_image/NanoSVG,DOM-only 页面不链接)。
|
|
177
|
+
stb_image/NanoSVG,DOM-only 页面不链接)。WOFF/WOFF2 解压也是(约 0.45 MiB:
|
|
178
|
+
Brotli 解码器及其约 120 KiB 静态字典、woff2 表重建代码与 miniz inflater)。字体是
|
|
179
|
+
系统字体或 `.ttf`/`.otf` 文件的页面完全不链接它,而使用 `.woff2` 来源的页面会
|
|
180
|
+
加上这些体积。Canvas2D、Web Audio 与
|
|
168
181
|
`mix-blend-mode` 合成器尚未按需化;不使用它们的程序仍要付出其 API 面积(每项大约
|
|
169
182
|
0.1–0.2 MiB)。
|
|
170
183
|
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
且只接受 TrueType 轮廓(不支持 CFF/OTF 或可变字体);彩色 emoji 也不会以彩色
|
|
136
136
|
渲染。这是 DOM-only 二进制约 3 MiB 的代价;可选的 `shaping` 特性会重新链接
|
|
137
137
|
HarfBuzz + FreeType,恢复完整整形。
|
|
138
|
-
- **链接特性检测是静态的。** `media`/`gpu`/`images`/`shaping`/`webgl` 从打包后的 HTML/CSS/TS(包括导入的
|
|
138
|
+
- **链接特性检测是静态的。** `media`/`gpu`/`images`/`shaping`/`webfonts`/`webgl` 从打包后的 HTML/CSS/TS(包括导入的
|
|
139
139
|
`.html` 与其内联 CSS)里选择。用运行时数据(`fetch`、`readFileSync`、函数返回值)
|
|
140
140
|
拼 HTML/CSS 的页面无法被看到;扫描器在能证明 sink 是动态时会保守地启用可选特性,
|
|
141
141
|
但对于它无法分类的不透明值,需要显式 `--feature media`/`gpu`/`images`/`shaping`/`webgl`(或 `all`)。
|