Commit Graph
6 Commits
Author SHA1 Message Date
Behdad Esfahbod 4650398a07 [gpu] encode() returns extents + auto-clears; drop get_extents() (#5910)
Bring hb_gpu_draw_encode into line with the rest of the render APIs:
auto-clear on success, and return the computed glyph extents to the
caller via a new out-parameter (nullable).

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

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

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

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

All 240 tests pass.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 00:15:54 -06:00
Behdad EsfahbodandClaude Opus 4.6 ba772af6f8 [gpu] Add -n iterations flag to hb-gpu-encode-all
Useful for profiling — run the encode loop multiple times
and report averaged timing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 14:21:05 -06:00
Behdad EsfahbodandClaude Opus 4.6 0b9f632f44 [gpu] Add timing to hb-gpu-encode-all
Report outline, encode, and wall time with per-glyph rates.
Also restore max blob size reporting.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 14:12:09 -06:00
Behdad EsfahbodandClaude Opus 4.6 686f3caa86 [gpu] Implement blob recycling in encode
recycle_blob stores the blob; encode reuses both the blob object
and its data buffer when the buffer is >= needed and < 2x needed.
Otherwise malloc fresh and replace_buffer on the recycled blob.

hb_blob_t::replace_buffer now skips destroy_user_data when the
new data pointer is the same as the old one (same-buffer reuse).

Add explicit destructor to hb_gpu_draw_t for recycled_blob cleanup.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 15:13:44 -06:00
Behdad EsfahbodandClaude Opus 4.6 6d355dddce [gpu] Report sizes in KiB in hb-gpu-encode-all
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 14:31:36 -06:00
Behdad EsfahbodandClaude Opus 4.6 198dc300d0 [gpu] Add hb-gpu-encode-all utility
Encodes all glyphs in a font, reports failures and summary
statistics (encoded/empty/failed counts, total and average sizes).

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