mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-25 08:51:07 +01:00
f8491cdb66efb60e5f4dce6786f2e277073d0976
21126
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
f8491cdb66 |
[paint] Centralize reduce_anchors in hb-paint.hh
hb-cairo-utils and hb-raster-paint each carried their own identical static copy of the COLR 3-anchor → 2-point gradient projection. Drop both, use the shared hb_paint_reduce_linear_anchors() added in the previous commit. Behavior unchanged. (hb-gpu-paint keeps its own copy intentionally -- it has slightly different surrounding code paths and we don't want to perturb the GPU encoder in this round.) Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
ce4199c303 |
[vector] Fix linear-gradient anchor reduction
hb-vector-paint emitted (2*x1 - x2, 2*y1 - y2) as the SVG end point -- the reflection of P2 about P1, not the projection. For COLR linear gradients the SVG end should be P1 projected onto the line through P0 perpendicular to (P2 - P0); that's the gradient's actual axis (perpendicular to the rotation line). With the old formula, fonts with rotation references far from the color line ended up with massively over-scaled gradient axes -- e.g. BungeeSpice's ABC showed solid red where raster shows a full red->yellow gradient. Add hb_paint_reduce_linear_anchors() to hb-paint.hh as the shared canonical implementation (matches hb-raster-paint and hb-cairo) and use it from hb-vector-paint. Regenerate the two affected basic.tests expected SVGs; the new gradient endpoints are now consistent with the cairo / raster outputs. Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
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> |
||
|
|
59d819f09c |
[util/gpu/web] Live palette via postMessage
Add web_set_palette() to both GL and WebGPU bindings (forwards
to demo_font_set_palette + buffer rebuild) and accept a
{ kind: 'palette', value: <int> } message in shell.html. Lets
the harfbuzz-world.cc host page push the user's CPAL pick into
the embedded GPU iframe alongside text / font / variations.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
||
|
|
c559eb8bc9 |
[vector] NEWS: document hb_vector_*_flat removal
PR #5927 dropped the flat-mode API. Add a Removed API entry, cross-link it to the svg-prefix replacement bullet, and clean up the now-stale Changed/New API entries that mentioned set_flat. Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
addaafd255 |
[vector] Rename svg_{set,get}_prefix to {set,get}_svg_prefix
Verb-then-thing matches the rest of the hb-vector setter/getter naming (set_precision, set_palette, etc.). Update the renamed internal references and the NEWS / harfbuzz-sections.txt entries to match. Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
ca75fd5ff9 |
[vector] Drop hb_vector_{draw,paint}_{set,get}_flat (#5927)
Flat mode disabled glyph reuse / caching to produce inline- everything SVG output. Its main use case was making hb-vector SVGs safe to concatenate side-by-side in a single document, but the recently-added svg_set_prefix API solves that without giving up the cache. No remaining callers in tree (util/vector-output.hh's --flat option goes too). Removes: - hb_vector_draw_set_flat / get_flat - hb_vector_paint_set_flat / get_flat - the `flat` field on both contexts - all `if (flat)` / `bool can_cache = !flat` branches - the --flat option in util/vector-output.hh - the four "flat*" expected files in test/vector/basic - the flat_draw / flat_paint params in the vector fuzzer - sections-list entries meson test --no-rebuild green (241/241). Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
ec63b7d921 |
[docs] Surface API-reference links in each integration section
The integration chapter explained how to use hb-glib / hb-ft / hb-cairo / hb-uniscribe / hb-coretext / hb-icu but never linked to the actual symbol pages. Readers had to guess the docbook page name to find the function reference. Add a "API reference: <link>" line at the top of each of the five C-binding integration sections (Python intentionally omitted -- uharfbuzz lives outside this manual). doc-check is green. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
45d2856376 |
[docs] Link to harfbuzz-world.cc from the install manual
Add a "Single-file build with harfbuzz-world.cc" section right after the configuration knob list. Names the amalgamation file, references the HB_TINY / HB_HAS_* machinery the section above just covered, and points at the harfbuzz-world.cc playground + source as a worked example. doc-check is green. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
747c04fc19 |
README, BUILD: link to harfbuzz-world.cc
Mention the live in-browser playground and the worked single-file build example at <https://harfbuzz-world.cc/>: - README.md: extend the existing amalgamated-sources paragraph with a pointer. - BUILD.md: add a paragraph at the bottom of the no-build-system section pointing at the playground and at the source repo (which is itself a worked example of `harfbuzz-world.cc` integration). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
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> |
||
|
|
7fe31859ca |
[config] Drop HB_NO_SUBSET_LAYOUT from HB_LEAN
HB_LEAN was dropping GSUB/GPOS out of the subset output, which turns subsetting Arabic / Indic / any complex-script font into a paperweight: the produced subset has no layout so it can't shape the text it was subsetted for. That's not really "lean", that's broken for most non-Latin use. Subset layout is load-bearing enough that it should stay in any HB_LEAN / HB_TINY build. Callers that truly don't want it can still #define HB_NO_SUBSET_LAYOUT themselves. meson test --no-rebuild is green (241/241). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
d35cdadd2a |
[util/gpu/web] Ignore 0x0 resizeCanvas calls; keep default buffer
The iframe-hosted case ran resizeCanvas() at script parse
time, before the iframe had laid out its canvas, which
installed a 0x0 drawing buffer. getContext('webgl2')
grabbed that 0x0 context and every subsequent setup (atlas,
viewport, swap chain) was frozen at 0x0 even when
ResizeObserver later re-ran resizeCanvas with real dims --
the existing context doesn't resize with the canvas
attribute.
Bail out of resizeCanvas when either dimension is 0, so the
canvas keeps its intrinsic default (300x150) until a real
layout arrives. getContext then grabs a non-degenerate
context, and the first ResizeObserver callback bumps it up
to the actual iframe-sized buffer.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
||
|
|
b13da1a712 |
[util/gpu/web] Re-fire window resize from the canvas observer
Changing canvas.width/height directly doesn't reach emscripten's GLFW port -- its framebuffer-size callback fires on window 'resize' events, not canvas mutation records. When ResizeObserver picks up the iframe's first real layout, also dispatch a synthetic 'resize' event so the framebuffer_size callback runs in wasm and glViewport gets re-set to the real size. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
05cb6623f6 |
[util/gpu/web] ResizeObserver on canvas; pick up first real layout
Initial resizeCanvas() runs at script parse time -- when the shell is inside a just-mounted iframe, the canvas's clientWidth / clientHeight are 0 (iframe hasn't laid out yet) and the GL drawing buffer installs at 0x0. A plain window 'resize' event never fires just because the iframe has sized itself, so the buffer stays 0x0 and the tab looks blank forever. Watch the canvas with a ResizeObserver and re-run resizeCanvas + requestRedraw on any observed size change, which catches the first real size the moment the iframe lays out. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
251c9d26e0 |
[vector] Apply svg prefix to the color-glyph first-use <use href>
Missed one emission site in the SVG color-glyph path: when a color glyph is first seen, hb-vector both defines it in <defs id="cg<N>"> (which I prefixed) and emits an initial <use href="#cg<N>"> in the body (which I did not). The mix meant body refs for the first use of every color glyph went unprefixed, so a caller-prefixed document had refs pointing to nonexistent IDs and the whole image came out blank. Fix: route that href="#cg<N>" through the prefix too. Verified on Noto Emoji subset: rsvg-convert with a "v1-" prefix now renders the full color glyph (was blank before). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
c3b0c4e282 |
[vector] Add hb_vector_{draw,paint}_svg_{set,get}_prefix
New public API for namespacing SVG output: callers that embed
multiple hb-vector-produced SVGs into the same document can
set a distinct id prefix per context, so hb-vector's short
internal IDs (p<N>, c<N>, clip-g<N>, gr<N>, cg<N>) don't
collide across snippets.
Example collision the new API prevents: page embeds two
hb-vector SVGs produced by different contexts. Both use
id="clip-g10"; the browser's url(#clip-g10) resolves to
whichever element appears first, so paint layers in the
second SVG get clipped against the first SVG's glyph outline
-- visible as giant unclipped color rects bleeding across
the wrong glyph shape.
With the new API the second caller passes e.g. "b-" as its
prefix; the clash disappears. Empty/NULL prefix preserves
the existing output byte-for-byte.
Affects every id / url(#...) / href="#..." emission in SVG
output:
- hb-vector-draw: <path id="p..."> + <use href="#p...">
- hb-vector-paint: <path>, <clipPath>, <linearGradient>,
<radialGradient>, <g id="cg..."> color-glyph cache, and
every corresponding url(#...) / href="#..." ref.
PDF output is unaffected (no ids).
Docs/harfbuzz-sections.txt updated; check-symbols passes.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
||
|
|
cd1af387ba |
Revert "[vector] Flat mode: inline clip-path="path('...')" instead of <clipPath>"
This reverts commit
|
||
|
|
3fe077d713 |
[vector] Flat mode: inline clip-path="path('...')" instead of <clipPath>
Flat output was still emitting <clipPath id="..."> into <defs>
and referencing them via clip-path="url(#...)". That meant
flat SVGs couldn't be safely concatenated: two documents'
short IDs (c0, clip-g10, ...) would collide and url(#c0)
resolves to whichever element appears first in document
order, producing the wrong clip and giant paint rects
falling through their clips.
SVG 2 lets clip-path take inline basic-shape or path()
values. In flat mode, emit:
push_clip_glyph -> clip-path="path('<glyph-d>')"
push_clip_rectangle -> clip-path="path('M..H..V..H..Z')"
...directly on the wrapping <g>, skipping defs entirely.
The resulting flat SVG truly has no defs for clips and is
safe to embed alongside other hb-vector output.
Gradients still use defs (paint servers need URL refs), but
those only affect color, not geometry -- a gradient
resolution mismatch yields wrong colors, never the
unclipped-rect bleed that was the visible symptom.
Verified on util/gpu/web/ / harfbuzz-world.cc's Noto color
emoji subset: no <clipPath> tags, no clip-path="url(...)",
69 inline clip-path="path('...')" refs instead. Meson
test --suite vector remains 22/22 green.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
||
|
|
8c99cf0a9a |
[util/gpu/web] Accept ?embed without a value, not just ?embed=1
Be permissive about the embed-mode URL form: ?embed, ?embed=1, ?embed=true all turn the mode on; only explicit ?embed=0 / ?embed=false leave it off. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
bdea49603c |
[util/gpu/web] Add embed-mode + postMessage protocol to the web demo
Lets a host page embed hb-gpu-demo as an iframe and drive it
from outside. harfbuzz-world.cc uses this to share its
text/font controls with the GPU tab without reinventing the
GPU stack.
Shell additions:
- ?embed=1 URL param hides the demo's own chrome (font
picker, text button, backend selector, FPS counter,
keyboard-help overlay) by setting html.embed.
- Message protocol:
{ kind: 'text', value: '…' } -> applyText
{ kind: 'font', bytes: ArrayBuffer } -> _web_load_font
On runtime init the shell posts { kind: 'ready' } to its
parent so the host can send font bytes (which can't ride
on the URL for file-uploaded fonts).
Existing ?text= and ?font= URL params still work and are
useful for "link to a specific demo" sharing.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
||
|
|
b7a7d33052 |
[src] Add HB_*_CC include guards to three world.cc dup-include sources
src/harfbuzz-world.cc unconditionally #includes hb-number.cc, hb-ot-cff1-table.cc, and hb-ot-cff2-table.cc in its core group, then re-#includes the same three files in its HB_HAS_SUBSET group (carried over from when the subset library was its own translation unit). In the single-TU amalgamation that's a redefinition error and prevents HB_HAS_SUBSET from being enabled. Wrap each file in the same HB_FOO_CC ifndef/define/ifdef guard pattern already used by hb-static.cc and hb-zlib.cc, so a second #include is a no-op. Verified with a wasm build of harfbuzz-world.cc that has both the core and subset blocks active, and a full meson test run (241/241 OK) on the regular library build. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
a0ae5ee262 | [config] In HB_TINY, don't disable draw/paint if any libs need it | ||
|
|
bb64f2cb30 |
[util/gpu] Fold the handful of used view options into the GPU group
hb-gpu only honors four of view_options_t's eleven options (--foreground, --background, --font-palette, --custom-palette). Exposing the full set via --help-view misled users into trying --stroke, --margin, --rainbow, etc., which silently did nothing. Merge the four relevant entries into the GPU option group (pointing at view_options_t's storage fields) and delegate parsing to view.post_parse() via a new gpu_output_t::post_parse. Drops the unused view entries from --help while keeping all the color/palette parsing logic shared with hb-view / hb-raster. Assisted-by: Claude <noreply@anthropic.com> |
||
|
|
ed9bdd1031 |
[util/gpu] Silence LOGI output when --output-file is set
Scripted / CI use of hb-gpu -o wants clean stderr. Gate LOGI on a hb_gpu_demo_quiet flag that hb-gpu flips to 1 when an output file is specified, so font stats, help text, and toggle-vsync chatter all stay out of the way. LOGW / LOGE are intentionally unaffected -- warnings and fatal errors should always surface regardless of quiet mode. Assisted-by: Claude <noreply@anthropic.com> |
||
|
|
18fa43ce29 |
[util/gpu] Fix regression: --output-file required an output file
Using output_options_t<false> (no stdout default) was the wrong choice: post_parse() rejects any invocation without -o, so every windowed hb-gpu run started failing with "No output file was specified." Roll a bespoke char* option instead: if set, render one frame to PPM (opening the file or stdout inline); otherwise the usual windowed mode. Keeps both code paths trivial and doesn't require the caller to specify an output file for interactive use. Assisted-by: Claude <noreply@anthropic.com> |
||
|
|
041fffa45f |
Merge pull request #5923 from harfbuzz/fuzzer-fixes-apr14
Fuzzer fixes apr14 |
||
|
|
d529a3ca90 |
[bit-set][hashmap] clear() under error state: early-out on empty
Previously clear() bailed outright under !successful, to protect the Null singleton which lives in (possibly read-only) static storage. That meant a real instance entering error state would silently fail to clear, leaving stale contents for the next caller. Replace the `!successful` guard with an early-out on already- empty state. The Null singleton is zero-initialized (population, occupancy, mask all 0), so the early-out catches it before any write. Any non-empty instance is by construction a real heap object with writable storage, so clearing is safe there even under !successful. Assisted-by: Claude <noreply@anthropic.com> |
||
|
|
8e7e29a691 |
[bit-set] Revert clear() change -- can't touch Null singleton
The prior commit (
|
||
|
|
32fbe980ad | [NEWS] Attribution | ||
|
|
2adb01a47c |
[internal] Replace remaining vector resize(0) with clear()
Two callers were still using vector.resize(0) to drop accumulated
data: graph/serialize.hh's overflow tracking and hb_bit_set_t's
clear() (via its own internal resize()). resize(0) on a vector
in error state short-circuits without zeroing length, leaving
stale entries that downstream code then walks as if valid.
Fix both:
- serialize.hh: call overflows->clear() instead.
- hb-bit-set.hh: reimplement clear() to zero length/population
unconditionally by calling pages.clear() / page_map.clear()
directly, bypassing the internal resize() that bails when
`successful` is false.
Mirrors the March clear() fix in hb-vector.hh (commit
|
||
|
|
fe04146acb |
[vector] Simplify reset() to use clear() instead of resize(0)
After the March refactor that made clear() a direct shrink_vector(0), reset() going through resize(0) adds an indirection (resize_full -> alloc(0) no-op -> shrink_vector(0)) for identical observable behavior. Use clear() directly. Assisted-by: Claude <noreply@anthropic.com> |
||
|
|
df4be0cec8 |
[gpu] Use vector.reset() not resize(0) in hb_gpu_paint_clear
Three accumulator vectors -- ops, sub_blobs, transform_stack -- can enter error state via failed push_or_fail() under failing-malloc. Once in error state, resize(0) short-circuits at the in_error() guard in alloc() and leaves length unchanged. In hb_gpu_paint_clear that means the next iteration's clear walks the stale entries again. For sub_blobs this is a double-destroy: the blob pointers were already freed in the previous clear, and hb_blob_destroy reads the dead ref_count field -- heap-use-after-free. Fix by calling vector.reset(), which clears the error state before resizing to 0. Matches the pattern hb_gpu_draw_clear already uses for draw->curves. Found by oss-fuzz/CIFuzz on hb-gpu-fuzzer; minimized testcase added to the fuzz corpus. Assisted-by: Claude <noreply@anthropic.com> |
||
|
|
24aa15d39a |
[gpu] Cap accumulated curves per glyph to bound memory
The curve accumulator grew without bound, reaching 2.9 GB on fuzzer-crafted inputs (VARC components expanded recursively, or cu2qu subdivisions on degenerate cubics, or a glyf with absurd contour counts). libFuzzer flags this as OOM. Add HB_GPU_DRAW_MAX_CURVES = 0x10000 (65536) -- far above any real glyph's needs -- and refuse to emit beyond it, flipping success=false so the encoder returns a valid empty/failure blob. Catches all upstream explosions (glyf / cu2qu / VARC / any future source) at the single choke point. Found by oss-fuzz/CIFuzz on hb-gpu-fuzzer. Assisted-by: Claude <noreply@anthropic.com> |
||
|
|
25bfb5adc3 |
[vector-paint/pdf] Check color-stops vector resize under failing-malloc
Two sites queried color-stop count, resized the scratch vector to match, then called hb_color_line_get_color_stops() passing the requested count as the write capacity. If the resize() failed (OOM), the vector stayed at its previous (smaller) length while the callee still wrote the full requested count -- heap-buffer- overflow. Fixed by checking resize() and bailing: build_gradient_function returns 0, paint_sweep_gradient returns. Matches the pattern already used in hb-raster-paint.cc and hb-vector-paint.cc. Found by oss-fuzz/CIFuzz on hb-vector-fuzzer against a sweep- gradient COLRv1 glyph under failing-malloc. Assisted-by: Claude <noreply@anthropic.com> |
||
|
|
cb834b17b5 |
[NEWS] Draft entry for upcoming release
Cover since 14.1.0: GPU paint renderer (hb_gpu_paint_t), Vector PDF output backend, SVG-in-OT glyph-source removal from Raster and Vector, cross-subsystem _clear() companions and getter companions, --output-file flag for hb-gpu, and fuzzer fixes. List new / removed / changed API grouped by library. Assisted-by: Claude <noreply@anthropic.com> |
||
|
|
9ebdd0019f |
[util/gpu] Add --output-file for headless PPM render
Gives hb-gpu a non-interactive output path: hb-gpu --demo -o /tmp/frame.ppm hb-gpu --demo -o - | display # stdout piping When --output-file is set, the GL backend passes GLFW_VISIBLE=false so no window pops up. After the normal init and one render pass, we glReadPixels the default framebuffer, flip row order, and write a PPM (P6) to the selected sink. No event loop, process exits after writing. Supported format: ppm (only). Other formats are rejected by the shared output_options_t machinery. Metal and D3D11 backends currently still open a window; headless support there is a straightforward follow-up. This unlocks CI golden-image tests for shader changes and reproducible benchmark timing without swapchain-present jitter. Assisted-by: Claude <noreply@anthropic.com> |
||
|
|
6828ad2865 |
[util/gpu] Route LOGI to stderr
LOGI is informational output (help text, toggle state, fps). It belongs on stderr: that keeps stdout available for program output (e.g. --output-file=- piping a PPM through a pipeline), and it matches LOGW/LOGE which already go to stderr. No user-visible change in normal (windowed) runs; stderr shows up in the same terminal as stdout by default. Assisted-by: Claude <noreply@anthropic.com> |
||
|
|
644b007df5 |
Add hb-gpu-paint COLRv1 renderer (#5920)
* [gpu] Add hb_gpu_paint_t infrastructure skeleton
Reserve the API shape for the upcoming GPU color-glyph paint
encoder. The skeleton adds:
hb_gpu_paint_t opaque type
hb_gpu_paint_create_or_fail ()
hb_gpu_paint_reference ()
hb_gpu_paint_destroy ()
hb_gpu_paint_set_user_data () / _get_user_data ()
hb_gpu_paint_shader_source (stage, lang)
Only the lifecycle is functional. hb_gpu_paint_shader_source()
returns an empty string for all supported (stage, lang) pairs
until the paint-renderer shaders land.
This commit wires up the files, public declarations, section
index, and build system (meson, CMake, harfbuzz-world.cc,
vtable). Callers can now hold, reference, destroy, and attach
user data to a paint context.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [gpu] Merge *-shaders.cc dispatchers into the subsystem .cc files
Each subsystem already had a dedicated source file for its C API;
having the shader-source getter live in a separate `*-shaders.cc`
was unnecessary. Merge:
hb-gpu-shaders.cc -> hb-gpu.cc
hb-gpu-draw-shaders.cc -> hb-gpu-draw.cc
hb-gpu-paint-shaders.cc -> hb-gpu-paint.cc
Each subsystem's .cc is now self-contained: the lifecycle, glyph
accumulation, and shader-source getter all live together.
The large stringized-shader .hh artifacts are included locally at
the bottom of each file, right above the function that uses them,
rather than with the primary includes at the top -- they are only
used by one function.
Updates meson.build, CMakeLists.txt, and harfbuzz-world.cc to
drop the removed files. All 241 tests still pass.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [gpu] Document hb_gpu_paint_t encoded-blob design
Add a design-doc comment in hb-gpu-paint.hh pinning the model
before any encoder code lands:
* One blob per glyph, one quad per glyph. The fragment shader
walks a flat pre-order op stream and maintains a small (depth-4)
group stack to composite.
* Op types: LAYER_SOLID, LAYER_GRADIENT, PUSH_GROUP, POP_GROUP.
* Clip-glyph outlines are embedded as Slug-format sub-payloads
(same format hb_gpu_draw_encode produces). v1 bakes the full
paint transform into each outline; v2 may canonicalize and share
translate-only variants.
* Gradient parameters embedded as RGBA16I texels: inverse transform
in q15.16, type+extend, subtype params, color stops.
* Colors carry a (palette_index, flags, alpha_q15) triple rather
than resolved RGBA. Palette is a shader-side uniform array of
256 vec4; swapping palettes never requires re-encoding. The
encoder preserves palette indices through harfbuzz's paint
pipeline via a custom_palette_color_func that returns a sentinel
hb_color_t with the index encoded, decoded again in the color /
color-stop callbacks.
* Shader entry point:
vec4 hb_gpu_paint (vec2 renderCoord, uint glyphLoc,
vec4 foreground);
Foreground is an explicit parameter; the caller chooses whether
to source it from a uniform or a per-quad flat varying (per-quad
lets styled text runs render in one draw call).
* Out of scope for v1: RECT_CLIP ops (treated as hints, not
enforced), paint images.
No code yet. The skeleton hb_gpu_paint_t stays as a bare
hb_object_header_t; encoder state and public API additions come in
follow-up commits.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [gpu] Add hb_gpu_paint_* glyph/encode/clear/reset/recycle stubs
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>
* [gpu] Revert demo paint-path wiring
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>
* [gpu] Drop hb_paint_funcs_get_empty from hb_gpu_paint_glyph stub
The stub called hb_font_paint_glyph_or_fail() with the empty paint
funcs just to get a truthful has-paint return value. That pulls in
hb_paint_funcs_get_empty from hb-paint.cc, which HB_LEAN strips out
of the wasm build, breaking the web demo link step.
Since the encoder is still a stub that accumulates nothing, there is
no reason to actually invoke the paint callback walk. Stash the
font scale and return false directly. When the real encoder lands
it will naturally pull in whichever paint symbols it needs.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [gpu] Implement hb_gpu_paint_t COLRv0 encoder
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>
* [gpu] Add GLSL paint fragment shader (LAYER_SOLID interpreter)
Implements the paint-renderer fragment entry point
hb_gpu_paint(renderCoord, glyphLoc, foreground) -> vec4 as an
interpreter over the blob format documented in hb-gpu-paint.hh.
For this first slice only LAYER_SOLID ops are handled -- enough
to render COLRv0 color glyphs end to end once the demo is
rewired. LAYER_GRADIENT and PUSH/POP_GROUP cause the interpreter
to stop; COLRv1 support lands in follow-up commits.
The shader:
* Reads the blob header for num_ops and ops_offset.
* Walks the op stream. For each LAYER_SOLID it fetches the
clip-glyph coverage via hb_gpu_draw() (provided by
hb_gpu_draw_shader_source), looks up the color from
hb_gpu_palette[] or the caller-supplied foreground parameter
(per the is_foreground flag), and composites SRC_OVER.
hb_gpu_paint_shader_source() now returns the compiled source for
GLSL fragment; other languages and the vertex stage still return
"" until transcribed.
Wires meson.build and gen-gpu-shader-artifacts.py to generate the
.hh artifact.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [gpu] Wire GL demo to the paint pipeline end-to-end
* 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>
* [gpu] encode-all: paint-first with draw fallback; skip empty clip glyphs
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>
* [gpu] First working COLRv0 GPU render
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/gpu] Extract demo shaders into .glsl files
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>
* [gpu] Port paint fragment shader to MSL; wire Metal demo
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>
* [gpu] Port paint fragment shader to WGSL; wire WebGPU demo
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>
* [gpu] Paint: port to HLSL/WGSL; add _hb_gpu_draw_impl; fix WGSL
This commit unblocks end-to-end paint rendering on the WebGPU
demo, adds the HLSL port, and avoids losing MSAA or stem
darkening along the way.
### Shared: _hb_gpu_draw_impl
hb_gpu_draw internally did fwidth(renderCoord) + MSAA. That works
fine in the single-call-per-fragment case but not when called from
inside a non-uniform branch (e.g. an op-stream LAYER_SOLID
conditional in the paint fragment shader) -- WGSL rejects fwidth
from non-uniform control flow.
Factor the MSAA-aware body into _hb_gpu_draw_impl, which takes a
caller-supplied pixelsPerEm. hb_gpu_draw is now a thin wrapper
that computes pixelsPerEm via fwidth and delegates. The paint
fragment shader in every language now computes pixelsPerEm once
at the top of hb_gpu_paint and calls _hb_gpu_draw_impl per layer
-- MSAA preserved, no redundant fwidth calls per layer.
In WGSL, _hb_gpu_draw_impl also inlines the ppem computation from
pixelsPerEm rather than recurring into hb_gpu_ppem (which itself
calls fwidth).
### Paint shaders
- hb-gpu-paint-fragment.hlsl (new): HLSL transcription. Assumes
a caller-declared StructuredBuffer<float4> hb_gpu_palette at
register(t1).
- hb-gpu-paint-fragment.wgsl: switched from hb_gpu_draw to
_hb_gpu_draw_impl; comment updated.
- hb-gpu-paint-fragment.msl, .glsl: same switch, cached
pixelsPerEm at entry.
hb_gpu_paint_shader_source() now returns content for all four
languages.
### Demos
- util/gpu/demo-fragment.glsl: restores stem darkening (dropped in
the first paint wiring commit); applies to the premultiplied
RGBA by scaling both colour and alpha. The desktop GL demo
regenerates demo-fragment-glsl.hh from this source.
- util/gpu/web/hb-gpu-web-webgpu.cc: WGSL fs_main concatenates the
paint source, binds a zero-filled palette storage buffer at
@group(0) @binding(2), and restores stem darkening. fwidth
hoisted outside the stem-darkening conditional so WGSL's
derivative-uniformity rule is happy.
- util/gpu/demo-renderer-d3d11.cc: HLSL ps_main switches to
hb_gpu_paint. Adds a second StructuredBuffer<float4>
hb_gpu_palette at t1, zero-filled for now, bound alongside the
atlas SRV.
### Misc
- perf/benchmark-gpu.cc: fix stale reset/encode(draw) calls.
Measured build (local Emscripten):
WebGL index.wasm : 443638 181640 gz
WebGPU webgpu.wasm : 461626 188400 gz
COLRv0 rendering (BungeeTint, Noto Color Emoji, etc.) now works
end-to-end on WebGL and WebGPU with the correct palette. Metal
and D3D11 demos should likewise compile against the new shader
flow; real palette upload cross-backend remains a TODO.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [gpu] Fix Metal segfault: route palette upload through atlas backend
The Metal path creates a GLFW window with GLFW_NO_API (no GL
context), but demo_font_upload_palette() unconditionally called
glGetIntegerv(), causing a segfault on the first glyph lookup.
Split palette upload into GL and external-backend paths:
- Extract demo_font_get_palette() to read CPAL colors into a
float array, shared by both paths.
- GL path (demo_font_upload_palette_gl) uploads via glUniform4fv
as before.
- External-backend path uploads via a new upload_palette callback
in demo_atlas_backend_t.
- Metal renderer implements the callback, writing palette data
directly to its paletteBuffer.
This fixes the --metal crash and enables proper COLRv0 palette
color rendering on Metal.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [util/gpu] Cross-backend palette upload via demo_renderer_t::set_palette
Reorganises the palette-upload plumbing so every backend handles
it uniformly and the hacky atlas-backend palette callback goes
away.
Before: demo_font_upload_palette in demo-font.cc mixed a GL
glUniform4fv direct call with a detour through an extra
demo_atlas_backend_t.upload_palette callback used by the Metal
renderer. demo-font and demo-atlas both knew about palettes.
After:
* demo_font_get_palette (font, out, capacity) just reports the
active palette as RGBA floats; demo-font no longer touches GL
state or the atlas for palettes.
* demo_renderer_t gains a virtual set_palette (rgba, count).
Default is a no-op. Backends override:
- demo-renderer-gl.cc -> demo_glstate_set_palette() ->
glUniform4fv.
- demo-metal.mm -> memcpy into the MTLBuffer's contents.
- demo-renderer-d3d11.cc -> ID3D11DeviceContext::UpdateSubresource
(palette buffer switched from IMMUTABLE to DEFAULT).
- hb-gpu-web-webgpu.cc -> wgpuQueueWriteBuffer on the palette
storage buffer.
* Callers invoke renderer->set_palette (palette, n) right after
demo_font_create:
- util/gpu-output.hh (desktop demo: GL / Metal / D3D11).
- util/gpu/web/hb-gpu-web.cc (WebGL).
- util/gpu/web/hb-gpu-web-webgpu.cc (WebGPU).
* The extra upload_palette field on demo_atlas_backend_t is
removed along with demo_atlas_upload_palette / _is_external --
atlas is back to being about glyph data only.
COLRv0 rendering now works with proper palette colours through
every backend that implements set_palette (WebGL, WebGPU, and
Metal/D3D11 once tested).
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [util/gpu] Respect view-options: foreground, background, palette, custom-palette
Wires view_options_t into gpu_output_t so hb-gpu picks up the
same foreground/background/palette flags the rest of the tools
use:
--foreground=#RRGGBB[AA]
--background=#RRGGBB[AA]
--font-palette=N
--custom-palette=N=#RRGGBB[,N=#RRGGBB,...]
After demo_view_setup() the gpu main loop now:
1. Fetches the active palette from the face via
demo_font_get_palette(font, view.palette, ...) -- palette index
out of range falls back to 0.
2. Overlays each view.custom_palette_entries entry on top of that
palette (clamped to 256 entries).
3. Uploads via renderer->set_palette(). Web demos and the
headless WebGPU path do the same, with palette_index=0 (they
don't yet plumb --font-palette).
4. Calls renderer->set_foreground / _background from the
post-parsed view-options colours. Defaults match the demo's
prior LIGHT mode, so no-op when the user passes no flags; the
dark-mode toggle (b key) still mutates renderer state
independently.
Other view-options flags (--rainbow, --stroke, --line-space,
--margin, --logical/--ink, --show-extents, --font-extents)
appear in --help-view for familiarity but currently no-op in
hb-gpu; they're inherited wholesale from view_options_t and the
gpu path just doesn't wire them.
demo_font_get_palette() now takes a palette_index parameter so
callers can ask for non-zero palettes (e.g. dark-mode palettes in
fonts that ship them). Web demos pass 0 for now.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [util/gpu] Web demos: URL ?text= and ?font=; wider default font
Two user-visible features plus a font swap.
### URL parameters
Forwards ?text= and ?font= from the query string into the C main
as --text=... and --font=... via Module.arguments, so the initial
text is applied before the first rendered frame (no flash of
default demo text). ?font= is still fetched asynchronously on
the JS side; once loaded, the text is re-applied to the new font.
If neither parameter is present, behaviour is unchanged: the
baked-in default text renders in the baked-in default font.
Data URLs (?font=data:font/ttf;base64,...) work naturally via
fetch(). Remote URLs need CORS; raw.githubusercontent.com and
jsdelivr both work, github.com/.../raw/... does not.
### Wider default font
The baked-in default-font.hh was a narrow subset that didn't
include uppercase Latin, so `?text=Hello` shaped to .notdef for
H and W. Re-subset Parastoo-Regular.ttf via hb-subset with:
--unicodes='U+0020-007E,U+0600-06FF,U+FB50-FDFF,U+FE70-FEFF'
covering printable ASCII plus the Arabic block and the two
Arabic presentation-forms blocks.
Font size:
source Parastoo-Regular.ttf 109152
new subset 49940
Wasm size impact (webgl build, Oz+lto):
before 443628 181597 gz
after 466657 196209 gz
delta +23029 +14612 gz
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [util/gpu] Web demos: skip default-font upload when ?font= pending; preserve URL on backend switch; reflect custom text in URL
Three small UX improvements to the web demos.
### Skip default-font upload when ?font= is pending
When ?font= is set, the async fetch replaces the font later. main
was still populating the atlas with the default font's glyphs for
the initial text, just to throw them away when _web_load_font ran
its own rebuild_buffer. Gate demo_buffer_add_text() on !arg_font
so the buffer stays empty until the real font lands.
### WebGPU ready signal
WebGPU's init_demo is async (awaits adapter/device), so
onRuntimeInitialized fires before the demo is usable; calling
_web_load_font from the ?font= fetch at that point tripped a wasm
indirect-call signature mismatch. init_demo now EM_ASMs a
window._webDemoReady() hook at its tail; the shell installs
_webDemoReady = startFontFetch when running the WebGPU build and
starts the fetch immediately for WebGL.
### URL ergonomics
* Backend-selector change now carries location.search across the
navigation -- ?text= and ?font= survive the WebGL <-> WebGPU
switch.
* The text-edit modal's Apply button updates history.replaceState
with a ?text= param so the typed text is copy/pasteable. Skips
the update when the text is unchanged from what was open.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [util/gpu] demo-font: tolerate NULL paint encode
hb_gpu_paint_encode returns NULL when the glyph uses unsupported
paint features (e.g. COLRv1 gradients/transforms) or emits zero
ops. Treat that as an empty glyph instead of die()-ing the whole
app, so fonts mixing supported and unsupported paint still render
their supported parts.
Zero-init hb_ext so the empty-glyph extents are well-defined, and
skip recycle_blob when blob is NULL.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [util/gpu] Web demos: fix URL-param handling for ?font= and ?text=
rebuild_buffer did free(current_text); strdup(text); but was often
called with text == current_text (from web_load_font's
"custom_text ? current_text : default"). Strdup of freed memory
shaped garbage and made multi-char strings look like 1 char. Fix:
strdup first, then free.
The WebGL rebuild_buffer also called demo_view_display itself,
which runs fine from a main loop tick but not from a fetch
promise's microtask (the canvas back-buffer doesn't swap). Drop
it: demo_view_reset sets needs_redraw=true, and the next
main_loop_iter renders inside a proper rAF tick.
Emscripten allocates argv on the JS stack, which is unwound when
main returns. WebGPU's init is async and reads arg_text/arg_font
after main returns, so those pointers were dangling -- early null
bytes in freed stack memory made the emoji URL shape to 1 glyph.
strdup them in main so they survive.
Finally, forward ?font= to argv as --font= (already done for
?text=) so the C side's "skip initial default-font glyph upload
when a font fetch is pending" path actually triggers.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [gpu] hb_gpu_paint: bake resolved color into blob, drop palette binding
Add a raster-style configuration surface to hb_gpu_paint_t:
hb_gpu_paint_set_foreground / hb_gpu_paint_get_foreground
hb_gpu_paint_set_palette / hb_gpu_paint_get_palette
hb_gpu_paint_clear_custom_palette_colors
hb_gpu_paint_set_custom_palette_color
hb_gpu_paint_glyph now passes paint->palette and paint->foreground
through to hb_font_paint_glyph, and the custom-palette-color
callback consults the user's overrides map (same pattern as
hb_raster_paint_t) before letting harfbuzz fall back to the font's
own palette.
With that in place, the color() callback can bake the already-
resolved RGBA into the encoded op directly, quantized as signed
Q15 in the existing second texel, instead of recording a palette
index and trusting the shader to look it up. The is_foreground
flag stays in the op so a runtime foreground-color change (e.g.
dark-mode toggle) still works without re-encoding.
Shader side: drop the hb_gpu_palette uniform/storage binding and
its HB_GPU_PALETTE_SIZE knob from all four paint-fragment shaders
(GLSL / MSL / WGSL / HLSL); read the per-layer color straight out
of the blob texel. This removes a per-backend binding slot and
the 256-entry uniform-array size ceiling that blocked fonts like
Noto-COLRv1 (~6200 entries).
Trade-off: changing the palette selection or overrides invalidates
previously encoded blobs and requires re-encoding. In practice
palette switches are rare, and the rendering hot path gets
simpler.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [util/gpu] Drop renderer palette plumbing, forward to hb_gpu_paint
Colors are now baked into encoded blobs (see prior commit), so
nothing needs to upload or bind a palette buffer. Remove
demo_renderer_t::set_palette from all backends (GL, Metal, D3D11,
WebGPU), the hb_gpu_palette GL uniform plumbing in demo-glstate,
the Metal/D3D11 palette buffers, and the WebGPU storage buffer +
bind-group entry. demo_font_get_palette is also gone.
Replace with new demo_font accessors that forward to the encoder:
demo_font_set_palette
demo_font_set_foreground
demo_font_clear_custom_palette_colors
demo_font_set_custom_palette_color
Each invalidates the glyph cache because colors are baked into
the atlas entries. gpu-output.hh now forwards view-option
--font-palette / --custom-palette through these.
Web demos stop allocating / uploading the palette buffer; the
WGSL fragment shader drops its third bind-group slot.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [gpu] hb_gpu_paint: emit LAYER_SOLID from gradients using first stop
Register linear/radial/sweep gradient callbacks that read just the
first color stop from the color line and emit a LAYER_SOLID op with
that stop's color. Previously these callbacks were unregistered,
so every gradient-filled layer silently produced no op -- Noto
COLRv1 emoji lost their face/body fills entirely.
Factor the LAYER_SOLID emission body out of hb_gpu_paint_color
into hb_gpu_paint_emit_solid so the color and gradient callbacks
share it. Reading one stop (count=1) drives the usual
custom_palette_color / foreground resolution path exactly once,
so palette overrides and is_foreground still apply.
This is a placeholder until real gradient ops land; it just makes
gradient-heavy fonts render with sensible flat colors instead of
missing layers.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [util/gpu] Drop sRGB framebuffer mode; always gamma 2.2
The paint encoder bakes sRGB-encoded font palette values directly
(quantizing 0..255 to 0..32767 without decoding), so the shader
writes sRGB-ish values. With GL_FRAMEBUFFER_SRGB enabled the
driver then applied linear->sRGB encoding on store, giving a
double-encoded, washed-out result -- most visible on mid-tone
gradients.
The cleanest fix is to stop pretending we're doing linear-space
compositing: drop the sRGB framebuffer mode entirely and always
apply the classic 2.2 gamma exponent for coverage correction
(flipped to 1/2.2 in dark mode to match the existing light/dark
logic). Removed pieces:
- demo_view_t::gamma_mode enum, demo_view_set_gamma_mode,
demo_view_cycle_gamma, and the `g` keybinding + help line
- demo_renderer_t::set_srgb virtual + every backend override
- GLFW_SRGB_CAPABLE hint in gpu-output.hh
- Metal swapchain MTLPixelFormatBGRA8Unorm_sRGB -> BGRA8Unorm
Replaced with demo_view_update_gamma, called on setup() and after
the dark-mode toggle. Shader side stays the same (only alpha gets
the gamma curve, as before).
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [gpu] hb_gpu_paint: encode linear gradients as LAYER_GRADIENT
The linear_gradient callback now emits a real LAYER_GRADIENT op
instead of falling back to a flat first-stop solid. Per-layer op
layout:
texel 0: (op_type=1, subtype=0, clip_payload_hi, clip_payload_lo)
texel 1: (grad_payload_hi, grad_payload_lo, extend_mode, stop_count)
Both payloads are sub_blob indices that hb_gpu_paint_encode()
patches to absolute atlas offsets. The clip payload is the
existing Slug draw blob for the layer's clip glyph; the gradient
payload is a fresh sub-blob laid out as:
texel 0 : (lx0, ly0, lx1, ly1) -- 2-point axis in font units,
reduced from COLRv1's 3-point anchors the same way
hb_raster_paint's reduce_anchors does it
texels 1..N : color stops, 2 texels each
texel a: (offset_q15, flags, _, _) flags bit 0 = is_foreground
texel b: (r_q15, g_q15, b_q15, a_q15)
All four paint fragment shaders (GLSL/MSL/HLSL/WGSL) grew a
_hb_gpu_sample_linear helper that projects the fragment onto the
axis, applies the COLRv1 extend mode, and walks stops to find the
enclosing segment.
Refactored the existing LAYER_SOLID emission body into
emit_clip_sub_blob + hb_gpu_paint_emit_solid so the gradient path
can share the clip-outline encode and extents accumulation. The
LAYER_GRADIENT encode-time patching walks both payload slots.
Radial and sweep callbacks still fall back to the first-stop solid
placeholder; they'll be replaced next.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [gpu] hb_gpu_paint: encode radial gradients as LAYER_GRADIENT
Same shape as linear: emit LAYER_GRADIENT with subtype=1 and a
gradient-params sub-blob. Radial just uses two param texels
(c0:x,y,r0 and c1:x,y,r1) before the stops instead of one.
Shader side: add _hb_gpu_sample_radial in all four languages.
Solves the COLRv1 two-circle radial quadratic
|P - C0 - t*(C1-C0)|^2 = (r0 + t*(r1-r0))^2 for t, picking the
larger root when the interpolated radius stays non-negative,
falling through to the smaller root otherwise, and degenerating to
a linear solve when the quadratic coefficient is near zero. Same
matching of hb_raster_paint's radial formulation.
Also extracted the color-stop walk (formerly inlined in
_hb_gpu_sample_linear) into _hb_gpu_eval_stops so both subtypes
share it; the per-subtype stops_base differs by one texel.
Sweep still uses the first-stop solid placeholder.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [gpu] hb_gpu_paint: normalize gradient color lines; add sweep
Gradient stops can arrive with offsets that don't span [0, 1] --
e.g. stops at 0.3 and 0.7 -- in which case REPEAT / REFLECT extend
modes would previously wrap over [0, 1] instead of over the stop
range. Match hb_raster_paint's normalize_color_line: sort stops
by offset, find (mn, mx), rescale offsets to [0, 1], and shift the
gradient geometry along its direction by mn..mx so the rendered
gradient position stays identical. Linear shifts axis endpoints,
radial shifts both centers and both radii, sweep shifts both
angles.
While there, implement real sweep gradient rendering. Encoder
emits LAYER_GRADIENT subtype=2 with a 1-texel param block
(cx, cy, start_q14, end_q14) -- angles stored as Q14 fractions of
pi (angles come in as radians; shader divides atan2 by pi before
comparing). All four shader languages grew _hb_gpu_sample_sweep.
The old hb_gpu_paint_gradient_first_stop fallback is gone now that
all three gradient subtypes are handled.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [gpu] hb_gpu_paint: implement PUSH_GROUP / POP_GROUP compositing
Register push_group/pop_group paint callbacks, emit 1-texel
PUSH_GROUP / POP_GROUP ops, and handle them in all four paint
fragment shaders.
Each shader keeps an HB_GPU_PAINT_GROUP_DEPTH (=4) stack of vec4
accumulators. PUSH_GROUP pushes the current `acc` and resets to
(0,0,0,0) so the enclosed subtree composites in isolation;
POP_GROUP pops the saved `acc` and composites the subtree result
into it using the mode stored in the op's aux slot (values match
hb_paint_composite_mode_t).
Implemented composite modes: CLEAR, SRC, DST, SRC_OVER (default),
DST_OVER, SRC_IN, DST_IN, SRC_OUT, DST_OUT, SRC_ATOP, DST_ATOP,
XOR, PLUS, SCREEN, DARKEN, LIGHTEN, MULTIPLY. The CSS/PDF
separable blend modes (OVERLAY, COLOR_DODGE, COLOR_BURN,
HARD_LIGHT, SOFT_LIGHT, DIFFERENCE, EXCLUSION) and all four HSL
modes fall back to SRC_OVER for now.
Noto-COLRv1 happens not to emit any PaintComposite nodes, so this
doesn't change rendering for that font; fonts that do use it
(e.g. test_glyphs-glyf_colr_1.ttf) will pick this up.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [gpu] hb_gpu_paint: honor COLRv1 paint transforms
Register push_transform / pop_transform callbacks and maintain a
current-affine stack (hb_transform_t<float>) on hb_gpu_paint_t.
Each push_transform multiplies the incoming matrix into the
current transform; pop_transform restores the previous one.
At each layer, the current transform is baked into the per-layer
data at encode time so the shader stays transform-unaware:
- Clip-glyph outlines: feed them through a transforming pen
(same pattern as VARC.cc's hb_transforming_pen_get_funcs) that
multiplies each move/line/quadratic/cubic point by the current
affine before forwarding to hb_gpu_draw's callbacks.
- Linear gradient: transform both axis endpoints.
- Radial gradient: transform the two centers, scale the two
radii by sqrt(|det|) (uniform-scale approximation; a non-
uniform scale turns the gradient circle into an ellipse which
the current shader does not model).
- Sweep gradient: transform the center, rotate both angles by
atan2(yx, xx) to pick up any rotation component.
Identity-transform layers (still the common case) use a fast path
that skips the transforming pen entirely. The pen keeps a
separate hb_draw_state_t for the downstream so transformed-space
state writes don't leak back into the caller's pre-transform
state; explicitly close any trailing open path on the downstream
state before returning.
Noto-COLRv1's "kissing face" glyph now renders with correctly
positioned small pink cheek blushes instead of a red overlay on
the whole face.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [gpu] hb_gpu_paint: transform clip outline at push_clip_glyph time
The outline of a PaintGlyph's clip is defined in the coord space
that was active when push_clip_glyph fires -- call it T_outer.
The paint subtree underneath can have its own PaintTransform
wrappers; when a gradient/color callback fires, cur_transform may
be deeper than T_outer. The previous code used cur_transform for
the clip outline too, which placed the clip at the WRONG position
when the child paint was wrapped in inner transforms (e.g. Noto-
COLRv1 emoji 🤣).
Snapshot cur_transform into pending_clip_transform at
push_clip_glyph time, and use that transform for the clip outline
in emit_clip_sub_blob. Gradient params keep using cur_transform
(the innermost composition) because HB dispatches their endpoints
in the innermost local space.
This matches what CPU raster already does implicitly (it paints
the clip into its current compositing surface using the transform
active at push_clip time, then rasterizes the child paint with
the deeper transform inside the same surface).
Fixes the "face split in two" glitch on 🤣 where the base face
stayed near the origin while the inner rotated features rendered
offset.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [util/gpu] Web demos: drop stale gamma-toggle hints
The `g` key was removed when we hardcoded gamma 2.2; the shell's
help overlay still mentioned it. Drop the lines.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [util/gpu] Apply stem darkening in Metal and D3D11 fragment shaders
demo-fragment.glsl (desktop GL/WebGL) and the WGSL shader in
hb-gpu-web-webgpu.cc already invoked hb_gpu_stem_darken on the
painted result; the Metal (fragment_main) and D3D11 (ps_main)
entry points were missing that block, so stem darkening did
nothing on those backends.
Add the same call: compute ppem from fwidth(texcoord), derive
brightness from the foreground luminance, and scale the
premultiplied result by darkened/c.a.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [gpu] Shaders: move Slug body to shared, rename _hb_gpu_draw_impl to _hb_gpu_slug
The Slug coverage algorithm (root-code math, band decode, single-
sample coverage, MSAA wrapper) and stem-darkening curve are useful
to both the draw renderer and the paint renderer. Until now they
lived inside hb-gpu-draw-fragment.{glsl,msl,hlsl,wgsl} and
hb-gpu-paint-fragment had to include the draw source to reach them,
even though the paint renderer doesn't need hb_gpu_draw itself.
Move everything except the thin fwidth wrapper into the already-
shared hb-gpu-fragment.{ext} helpers, and rename the MSAA-aware
entry point _hb_gpu_draw_impl -> _hb_gpu_slug since it's no longer
specific to the draw renderer. hb_gpu_draw is now a one-liner in
hb-gpu-draw-fragment that calls _hb_gpu_slug with pixelsPerEm
derived from fwidth at uniform control flow.
No functional change. bench --demo stays at ~1750fps.
Next step: demo dispatches to either the draw or paint shader
based on whether the font has any color paint, recovering the ~25%
perf gap for monochrome fonts while still exercising both paths
from the same binary.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [gpu] Fix missing closing brace in Metal fragment shader
_hb_gpu_slug in hb-gpu-fragment.msl was missing its closing
brace, so hb_gpu_stem_darken got parsed as a nested function
definition, which MSL rejects:
error: function definition is not allowed here
The other three shader languages already had the brace; this
regression was limited to the Metal source during the recent
refactor that moved the slug body to the shared fragment file.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [gpu] Regenerate hb-gpu-fragment-msl.hh
Regenerate from the .msl source after the missing closing brace
fix in
|
||
|
|
19aace663f |
[gpu] Fix blob leaks under failing-malloc in paint encoder
hb_vector_t::push(args) returns &Crap(Type) on allocation failure,
not nullptr -- Crap is a static pool slot, always non-null. So
`!vec.push(item)` is *always* false and the cleanup branch never
fires. Use push_or_fail(), which is a bool-returning wrapper that
checks against the Crap address properly.
Under failing-malloc the five affected call sites would:
- leak the clip sub-blob in emit_clip_sub_blob (and its 1.9KB
draw-encoded buffer + 32-byte data-wrapper)
- leak the gradient parameters sub-blob in the three
emit_{linear,radial,sweep}_gradient paths
- silently ignore the overflow in push_transform
The blob leaks reproduce cleanly on oss-fuzz/CIFuzz (2056 bytes
in 6 allocations on the reported crash). Confirmed by running the
gpu tests after the fix.
Assisted-by: Claude <noreply@anthropic.com>
|
||
|
|
ccb55d6009 |
[gpu] Factor layer coverage into _hb_gpu_layer_coverage helper
The LAYER_SOLID and LAYER_GRADIENT paths both walked the clip stack (1-3 slug evaluations) inline, so the coverage logic was duplicated across six call sites in each of GLSL, MSL, HLSL, and WGSL. Hoist that walk into a single helper used by both ops. Same behavior; cleaner surface; single place to edit if the clip mask logic changes. Assisted-by: Claude <noreply@anthropic.com> |
||
|
|
7c7b1756c1 |
[gpu] Support 3 nested glyph clips per layer
Replace the single-slot pending_clip / pending_clip_glyph / pending_clip_font / pending_clip_transform fields with a stack of up to HB_GPU_PAINT_MAX_CLIP_DEPTH (3) clips. push_clip_glyph appends; pop_clip pops; depth > 3 sets `unsupported`. LAYER_SOLID and LAYER_GRADIENT ops grow from 2 to 3 texels: texel 0: (op_type, flags, clip1_hi, clip1_lo) texel 1: (clip2_hi, clip2_lo, clip3_hi, clip3_lo) texel 2: color (SOLID) or grad meta (GRADIENT) The existing flags slot (i16) gains: bit 0 IS_FOREGROUND (SOLID only -- was already there) bit 8 HAS_CLIP2 (new) bit 9 HAS_CLIP3 (new) For GRADIENT the gradient subtype lives in bits 0..7. Shader: nest the HAS_CLIP2 / HAS_CLIP3 checks (HAS_CLIP3 implies HAS_CLIP2) so single-clip layers pay only one branch, two-clip layers pay one extra slug call, three-clip layers pay two extra. On Noto-COLRv1 the bench is unchanged (~320 fps with the emoji text the user benches against), within noise of the depth-1 baseline -- the extra branches don't fire on most layers. Ports across all four shader languages (GLSL, MSL, HLSL, WGSL). NEWS: limitation entry updated to "up to 3 levels are intersected exactly; deeper nests set unsupported". Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
f6cd414c9f |
[gpu] Add hb_gpu_paint_set_scale / _get_scale
Mirror the draw API. hb_gpu_paint_t already had x_scale / y_scale fields and hb_gpu_paint_glyph() set them directly, but no public setter / getter -- callers that want to use the paint funcs without going through paint_glyph had no way to wire the scale. Add the public setters / getters and route paint_glyph through them, matching hb_gpu_draw_glyph's pattern. Document on both draw and paint that the convenience wrappers call _set_scale. Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
8403dce620 |
[gpu] hb_gpu_paint_glyph: fix docstring
Two errors: - We use hb_font_paint_glyph (not _or_fail) so non-color glyphs go through the synthesized-foreground fallback, which the body's comment already explains. - The return is the encoder-supported flag (!paint->unsupported), not "has color paint data". Monochrome glyphs return true; the return is false only when paint walk hit a feature the encoder doesn't represent (PaintImage, group-stack overflow, ...). Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
a01bd008ad |
[gpu] paint_encode: empty-blob singleton for "no ink" (match draw)
hb_gpu_draw_encode already returns the empty-blob singleton (not
NULL) when the encoder has accumulated no curves -- the convention
is "NULL = encoder failed, empty blob = nothing to render".
Make hb_gpu_paint_encode follow the same shape:
- NULL -> hard failure (paint_glyph hit an unsupported feature
or allocation failed).
- empty -> no ink (e.g. space glyph or paint tree that produced
no layer ops).
Document on both encode functions, and update the tests to expect
empty (not NULL) for the no-ink path.
The demo already short-circuits on length 0 (no atlas upload) and
_hb_gpu_blob_recycle drops the empty singleton instead of stashing
it, so nothing downstream needs to change.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
||
|
|
b38c5189df |
[gpu] Detect paint-encoder limits, fail rather than misrender
Paint encoder used to push past several limits and produce a blob that wraps an int16, overflows the shader's group stack, or skips unsupported callbacks entirely. Detect each: - num_ops > 32767 (the i16 blob header field's range): set paint->unsupported in every emit path. - group depth > HB_GPU_PAINT_MAX_GROUP_DEPTH (4 -- matches the fragment shader's HB_GPU_PAINT_GROUP_DEPTH): set unsupported in push_group; mirror the symmetric pop guard. - PaintImage: register an `image` callback that sets unsupported (the slug+gradient encoder can't represent raster images). push_clip_rectangle is intentionally NOT trapped -- the encoder silently ignores it; rendered output is wider than the rectangle asks but doesn't fail. Nested PaintGlyph clips still silently override the outer clip (only depth 1 is faithfully stored); follow-up commit will lift this to depth 2. Document all of the above in NEWS, and relax the COLR test to tolerate a font where every glyph trips one of these limits. Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
24e1bde6f2 |
[gpu] Name composite modes; approximate unsupported ones
a) Add inline /* MODE_NAME */ comments next to each mode == N
branch in all four paint-shader languages. The numbers were
bare hb_paint_composite_mode_t values; the comments match.
b) Approximate unsupported modes with the nearest Porter-Duff
mode rather than silently SRC_OVER'ing them:
OVERLAY (14) / COLOR_BURN (18) / HARD_LIGHT (19) -> MULTIPLY
COLOR_DODGE (17) / SOFT_LIGHT (20) -> SCREEN
DIFFERENCE (21), EXCLUSION (22) and HSL_HUE..HSL_LUMINOSITY
(24-27) still fall through to SRC_OVER -- they're not similar
enough to anything we have to be worth a misleading
approximation.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
||
|
|
228e1792ac |
[gpu] Move encoder cleanup out of dtors, into _destroy
LSan flagged sub_blobs and recycled_blob leaks under failing-malloc in hb_gpu_paint and hb_gpu_draw. Both structs relied on a C++ destructor invoked indirectly via hb_object_actually_destroy() to free their nested resources -- the same pattern that fooled me into not noticing the path is fragile. Match the established harfbuzz convention (hb_raster_paint_destroy, hb_face_destroy, ...): drop the destructors, call hb_object_should_destroy() to take ownership of the dec, do the nested-resource cleanup explicitly, then hb_object_actually_destroy + hb_free. Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
52b97c7f79 |
[gpu] Share blob-recycling between draw and paint encoders
hb_gpu_draw already recycled its output blob: hand the blob back via hb_gpu_draw_recycle_blob() and the next hb_gpu_draw_encode() reused the underlying buffer (and even returned the same blob handle), avoiding malloc / blob allocation traffic in the glyph-by-glyph loop. Paint had a recycled_blob field but its recycle_blob entry point just hb_blob_destroy()'d the input. Lift the recycle machinery out of hb-gpu-draw.cc into a small set of helpers (_hb_gpu_blob_acquire / _finalize / _abort / _recycle) that live in hb-gpu.cc, declared in a new internal header hb-gpu.hh, and share the destroy-callback identity between both encoders. Both paint and draw now reuse the same buffer pool semantics. Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
d235a23b45 |
[test/api] Silence cast-align in test-gpu blob accessors
Casting hb_blob_get_data()'s const char* to a struct pointer trips clang's -Wcast-align (1-byte to 2-byte short). In practice the blob's underlying buffer is malloc'd and so suitably aligned for any standard type; suppress the warning around the cast with the same #pragma GCC diagnostic ignored "-Wcast-align" pattern used elsewhere in the codebase (hb-bit-set.hh, hb-machinery.hh). Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |