Check canvas size each frame and reconfigure the WebGPU surface
when it changes. Fixes black screen when toggling dev tools or
resizing the browser window.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Same per-pixel coverage adjustment as the GL demo. Replaces
unused debug uniform with stem_darkening in the uniform buffer.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adjust coverage at small sizes to compensate for gamma washing
out thin stems. Dark-on-light gets pow(cov, 0.7) to fatten,
light-on-dark gets pow(cov, 1.4) to thin. Smoothly transitions
to no effect above 48ppem. Applied before gamma correction so
it works with sRGB, gamma 2.2, and none.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Self-contained HTML with embedded font and text, same controls
as GPU demos (pan, zoom, 3D rotation, drag-release animation).
Useful for comparing DOM text rendering performance vs GPU.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Self-contained HTML with embedded font (base64) and default text.
Same controls as GPU demos. Useful for comparing rendering
performance: DOM vs WebGL vs WebGPU.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Show helpful error with link to webglreport.com when WebGL2
context creation fails (e.g. Firefox with hardware acceleration
disabled or GPU blocklisted).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Map DOM button 1 (middle) to GLFW middle button so middle-click
reset and middle-drag zoom work.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The WGSL shader compilation fails with _hb_gpu_curve_counts.
Debug mode is available in desktop and WebGL demos.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Refactor library fragment shaders (GLSL, MSL, WGSL) to extract
_hb_gpu_decode_glyph and _hb_gpu_curve_counts helpers, used by
both hb_gpu_render and the debug visualization.
Debug mode (d key) shows per-pixel curve counts as a heatmap:
R = horizontal band curves, G = vertical band curves, B = text
coverage. Scale 0-8 curves maps to 0-1 intensity.
Also auto-generates demo shader headers via meson, and adds
set_debug to the renderer interface.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Three-finger drag on mobile now does trackball rotation, matching
right-drag on desktop. Uses centroid of three touch points.
Release with momentum triggers spin animation.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Don't call demo_view_motion_func in on_mouseup — it zeros dx/dy
(same position as last mousemove), killing the velocity needed
for drag-release spin detection. Also remove debug printfs.
Track active_buttons to filter spurious document-level mouseup
events from UI controls while still catching drag releases
outside the canvas.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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>
- Show helpful error with browser support link when WebGPU is
unavailable (JS-level check before WASM loads)
- Suggest Linux Chrome flags for Vulkan/WebGPU
- Prevent onRuntimeInitialized from hiding the error message
- Set page title to WebGL/WebGPU variant
- Make adapter failure in C++ also show HTML error
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Display browser support link and Linux Chrome flags when
adapter or device creation fails.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Default to light mode matching GL demo
- Gamma cycles between 2.2 and none (no sRGB framebuffer)
- Gamma depends on dark_mode (1/2.2 for dark, 2.2 for light)
- Add console logging for key presses
- Blur backend dropdown after selection to prevent space capture
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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>
Replace demo_glstate_t with demo_renderer_t interface, use
demo_renderer_create_gl(), and add demo-renderer-gl.cc to
the web build.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add a "text" button that opens a modal textarea with the current
text. Apply sends new text to WASM, flushing the glyph cache and
atlas. Custom text is preserved across font changes.
Also adds demo_font_clear_cache() and demo_atlas_clear() for
flushing state without full destroy/recreate.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Don't call demo_view_display from main() — let the main loop
handle the first frame. The premature call could render before
the browser's canvas was ready, and since it cleared needs_redraw,
no subsequent frame was drawn until user interaction.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add a font button and drag-and-drop support to the web demo.
When a user provides their own .ttf/.otf font, the glyph cache
and atlas are flushed and the display is rebuilt with English-only
text (since the font may not support Persian).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Generate default-text-combined.hh with 35 lines of English +
35 lines of Persian for the web demo, matching the desktop
demo's adaptive line count.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Check the font's GSUB table for Latin and Arabic script support.
Build default demo text from English (Lorem Ipsum) and Persian
paragraphs for supported scripts, cropped to 35 lines each.
Source paragraphs live in perf/texts/{en,fa}-paragraph.txt.
gen-default-texts.py wraps them at fixed width and generates
the .hh headers.
Web demo hardcodes both texts since the embedded font supports
both scripts.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Reduces wasm size from 933K to 687K via size optimization
and link-time dead code elimination.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Merge the .c and .h files into single .hh headers with
static inline functions. Eliminates the C/C++ linkage issue
and simplifies the web demo build to a single em++ call.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Make scroll zoom proportional to delta (pow(STEP, yoffset))
instead of fixed steps. Add JS pinch-to-zoom handler that
translates two-finger touch to wheel events with a dead zone
to prevent jitter.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Web build using Emscripten + WebGL2 with HB_GPU_ATLAS_2D mode.
Touch support: drag to pan, tap to toggle animation.
FPS counter overlay. Viewport meta for mobile.
Fix cursor position on first touch by querying glfwGetCursorPos
in mouse_func. Left click/tap also toggles animation.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>