Commit Graph
167 Commits
Author SHA1 Message Date
Behdad Esfahbod f587af3ec3 [gpu] Extract shared shader helpers into hb_gpu_shader_source() (#5921)
The draw-renderer fragment shaders defined utilities
(HB_GPU_UNITS_PER_EM, the hb_gpu_atlas uniform, hb_gpu_fetch) that
any future GPU renderer will also need.  The draw-renderer vertex
shader likewise contained only the generic hb_gpu_dilate helper.
If a paint renderer were added today and a caller linked both
fragment sources together, hb_gpu_fetch would be defined twice.

Move these shared helpers into a new family of sources and expose
them via a new public entry point:

  hb_gpu_shader_source (stage, lang);

The existing hb_gpu_draw_shader_source() now returns only the
draw-specific fragment code; it returns an empty string for the
vertex stage because all current vertex logic is shared.  Callers
concatenate the shared source first, then the draw-specific
source, then their own main():

  [#version, hb_gpu_shader_source (...), hb_gpu_draw_shader_source
  (...), main]

Additions:
 - src/hb-gpu-fragment.{glsl,msl,wgsl,hlsl} — shared fragment
 - src/hb-gpu-vertex.{glsl,msl,wgsl,hlsl}   — shared vertex,
   renamed from hb-gpu-draw-vertex.*
 - src/hb-gpu-shaders.cc — hb_gpu_shader_source() dispatcher

Removals:
 - src/hb-gpu-draw-vertex.{glsl,msl,wgsl,hlsl} — moved to common

Shared sources are Behdad-only copyright; the Eric Lengyel / Slug
attribution stays on the draw-specific fragment sources where the
Slug algorithm actually lives.

Updates: test/api/test-gpu.cc, the Metal/D3D11/WebGPU/GL demo
shaders, the hb-gpu SECTION documentation, meson.build,
CMakeLists.txt, gen-gpu-shader-artifacts.py decl_map,
harfbuzz-world.cc, and docs/harfbuzz-sections.txt.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 12:10:23 -06:00
Behdad Esfahbod a44eb976dc [gpu] Rename hb_gpu_draw_darken -> hb_gpu_stem_darken
The previous commit renamed hb_gpu_darken to hb_gpu_draw_darken
for symmetry with hb_gpu_draw (formerly hb_gpu_render).  But the
operation isn't draw-subsystem specific: it adjusts a coverage
value based on foreground brightness and ppem, which is just the
standard stem-darkening recipe.  Name it after what it does.

Paint doesn't need its own variant — it can call this same
function on any alpha/coverage channel it produces.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 02:59:37 -06:00
Behdad Esfahbod daddae08a3 [gpu] Rename fragment-shader entry points with "draw_" prefix
Rename the public fragment-shader entry points provided by the
hb_gpu_draw_t renderer:

  hb_gpu_render(...)   -> hb_gpu_draw(...)
  hb_gpu_darken(...)   -> hb_gpu_draw_darken(...)

Also rename the internal helper:

  _hb_gpu_render_single(...) -> _hb_gpu_draw_single(...)

A COLRv1 paint renderer is planned and will provide its own
fragment entry point (likely hb_gpu_paint returning a vec4); the
existing draw/coverage entry point gets a subsystem-qualified name
now so draw and paint can coexist.

Updates the .glsl/.msl/.wgsl/.hlsl sources, regenerated .hh
artifacts, the documentation block in hb-gpu.cc, and the util/gpu
demo shaders.  No behavior change.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 02:57:07 -06:00
Behdad Esfahbod eeec9bd9fa [gpu] Unify shader source getters; rename for draw/paint split
Replace the two separate getters

  hb_gpu_shader_fragment_source (lang)
  hb_gpu_shader_vertex_source   (lang)

with a single

  hb_gpu_draw_shader_source (stage, lang)

where stage is the new hb_gpu_shader_stage_t enum (VERTEX or
FRAGMENT).  Parameter order is stage-first because "the vertex
shader in GLSL" reads more naturally than the reverse, and stage
is the primary axis (it determines which shader object the source
is compiled into).

The `_draw_` in the new name makes room for the incoming
hb_gpu_paint_shader_source() once the COLRv1 encoder lands —
that family will have its own (likely different) shader sources
per stage and language.

Updated the four in-tree callers: test/api/test-gpu.cc, and the
GPU demos under util/gpu/.  ABI break on a 14.0-only API; the
gpu library is still young enough that this is acceptable.

Marked new API with XSince: REPLACEME.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 02:26:21 -06:00
Behdad Esfahbod 4650398a07 [gpu] encode() returns extents + auto-clears; drop get_extents() (#5910)
Bring hb_gpu_draw_encode into line with the rest of the render APIs:
auto-clear on success, and return the computed glyph extents to the
caller via a new out-parameter (nullable).

  HB_EXTERN hb_blob_t *
  hb_gpu_draw_encode (hb_gpu_draw_t      *draw,
                      hb_glyph_extents_t *extents);

Consumers typically need both the encoded blob and the glyph's
extents to size the quad they'll draw into in the vertex shader;
returning them together removes a redundant trip through the draw
state and lets encode() auto-clear like hb_vector_*_render() and
hb_raster_*_render() do.

Drop hb_gpu_draw_get_extents() from the public API — its only
role was reading extents out of the draw state post-encode, which
the new encode() signature makes redundant.  The computation
stays (moved to a static _hb_gpu_draw_get_extents helper) so
encode() can call it before auto-clear wipes the state.

ABI break for anyone who had already wired up against the 14.0.0
hb_gpu_draw_encode signature or hb_gpu_draw_get_extents, but the
library is new/experimental and the two in-tree consumers
(test/api/test-gpu.cc, util/gpu/demo-font.cc, util/hb-gpu-encode-all.cc,
test/fuzzing/hb-gpu-fuzzer.cc) are updated here.

All 240 tests pass.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 00:15:54 -06:00
Behdad Esfahbod 81a9830f30 [gpu] Make Escape exit fullscreen before quitting
When in fullscreen mode, pressing Escape now exits fullscreen
instead of closing the application. Pressing Escape again (or Q
at any time) still quits.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 18:05:00 -06:00
Behdad Esfahbod 0234df4db6 [gpu] Fix WebGPU error page not showing when adapter unavailable
Check navigator.gpu synchronously in main() before calling
the WebGPU C API.  Previously the error was reported in an
async callback that raced with onRuntimeInitialized, which
hid the loading div before the error message could appear.

Also re-show the loading div and set window._webgpuError in
the adapter callback as a fallback.

Assisted-by: Claude <noreply@anthropic.com>
2026-04-02 01:26:54 -06:00
Behdad Esfahbod e7c5b839eb [gpu] Store font scale in blob header; auto-MSAA in hb_gpu_render
Add hb_gpu_draw_set_scale() API and store x/y scale in the
glyph blob header (buf[1].b/a).  hb_gpu_draw_glyph() sets it
automatically from the font.

hb_gpu_render() now reads the scale, computes ppem via fwidth,
and automatically blends 4 corner samples at ±1/3 pixel when
ppem < 16 to reduce moiré at small sizes.  Define
HB_GPU_NO_MSAA to disable.

Add hb_gpu_ppem() public shader helper so clients can get
ppem without touching internal functions (e.g. for
hb_gpu_darken).

Remove hb_gpu_render_aaa(), u_upem uniform, and set_upem
plumbing from the demo — no longer needed.

GLSL only for now.

Assisted-by: Claude <noreply@anthropic.com>
2026-04-02 00:59:39 -06:00
Behdad Esfahbod a255d9745b [gpu] Rework MSAA into hb_gpu_render_aaa with caller-provided ppem
Replace the two-program MSAA toggle with hb_gpu_render_aaa()
that takes ppem from the caller and auto-selects single-sample
(ppem >= 16) or 4-corner MSAA (ppem < 16).  This keeps
hb_gpu_render() lean for the fast path while letting the
adaptive function handle small sizes.

The previous approach had the ppem calculation inside the
library shader using 1/fwidth(texcoord), which was wrong by
a factor of upem — MSAA fired at all sizes.  Now the demo
passes correct ppem via a u_upem uniform.

Remove the 'm' key toggle, two-program compilation, and
set_msaa plumbing — no longer needed.

GLSL only for now.

Assisted-by: Claude <noreply@anthropic.com>
2026-04-02 00:40:49 -06:00
Behdad Esfahbod 39d3b83b47 [gpu] Add GLFW_KEY_M to web GL stub for MSAA toggle
Assisted-by: Claude <noreply@anthropic.com>
2026-04-02 00:19:04 -06:00
Behdad Esfahbod 4f9048cd27 Revert "Revert small-size MSAA experiment"
This reverts commit 3c291a5015.
2026-04-02 00:18:05 -06:00
Behdad Esfahbod 5eb52c7407 [gpu] Fix display() signature in D3D11, Metal, and WebGPU renderers
Drop HB_UNUSED from the generation parameter — it's not
available in MinGW or Emscripten build contexts.

Assisted-by: Claude <noreply@anthropic.com>
2026-04-01 23:52:54 -06:00
Behdad Esfahbod 61db984844 [gpu] Pass buffer generation to renderer display
The previous commit added the generation parameter to the
display interface but missed passing it from demo_view_display.

Assisted-by: Claude <noreply@anthropic.com>
2026-04-01 23:29:15 -06:00
Behdad Esfahbod c86cb51bf6 [gpu] Fix garbled rendering after font change in web demo
The GL renderer cached the vertex buffer upload by comparing
the data pointer and count.  After clearing and refilling the
buffer with a new font's glyphs, std::vector reused the same
allocation, so the pointer and count matched — the upload was
skipped and the GPU drew with stale vertex data containing old
atlas offsets.

Fix by adding a generation counter to demo_buffer_t that
increments on clear().  The renderer compares generation and
count to decide whether to re-upload.

Assisted-by: Claude <noreply@anthropic.com>
2026-04-01 23:25:48 -06:00
Behdad Esfahbod 3c291a5015 Revert small-size MSAA experiment
Reverts dc19a8002 and 7ac851ab6.  The improvement was not
worth the complexity or performance cost.

Assisted-by: Claude <noreply@anthropic.com>
2026-04-01 23:09:36 -06:00
Behdad Esfahbod dc19a8002a [gpu] Add optional MSAA mode for small-size antialiasing
Add hb_gpu_render_msaa() that evaluates 9 samples (3x3 grid
at ±1/3 pixel) to reduce moiré at small sizes.  GLSL only.

The demo compiles two shader programs and toggles between them
with the 'm' key, so the MSAA program's register pressure
does not affect the fast single-sample path.

Assisted-by: Claude <noreply@anthropic.com>
2026-04-01 23:08:30 -06:00
Behdad Esfahbod 5d24cb5bf3 [gpu] Add --bench option for automated benchmarking
Implies --demo and --type '30=f ' (zoom 30x, fullscreen,
animate).  Quits automatically after 3 fps reports.

Uses a GOption parse callback so --demo is set early enough
for the default font/text machinery.

Assisted-by: Claude <noreply@anthropic.com>
2026-03-31 16:25:05 -06:00
Behdad Esfahbod 6c1bd94816 [gpu] Add --type / -T option to replay keystrokes on startup
Allows simulating keyboard input at launch, e.g. -T '30= f'
zooms 30x, toggles fullscreen and starts animation.

Assisted-by: Claude <noreply@anthropic.com>
2026-03-31 16:12:25 -06:00
Behdad EsfahbodandClaude Opus 4.6 94be1485ae [gpu] Use HB_TINY for web demo builds
HB_TINY = HB_LEAN + HB_MINI + HB_OPTIMIZE_SIZE_MORE.

WebGL: 635KB → 351KB (-45%)
WebGPU: 655KB → 371KB (-43%)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 22:35:10 -06:00
Behdad EsfahbodandClaude Opus 4.6 73616f9808 [gpu] Drop HB_NO_VAR override now that draw works without gvar
WebGL: 513KB → 478KB, WebGPU: 533KB → 498KB.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 22:23:49 -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
Behdad EsfahbodandClaude Opus 4.6 14effc302a [gpu] Add hb_gpu_darken() to all shader languages
Library function for stem darkening: pow(2, brightness-0.5)
scaled by ppem. Added to GLSL, MSL, WGSL, HLSL with consistent
brief docs. Demo shaders now call the library function.
Section docs in hb-gpu.cc updated with usage example.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 19:49:42 -06:00
Behdad EsfahbodandClaude Opus 4.6 f99f91a658 [gpu] Update Metal stem darkening to pow(2, brightness-0.5)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 19:26:51 -06:00
Behdad EsfahbodandClaude Opus 4.6 9e2828622c [gpu] Use pow(2, brightness-0.5) for stem darkening
Replace boolean light_on_dark with continuous brightness-driven
exponent. pow(2, b-0.5) gives sqrt(2)≈1.414 for white text
(thin) and 1/sqrt(2)≈0.707 for black text (fatten), perfectly
symmetric around 1.0 at 50% gray.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 19:25:31 -06:00
Behdad Esfahbod 9e0d8d48c4 Revert "Revert "[webgpu] Align touch handoff with WebGL fixes""
This restores commit 00a3475ce.

Testing:
- source /home/behdad/emsdk/emsdk_env.sh >/dev/null &&
  EM_CACHE=/tmp/emscripten-cache ./util/gpu/web/build.sh
- source /home/behdad/emsdk/emsdk_env.sh >/dev/null &&
  EM_CACHE=/tmp/emscripten-cache ./util/gpu/web/build-webgpu.sh

Assisted-by: OpenAI Codex
2026-03-30 18:40:40 -06:00
Behdad Esfahbod a7367b65e2 Revert "[webgpu] Align touch handoff with WebGL fixes"
This reverts commit 00a3475ce.

Testing:
- source /home/behdad/emsdk/emsdk_env.sh >/dev/null &&
  EM_CACHE=/tmp/emscripten-cache ./util/gpu/web/build.sh
- source /home/behdad/emsdk/emsdk_env.sh >/dev/null &&
  EM_CACHE=/tmp/emscripten-cache ./util/gpu/web/build-webgpu.sh

Assisted-by: OpenAI Codex
2026-03-30 18:39:20 -06:00
Behdad Esfahbod 00a3475ce0 [webgpu] Align touch handoff with WebGL fixes
The WebGPU touch path was still using the older gesture state machine.
It handled 3->2 reseeding, but it did not track whether a pinch was
active and it had no explicit 2->1 single-finger pan handoff.

Carry over the proven transition rules from the WebGL path without
changing desktop input handling: track pinch-active and synthetic
single-pan state, preserve the 3->2 reseed, and continue pan after a
pinch when one finger remains. touchcancel now also clears those touch
states consistently.

Testing:
- source /home/behdad/emsdk/emsdk_env.sh >/dev/null &&
  EM_CACHE=/tmp/emscripten-cache ./util/gpu/web/build.sh
- source /home/behdad/emsdk/emsdk_env.sh >/dev/null &&
  EM_CACHE=/tmp/emscripten-cache ./util/gpu/web/build-webgpu.sh

Assisted-by: OpenAI Codex
2026-03-30 18:36:54 -06:00
Behdad Esfahbod 2c15cb9123 [web] Continue pan after pinch handoff
The previous fix stopped the 2->1 jump by swallowing the pinch-ending
touchend and seeding a synthetic left-button press at the remaining
finger. But subsequent one-finger motion was still left to the browser,
which does not reliably resume mouse emulation mid-gesture.

Track an explicit single-finger pan mode after the pinch handoff, route
its touchmove events to synthetic mousemove, and end it with a
gesture-cancelled synthetic mouseup on lift or touchcancel.

Testing:
- source /home/behdad/emsdk/emsdk_env.sh >/dev/null &&
  EM_CACHE=/tmp/emscripten-cache ./util/gpu/web/build.sh
- source /home/behdad/emsdk/emsdk_env.sh >/dev/null &&
  EM_CACHE=/tmp/emscripten-cache ./util/gpu/web/build-webgpu.sh

Assisted-by: OpenAI Codex
2026-03-30 18:25:42 -06:00
Behdad Esfahbod 7c3c313bbc [web] Fix pinch to single-finger handoff
The WebGL touch path only tracked the initial 3->2 reseed with
skipNextPinchMove. Once a real pinch was underway, the later 2->1
transition stopped being treated as a gesture handoff and fell back
into the browser/GLFW single-touch path.

Track pinch-active state explicitly, swallow the pinch-ending touchend,
and hand single-finger pan off from the remaining touch by syncing the
cursor before synthesizing mousedown. This keeps the 3->2->1 sequence
from jumping the view when the second finger lifts.

Testing:
- source /home/behdad/emsdk/emsdk_env.sh >/dev/null &&
  EM_CACHE=/tmp/emscripten-cache ./util/gpu/web/build.sh
- source /home/behdad/emsdk/emsdk_env.sh >/dev/null &&
  EM_CACHE=/tmp/emscripten-cache ./util/gpu/web/build-webgpu.sh

Assisted-by: OpenAI Codex
2026-03-30 18:22:03 -06:00
Behdad Esfahbod 4ebb454061 Revert "[gpu] Sync cursor position on 2→1 touch transition"
This reverts commit d44b0958fa.
2026-03-30 18:18:15 -06:00
Behdad EsfahbodandClaude Opus 4.6 d44b0958fa [gpu] Sync cursor position on 2→1 touch transition
Dispatch mousemove before mousedown when transitioning from
pinch to single-finger pan, so GLFW's cursor position matches
the remaining finger.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 18:17:34 -06:00
Behdad EsfahbodandKhaled Hosny 7af550edd4 Update util/gpu/meson.build
Co-authored-by: Khaled Hosny <khaled@aliftype.com>
2026-03-30 16:40:29 -06:00
Behdad EsfahbodandClaude Opus 4.6 a6396882b0 [gpu] Add gpu_demo option, disable on MSVC only
GPU library always builds (no deps). GPU demo controlled by
gpu_demo option (auto default). Only MSVC CI disables it
(GLEW wrap broken with -nodefaultlib). All other CIs install
GLEW/GLFW system packages.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 16:09:37 -06:00
Behdad EsfahbodandClaude Opus 4.6 f138460772 [gpu] Simplify GPU demo dep handling across CIs
Drop gpu_demo option. GLEW/GLFW use required:false — demo builds
when deps are found, skipped when not. Install GLEW/GLFW on all
CIs (Linux already had them, add to macOS and Rust). MinGW CI
uses wraps via --wrap-mode=default.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 16:02:04 -06:00
Behdad EsfahbodandClaude Opus 4.6 d30dc93503 [gpu] Add gpu_demo option, gate deps behind it
GPU library is always built (no deps). GPU demo (hb-gpu) requires
GLEW/GLFW/GL and is controlled by gpu_demo option (auto by default).
When disabled, deps aren't even looked up — fixes MSVC pulling in
broken GLEW wrap. MinGW CI explicitly enables with -Dgpu_demo=enabled.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 15:55:06 -06:00
Behdad EsfahbodandClaude Opus 4.6 9b3a62ca84 [gpu] Integrate D3D11 renderer into main hb-gpu tool
Wire demo_renderer_create_d3d11 into gpu-output.hh with --direct3d
flag. Add to meson build conditionally on Windows with d3d11 and
d3dcompiler libraries. Remove standalone D3D11 demo (superseded).

hb-gpu.exe --demo --direct3d now works under Wine.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 15:19:28 -06:00
Behdad EsfahbodandClaude Opus 4.6 5aaef7d43a [gpu] Fix M_PI for MinGW cross-compilation
Add _USE_MATH_DEFINES before <cmath> includes on Windows.
hb-gpu.exe now cross-compiles successfully with MinGW.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 15:13:37 -06:00
Behdad EsfahbodandClaude Opus 4.6 67c8529825 [gpu] Add D3D11 renderer for the main hb-gpu tool (Windows)
Implements demo_renderer_t using D3D11, same pattern as Metal.
Uses GLFW for windowing (GLFW_NO_API + glfwGetWin32Window).
Compiled conditionally with #ifdef _WIN32.

Not yet wired into gpu-output.hh or build system — needs
GLFW and GLib for MinGW, which are available on Fedora.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 15:02:35 -06:00
Behdad Esfahbod f776a25657 Revert "[gpu] Add trail mode (p key)"
This reverts commit 17bdcac84f.
2026-03-30 13:48:32 -06:00
Behdad Esfahbod 32e6eea763 Revert "[gpu] Add exponential fade to trail mode"
This reverts commit fa576c3a6e.
2026-03-30 13:48:11 -06:00
Behdad EsfahbodandClaude Opus 4.6 fa576c3a6e [gpu] Add exponential fade to trail mode
Draw a semi-transparent fullscreen quad with the background color
each frame instead of clearing, so previous frames fade gradually.
Uses a tiny passthrough shader and attributeless triangle.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 13:45:44 -06:00
Behdad EsfahbodandClaude Opus 4.6 17bdcac84f [gpu] Add trail mode (p key)
Skip glClear when trail is on — previous frames stay visible,
creating a paint/stamp effect during animation and interaction.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 13:42:41 -06:00
Behdad EsfahbodandClaude Opus 4.6 1c242329dc [gpu] Double-click reset on both left and right buttons
Double-left-click and double-right-click both reset view.
Middle-click reset also still works. Updated help text.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 12:55:19 -06:00
Behdad EsfahbodandClaude Opus 4.6 bbc0b5b682 [gpu] Double-click to reset view
Second click within 300ms undoes the first click's animation
toggle and resets the view. Works across all backends.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 12:48:55 -06:00
Behdad EsfahbodandClaude Opus 4.6 453eb77634 [gpu] Fix pan after pinch: synthesize mousedown on 2→1 transition
GLFW doesn't see the remaining finger after a swallowed pinch,
so synthesize a mousedown to start drag tracking.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 12:42:59 -06:00
Behdad Esfahbod db6d2c27ec Revert "[web] Move tap recognition to touchend"
This reverts commit 7db69c0cd0.
2026-03-30 12:32:50 -06:00
Behdad Esfahbod 7db69c0cd0 [web] Move tap recognition to touchend
WebGL mobile currently commits a tap on touchstart, then the second
tap in a double-tap zoom has to undo that animation toggle. This
makes tap and double-tap drag compete and can start animation before
gesture intent is clear.

Track a pending single tap until touchend, suppress the synthetic
click toggle on release, and only fire the animation toggle after the
double-tap timeout expires. A second tap now cancels that pending
toggle and claims double-tap zoom directly.

Testing:
- source /home/behdad/emsdk/emsdk_env.sh >/dev/null &&
  EM_CACHE=/tmp/emscripten-cache ./util/gpu/web/build.sh
- source /home/behdad/emsdk/emsdk_env.sh >/dev/null &&
  EM_CACHE=/tmp/emscripten-cache ./util/gpu/web/build-webgpu.sh

Assisted-by: OpenAI Codex
2026-03-30 12:31:24 -06:00
Behdad Esfahbod 9ddc43a2b5 [gpu] Revert pinch jitter deadzone
The deadzone suppressed slow, deliberate pinch rotation too
aggressively. Restore the original pinch sensitivity.

Testing:
- EM_CACHE=/tmp/emscripten-cache ./util/gpu/web/build.sh
- EM_CACHE=/tmp/emscripten-cache ./util/gpu/web/build-webgpu.sh

Assisted-by: OpenAI Codex
2026-03-30 12:22:10 -06:00
Behdad Esfahbod a6d0fffaf4 [gpu] Ignore tiny pinch jitter
Clamp very small pinch scale and rotation deltas to neutral
before applying them. This reduces touch hardware noise without
changing the overall gesture model.

Testing:
- EM_CACHE=/tmp/emscripten-cache ./util/gpu/web/build.sh
- EM_CACHE=/tmp/emscripten-cache ./util/gpu/web/build-webgpu.sh

Assisted-by: OpenAI Codex
2026-03-30 12:17:58 -06:00
Behdad Esfahbod bef4c6a79e [web] Handle touchcancel in touch gestures
Track the last gesture centroid and explicitly handle touchcancel
for both web gesture paths. This clears active gesture state
without turning browser-driven cancellation into a tap, fling, or
stuck drag.

Testing:
- sh -n util/gpu/web/build.sh
- sh -n util/gpu/web/build-webgpu.sh
- EM_CACHE=/tmp/emscripten-cache ./util/gpu/web/build.sh
- EM_CACHE=/tmp/emscripten-cache ./util/gpu/web/build-webgpu.sh
  (blocked offline fetching emdawnwebgpu)

Assisted-by: OpenAI Codex
2026-03-30 12:14:59 -06:00