WGSL transcription of the paint interpreter. Takes the atlas and
palette as explicit storage-buffer pointer parameters (matching
the WGSL draw helper's calling convention):
fn hb_gpu_paint (renderCoord: vec2f, glyphLoc: u32,
foreground: vec4f,
hb_gpu_atlas: ptr<storage, array<vec4<i32>>, read>,
hb_gpu_palette: ptr<storage, array<vec4f>, read>) -> vec4f
hb_gpu_paint_shader_source() now returns real content for
HB_GPU_SHADER_LANG_WGSL fragment; HLSL still stubs to "".
util/gpu/web/hb-gpu-web-webgpu.cc:
- Concats the paint source alongside the draw source into the
WGSL shader module.
- Declares @group(0) @binding(2) for hb_gpu_palette.
- Allocates a 256 * vec4f storage buffer (zero-filled for now;
real palette upload is TODO), binds it at entry index 2.
- Fragment main switches from hb_gpu_draw to hb_gpu_paint.
util/gpu/web/gl-stub.h: adds glUniform4fv stub (demo-font.cc now
calls it for the GL palette path) and makes
glGetUniformLocation return -1 so the WebGPU build's
demo_font_upload_palette short-circuits.
Wasm sizes:
WebGL index.wasm : 443628 181597 gz
WebGPU webgpu.wasm : 461110 188045 gz
Non-color text should render through WebGPU. COLRv0 color glyphs
come up transparent until the cross-backend palette upload lands.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
MSL transcription of the GLSL paint fragment interpreter. Same
per-pixel op-stream walk and LAYER_SOLID SRC_OVER composite; the
only surface difference is that MSL's hb_gpu_fetch /
hb_gpu_paint take the atlas and palette as explicit buffer
pointer parameters (matching MSL's lack of globally-scoped
device-address-space globals).
float4 hb_gpu_paint (float2 renderCoord, uint glyphLoc,
float4 foreground,
device const short4* hb_gpu_atlas,
constant float4* hb_gpu_palette);
hb_gpu_paint_shader_source() now returns a real string for
HB_GPU_SHADER_LANG_MSL fragment; vertex and WGSL/HLSL still stub
to "".
util/gpu/demo-metal.mm: concatenates the paint source alongside
the draw source into the Metal library, fragment_main switches
from hb_gpu_draw to hb_gpu_paint, and a 256-element palette
MTLBuffer is created + bound at fragment buffer index 2. The
palette buffer is zero-filled for now; real palette upload from
the font's active palette is a follow-up (the GL path in
demo-font.cc uses glUniform4fv, which is GL-specific; a cleaner
cross-backend upload will come with the general palette plumbing).
Non-color text (u_foreground path) should render correctly on
Metal. COLRv0 color glyphs will render transparent until the
palette upload lands -- ready for Mac smoke-testing.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
demo_vertex_glsl and demo_fragment_glsl were inline R"glsl(...)"
string literals in util/gpu/demo-shader.cc. Pull them into
dedicated util/gpu/demo-{vertex,fragment}.glsl source files with
their own copyright headers, and wire the existing
gen-gpu-shader-artifacts.py generator to stringize them into
demo-*-glsl.hh at build time.
Also simplifies gen-gpu-shader-artifacts.py: the decl_map had
grown to cover every shader and its entries were all trivial
filename-to-symbol derivations. Replace the map with direct
derivation (hyphens -> underscores, strip .hh), so adding more
shaders anywhere -- library or demo -- needs no generator edit.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Two paint-encoder bugs and two demo-plumbing bugs together
prevented end-to-end rendering. With all four fixed, BungeeTint
and similar COLRv0 fonts now render through the GL demo in their
proper palette colors.
### Paint encoder
1. hb-gpu-paint-fragment.glsl: the LAYER_SOLID op's payload is a
blob-relative texel offset, but the shader was passing it to
hb_gpu_draw() as-is -- which treats its argument as an absolute
atlas offset. Add the glyph's `base` to the payload before the
draw-coverage call so the sub-blob reference resolves inside
the paint blob instead of elsewhere in the atlas.
2. hb-gpu-paint.cc push_clip_glyph callback: was resetting
pending_palette_index to 0. But harfbuzz's COLRv0 paint
emitter calls custom_palette_color BEFORE push_clip_glyph for
each layer, so the index set by custom_palette_color was being
clobbered before the color callback consumed it -- every layer
ended up tagged palette_index=0. Leave pending_palette_index
alone in push_clip_glyph.
### Demo plumbing
3. util/gpu/demo-glstate.cc: demo_glstate_create now glUseProgram's
its program immediately. The palette uniform upload reads
GL_CURRENT_PROGRAM, and glyph upload happens from
demo_buffer_current_line() -- which runs before
demo_view_setup() would have bound the program. Without this,
glGetIntegerv returned 0 and the palette was never uploaded.
4. util/gpu/demo-font.cc: adds lazy demo_font_upload_palette() on
first glyph request. Also tries both "hb_gpu_palette" and
"hb_gpu_palette[0]" for the uniform lookup since drivers
disagree.
### Bonus
util/hb-gpu-encode-all.cc: reports paint-encoded and draw-fallback
counts / sizes / timings separately so you can tell where time
goes in mixed-content fonts.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
util/hb-gpu-encode-all.cc now exercises the paint encoder instead
of the draw encoder directly. Every glyph is routed through
hb_gpu_paint_glyph + hb_gpu_paint_encode; on NULL result (v1
features not yet handled, or fully empty paint tree) it falls
back to hb_gpu_draw_glyph + hb_gpu_draw_encode. Reports paint
encoded count separately from draw-fallback count.
hb_gpu_paint.cc: the color callback now checks the
hb_gpu_draw_glyph return value and skips the layer when the
clip-glyph has no outline, so fallback-synthesized LAYER_SOLIDs
for glyphs like U+0020 don't produce a 1-op blob that the shader
would sample as zero coverage anyway.
Sample run on BungeeTint-Regular.ttf (COLRv0, 2 layers/glyph):
glyphs: 2126
paint: 2126 (all routed through paint)
empty: 0
total: 8347.27 KiB
avg: 3.93 KiB/glyph
max: 10.84 KiB (gid 1005)
paint: 13.10ms (6.2us/glyph)
encode: 0.27ms (0.1us/glyph)
wall: 13.53ms (157185 glyphs/s)
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* hb_gpu_paint_glyph() switches from hb_font_paint_glyph_or_fail
to hb_font_paint_glyph so non-color glyphs also produce a blob
(harfbuzz synthesizes push_clip_glyph + color(is_foreground) +
pop_clip which our callbacks turn into a single LAYER_SOLID
op). Return value is now "no internal error" rather than
"glyph had color paint".
* util/gpu/demo-font.cc: drops the draw-only upload path and
routes every glyph through hb_gpu_paint_{clear,glyph,encode,
recycle_blob}. Uploads the active palette to the
hb_gpu_palette uniform array in demo_font_create.
* util/gpu/demo-shader.cc: concatenates hb_gpu_paint_shader_source
after the shared + draw sources, and the demo's fragment main
now calls hb_gpu_paint(texcoord, glyphLoc, u_foreground)
directly. Stem-darkening / debug overlay paths preserved
against the premultiplied alpha channel returned by paint.
MSL / WGSL / HLSL demo paths are unchanged for now -- the paint
shader is GLSL-only and those demos keep using the draw path.
wasm size impact (local Emscripten build):
baseline 412722 170342 gz
+HB_NO_COLOR/HB_NO_PAINT 437752 179165 gz
+demo paint wiring 443313 181502 gz
delta (vs baseline) +30591 +11160
All 241 tests pass.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Wire the paint-callback pipeline for COLRv0 color glyphs.
Adds:
* push_clip_glyph / pop_clip / color / custom_palette_color
callbacks. Each COLRv0 layer's push_clip_glyph is captured,
then the following color callback rasterizes the clip-glyph
outline through a scratch hb_gpu_draw_t, appends the resulting
Slug sub-blob, and emits a LAYER_SOLID op carrying the
palette_index (preserved via custom_palette_color) plus the
is_foreground flag. pop_clip clears the pending state.
* hb_gpu_paint_get_funcs(): cached singleton hb_paint_funcs_t via
the standard hb_paint_funcs_lazy_loader_t.
* hb_gpu_paint_glyph(): stashes the font scale and invokes
hb_font_paint_glyph_or_fail() with our funcs and a sentinel
foreground (the encoder never stores foreground -- the shader
resolves it per quad from a caller-supplied attribute).
* hb_gpu_paint_encode(): concatenates the 3-texel header, the op
stream, and the collected sub-blobs into one RGBA16I blob,
patching each op's sub_blob-index into an absolute texel
offset. Returns NULL when no layers accumulated or an
unsupported (v1) feature was seen.
* hb_gpu_paint_clear(): discards ops, sub-blobs, and pending
state while preserving the font scale.
The gradient / group / transform callbacks are not wired yet, so
COLRv1 paint graphs silently fall through -- callers should
precheck with hb_ot_color_glyph_has_paint() and route v1 glyphs
elsewhere (or fall back to draw).
Enables HB_NO_COLOR and HB_NO_PAINT in the web demo config
override so the wasm link resolves the new paint pipeline
symbols. Measured on a local Emscripten build:
raw wasm: 412722 -> 437752 (+25030 B, +6.1%)
gzip wasm: 170342 -> 179165 ( +8823 B, +5.2%)
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The previous commit routed color-glyph upload to hb_gpu_paint_t and
fell back to hb_gpu_draw_t on NULL blob. That is fine as long as
hb_gpu_paint_encode() is a stub returning NULL, but when the real
encoder lands the demo would start uploading paint-format blobs
into the atlas while the renderer still uses only the draw-stage
fragment shader -- producing garbage.
Keep the library-side paint stubs (they are legit scaffolding) but
back out the demo changes. The demo will grow the paint path in
lock-step with the paint shader, not ahead of it.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Reserve the paint-encoder API shape and wire the demo to try the
paint path before falling back to draw. The encoder itself is
still a stub so the fallback always fires today; when the encoder
lands, color glyphs will flip automatically with no demo changes.
New public API:
hb_gpu_paint_glyph (paint, font, glyph)
Stashes the font scale on @paint and calls
hb_font_paint_glyph_or_fail() with hb_paint_funcs_get_empty()
so non-color glyphs report false. Returns the funcs call
result.
hb_gpu_paint_encode (paint, &extents)
Stub, returns NULL.
hb_gpu_paint_clear (paint)
hb_gpu_paint_reset (paint)
hb_gpu_paint_recycle_blob (paint, blob)
Stubs that preserve the right semantics. clear is a no-op
(no accumulator state yet), reset additionally zeroes the
stashed scale, recycle_blob hb_blob_destroys.
Adds x_scale / y_scale to hb_gpu_paint_t so glyph can stash them
for the encoder to consume later.
util/gpu/demo-font.cc:
- Creates a paired hb_gpu_paint_t alongside hb_gpu_draw_t.
- Per glyph: if the face has COLRv1 paint for the glyph, tries
hb_gpu_paint_glyph + hb_gpu_paint_encode. On NULL blob, falls
through to the existing draw path.
- Changes the per-iteration sync from _reset to _clear for both
draw and paint: _reset zeroes the font-scale config that
_glyph immediately re-populates, which wastes work and is
semantically wrong. _clear discards accumulator state while
preserving user config.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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>
hb_raster_paint_glyph() took the palette index and foreground
color as per-call arguments, duplicating state that also lives on
the paint context (foreground via hb_raster_paint_set_foreground,
palette previously only available as a per-call arg). This gave
callers two paths for configuring the same state.
Drop the per-call palette/foreground arguments and require callers
to configure them via setters before painting, matching the
already-established pattern in hb_vector_paint_glyph() and
elsewhere in the subsystem.
- Drop palette and foreground args from hb_raster_paint_glyph().
- Add hb_raster_paint_set_palette() / _get_palette() and a
hb_raster_paint_get_foreground() companion.
- Store palette on hb_raster_paint_t (default 0).
- Update util/raster-output.hh, util/hb-raster-all.cc, and
test/fuzzing/hb-raster-fuzzer.cc to the new API.
- Update the hb-raster section-doc example.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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>
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>
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>
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>
- Default hb_vector_{draw,paint}_t::format to HB_VECTOR_FORMAT_INVALID
instead of HB_VECTOR_FORMAT_SVG.
- Update renamed hb_vector_{draw,paint}_set_{flat,precision} API docs
from "Since: 13.0.0" to "XSince: REPLACEME".
- Extract hb_vector_draw_render_svg() helper to match the
hb_vector_draw_render_pdf() pattern; move the misplaced
hb_vector_draw_render doc comment to the actual function and update
it to say "output blob" since the renderer is no longer SVG-only.
- Revert 14.0.0 NEWS entry edits; the API rename will be announced in
the next release entry.
- Update docs/harfbuzz-sections.txt to reflect the API renames.
- hb-vector tool: expose -O/--output-format with supported formats
"svg/pdf", validate format, update description string, and switch
PDF detection to g_ascii_strcasecmp for case-insensitive matching.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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>
Drop "svg" from the names since flat/precision settings apply
equally to PDF output. The new names follow the hb_vector_draw_*
/ hb_vector_paint_* convention:
hb_vector_svg_set_flat -> hb_vector_draw_set_flat
hb_vector_svg_set_precision -> hb_vector_draw_set_precision
hb_vector_svg_paint_set_flat -> hb_vector_paint_set_flat
hb_vector_svg_paint_set_precision -> hb_vector_paint_set_precision
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add hb-vector-pdf-paint.cc with a complete set of PDF paint
callbacks for the HarfBuzz paint API:
push/pop_transform → q + cm / Q
push/pop_clip_glyph → q + path + W n / Q
push/pop_clip_rect → q + re + W n / Q
color → rg + re + f
push/pop_group → q / Q
gradients → solid fallback (first stop color)
The PDF paint backend reuses the draw funcs for glyph clip
path emission and shares the hb_vector_paint_t struct with
the SVG backend via hb-vector-paint.hh.
hb_vector_paint_glyph dispatches to SVG or PDF paint funcs
based on format. hb_vector_paint_render delegates to the
PDF render function for PDF output.
Tested with COLRv0 (RocherColorGX) — color layers render
correctly with proper clipping.
Assisted-by: Claude <noreply@anthropic.com>
Add HB_VECTOR_FORMAT_PDF to hb_vector_format_t. The hb-vector
tool now produces self-contained PDF when invoked with -o out.pdf.
PDF path operators map directly from the draw callbacks:
move_to → m, line_to → l, cubic_to → c, close_path → h,
with quadratic-to-cubic promotion (PDF has no Q operator).
The render function builds a minimal PDF 1.4 with catalog,
page, and content stream objects plus a cross-reference table.
Implementation:
- Extract hb_vector_draw_t struct to hb-vector-draw.hh so
future backends can share it.
- Draw callbacks branch on format for SVG vs PDF syntax.
- hb_vector_draw_glyph and hb_vector_draw_render dispatch by
format.
- vector-output.hh selects format from file extension and
skips paint (color glyphs) for PDF.
Coordinate system needs refinement — the page layout inherits
the SVG Y-flip transform, placing glyphs at the top with
extra whitespace. Correct PDF coordinate handling is a
follow-up.
Assisted-by: Claude <noreply@anthropic.com>
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>
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>
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>
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>
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>
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>
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>
Allows simulating keyboard input at launch, e.g. -T '30= f'
zooms 30x, toggles fullscreen and starts animation.
Assisted-by: Claude <noreply@anthropic.com>
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>
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>
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>
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
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
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
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>