Commit Graph
7 Commits
Author SHA1 Message Date
Behdad Esfahbod 7f6d75cd9e [util/gpu/web] Export _web_set_palette in both build scripts
The previous palette commit added the C entry point and the
shell.html message handler but forgot to list _web_set_palette
in EXPORTED_FUNCTIONS, so emscripten dead-stripped it and the
'palette' postMessage was a silent no-op in the iframe.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 15:29:42 -06:00
Behdad EsfahbodandClaude Opus 4.6 d17ff1e8d6 [util/gpu/web] Live variations via postMessage
Add web_set_variations(const char *) to both the WebGL and
WebGPU hb-gpu-web wasm modules.  Parses a comma-separated
"wght=400,wdth=100" string via hb_variation_from_string,
applies via hb_font_set_variations on the current font, and
rebuilds the shaping buffer.  Cheap to call repeatedly --
suitable for live slider pushes once a slider UI lands.

Shell.html grows a matching applyVariations() helper and a
'variations' postMessage case.  config-override.h undefs
HB_NO_VAR so the new function actually links.  EXPORTED
_FUNCTIONS on both build scripts list _web_set_variations.

Also plumbed in a small cap (32 axes) on the stack so the
parser doesn't need hb's internal containers -- no font has
anywhere near that many.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 12:57:18 -06:00
Behdad EsfahbodandClaude Opus 4.6 e96cbf4a12 [gpu] Shrink web demo WASM with HB_LEAN
Add config.h with HB_LEAN and config-override.h to re-enable
draw, metrics, and variable font support. Strips color, paint,
math, bitmap, deprecated APIs, and other unused features.

WebGL: 635KB → 513KB (-19%)
WebGPU: 655KB → 533KB (-19%)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 22:18:06 -06:00
0bdd933a1e [gpu] Fix 3-finger to 2-finger touch transition
Properly handle finger count transitions with cooldown and
state reinitialization to prevent jumps in zoom/rotation.

Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 11:54:03 -06:00
fa50f16e51 [gpu] Fix black screen on resume with web_request_redraw
Add demo_view_request_redraw() and export as _web_request_redraw.
Shell calls it on visibilitychange, focus, pageshow, and
webglcontextrestored events to force a redraw after phone
lock/unlock or tab switch.

Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 11:17:42 -06:00
Behdad EsfahbodandClaude Opus 4.6 ca2fb1eb68 [gpu] Share demo_view between WebGL and WebGPU web demos
Refactor demo_view to work without GLFW (guarded by HB_GPU_NO_GLFW):
- Add demo_view_create_headless() for non-GLFW use
- Store fb/window dimensions in the view struct
- Use emscripten_get_now() for timing when on Emscripten
- Guard GLFW-specific calls (fullscreen, window close, cursor query)

Rewrite WebGPU entry point to use demo_view and demo_renderer_t
interface instead of duplicated view/input code. This gives the
WebGPU demo identical trackball rotation, drag-release animation,
keyboard shortcuts, and gamma cycling as the GL demos.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 15:36:19 -06:00
Behdad EsfahbodandClaude Opus 4.6 e51d769ce3 [gpu] Add WebGPU web demo
Add a WebGPU variant of the web demo using Emscripten's
emdawnwebgpu port. Uses the WGSL shaders from the library API,
a storage buffer for the atlas (i16→i32 expansion on upload),
and Emscripten HTML5 APIs for input (no GLFW).

Also moves demo_shader_add_glyph_vertices to demo-shader.h as
static inline so demo-buffer.cc can be compiled without GL.

Build: bash util/gpu/web/build-webgpu.sh → out/webgpu.html
The existing WebGL build continues to work unchanged.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 14:39:50 -06:00