Commit Graph
25 Commits
Author SHA1 Message Date
Behdad Esfahbod a1fa46cbde [limits] Streamline work-budget spending
Keep the hot spend primitive always-inline and branch-free.  Budget costs
and multipliers are unsigned and structurally bounded by their callers, so
the primitive only needs to debit the live counter and report exhaustion.

Move hb-limits.hh alongside the shared internal headers, after the paired
inline/noinline attribute definitions it now depends on.

Tests: meson test -C build (272/272 passed)

Assisted-by: OpenAI Codex <codex@openai.com>
2026-08-26 17:09:22 -06:00
Behdad Esfahbod 074b486d21 [limits] Add weighted outline work accounting
COLR can repeatedly request expensive glyf or CFF outlines, multiplying
their per-glyph structural limits.  Make both outline implementations
consume a caller-provided weighted budget so a later paint-session
counter can aggregate that work.

Add checked precharge arithmetic with stable exhaustion, charge glyf
loads, terminal points, and gvar tuples, and charge CFF operators,
subroutine calls, CFF2 blends, and both CFF1 seac outlines.  Keep a
generous local fallback for callers that do not yet provide a session
budget.

Tests: meson test -C build

Assisted-by: Codex <codex@openai.com>
2026-08-26 16:34:38 -06:00
Behdad Esfahbod 8ff823adce [algs] Add a signed integer clamp helper
Provide an always-inline int64_t overload of hb_clamp_to for cold
position formulas that need wider intermediate arithmetic while
preserving integer division and rounding semantics.

Add boundary tests. This supports the complete position-overflow fix
for issue #6151.

Testing: meson test -C build --print-errorlogs

Assisted-by: Codex <codex@openai.com>
2026-08-12 17:38:49 -06:00
Behdad Esfahbod 291b7ef1e0 [algs] Complete signed saturation helpers
Add an always-inline saturating negation for position values that can
reach INT_MIN. Also require the floating-point clamp helper to inline,
matching the add and subtract helpers used throughout shaping.

Extend the boundary tests for both helpers. This supports the complete
position-overflow fix for issue #6151.

Testing: meson test -C build --print-errorlogs

Assisted-by: Codex <codex@openai.com>
2026-08-12 17:23:05 -06:00
Behdad Esfahbod 764d42cc64 [algs] Add fast signed saturating arithmetic
Provide always-inline signed add and subtract helpers for position
arithmetic. Compiler overflow builtins reduce the common path to one
arithmetic instruction and a not-taken overflow branch.

This is the foundation for fixing the position overflow reported in
issue #6151.

Assisted-by: Codex <codex@openai.com>
2026-08-12 17:12:35 -06:00
Behdad Esfahbod 75f919876f [src/test-*] Use hb_always_assert() which isn't compiled out under NDEBUG
Part of https://github.com/harfbuzz/harfbuzz/issues/5418
2025-07-25 03:00:38 -06:00
Behdad Esfahbod f3a8b7f36b [algs] Test hb_hash() 2022-06-03 02:21:46 -06:00
Behdad Esfahbod c484641304 Revert "[vector] Add initializer_list constructor & tests"
This reverts commit aa6182453b.
2021-11-01 18:48:24 -06:00
Behdad Esfahbod aa6182453b [vector] Add initializer_list constructor & tests 2021-11-01 18:36:57 -06:00
Behdad Esfahbod 3bc86fb237 [algs] Fix hb_inc/dec signature 2019-08-31 12:24:56 -05:00
Behdad Esfahbod 6f51e55524 [algs] Rename hb_bind to hb_partial
Since our API is the invers of what std::bind is, and closer to Python
functools.partial().
2019-05-15 21:41:12 -07:00
Behdad Esfahbod 0888e7bc86 [algs] Change hb_bind parameter number to be from one
To match std:;bind, even though our interfaces are very different.
2019-05-15 21:36:42 -07:00
Behdad Esfahbod a06a236891 [algs] Partialize all operators 2019-05-15 21:16:09 -07:00
Behdad Esfahbod edc69ec935 [algs] Rewrite bind API
And add a partialization API use example to hb_add()
2019-05-15 21:09:56 -07:00
Behdad Esfahbod 16a3540ea4 [algs] Add hb_bind0 and hb_bind1 2019-05-15 20:48:20 -07:00
Behdad Esfahbod 243a5a6af2 [algs] Remove pair copy constructor
Use default.
2019-05-15 19:04:24 -07:00
Behdad Esfahbod 5266ca86b6 Fix tests
Oops.
2019-05-15 17:59:00 -07:00
Behdad Esfahbod 790315e0db [algs] Implement implicit casting between compatible pair types 2019-05-09 15:31:24 -07:00
Behdad Esfahbod 2c7093ed01 More tests 2019-05-07 23:10:59 -07:00
Behdad Esfahbod 6fa1f38070 [algs] Accept varargs in hb_min/max 2019-05-07 21:33:26 -07:00
Behdad Esfahbod 0268db1196 [map] Use hb_invoke() with pointer-to-method 2019-04-24 10:53:39 -04:00
Behdad Esfahbod 12017db0bf Move test code around 2019-04-24 09:24:38 -04:00
Behdad Esfahbod 1558a43342 [test] Minor 2019-02-14 20:46:13 -08:00
Behdad Esfahbod fa373584de [algs] Test pair more 2019-02-14 20:15:07 -08:00
Behdad Esfahbod 0d7af5fb02 [algs] Use universal references for hb_pair()
Such that it carries lvalues inside.
2019-02-14 19:37:57 -08:00