Commit Graph
48 Commits
Author SHA1 Message Date
Behdad Esfahbod 472c3e0fd3 [draw] Add rendering work-budget API
Expose budget policy and remaining-work callbacks on draw and paint function
objects.  The public setters clamp invalid negative caps, distinguish finite
defaults from explicit unlimited operation, and report whether a backend
participates in accounting.

Let draw sessions borrow the live counter owned by draw_data.  OpenType glyf
and CFF traversal then debit the same counter in place, while unsupported
backends retain a finite per-glyph fallback.  Forward budget access through
the parent-font draw adaptor.

Document the new API and cover nil, default, unlimited, clamped, concrete,
and live-depletion behavior.

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

Assisted-by: OpenAI Codex <codex@openai.com>
2026-08-26 17:11:21 -06:00
Nussu06 9de7e9d563 [paint] pass color_glyph its own user_data
The dispatch wrapper handed the callback user_data->push_clip_glyph
instead of user_data->color_glyph, so a client registering both
callbacks with different contexts got the wrong pointer on every
COLR glyph.
2026-07-17 11:43:34 -06:00
Khaled Hosny b4ed968183 [test/paint] Test the fill_path callback 2026-07-12 19:36:15 +03:00
Behdad Esfahbod 788706d568 [test] Normalize linear paint transcripts
Reduce linear gradient anchors and normalize color lines before
printing them in test-paint. This makes the transcript reflect the
renderer-facing gradient geometry instead of backend-specific raw
COLRv1 anchors and stop ranges.

Also normalize signed zero in transform output so the fixtures stay
stable across backends.

Testing:
CCACHE_DISABLE=1 meson test -C build test-paint --print-errorlogs

Assisted-by: OpenAI Codex
2026-05-27 12:40:44 +02:00
Behdad EsfahbodandClaude Opus 4.6 f3c36ef3d6 [test] Add API tests for push_clip_path_start/_end
Folded into the existing test-paint binary.  Two tests,
both font-independent (registered ahead of the glyph-based
flavor setup so they run even on builds without the test
COLRv1 font):

* test_push_clip_path_nil_returns_null: an unset paint-funcs
  table returns NULL from push_clip_path_start and clears
  the out-param draw_data, and push_clip_path_end is safe
  to call on the nil stub.

* test_push_clip_path_round_trip: registered start/end fire
  in order, the returned draw-funcs + draw-data round-trip
  through the public entry points, and every hb_draw_*()
  call reaches the sink accumulator.  Asserts the count
  includes hb_draw_close_path's synthetic back-to-start
  line_to so the contract is documented by the test.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 16:18:20 -06:00
Behdad Esfahbod 469502c99b [test-paint] Test fontations too
Luckily it passes!
2025-03-12 11:02:43 -06:00
Matthias Clasen 0ce90f60ab [test-paint] Make it easier to regenerate test output
This command will regenerate the expected output for all the
paint tests:

GENERATE_DATA=1 G_TEST_SRCDIR=./test/api ./build/test/api/test-paint
2025-03-06 20:10:13 -05:00
Behdad Esfahbod 9d149c5284 [test-paint] Redirect generated output to stderr 2025-02-26 15:07:46 -07:00
Behdad Esfahbod 753093d60e [test-colrv1] Add test files from https://roettsch.es/var_colrv1.html
These are not currently used for any testing. To be used later.
2025-02-26 14:41:04 -07:00
Behdad Esfahbod 6fe1441782 [test-paint] Update comment 2025-02-26 14:40:08 -07:00
Behdad Esfahbod 755929c48d Fix more compiler warnings
In case FreeType is not available.
2024-10-12 20:08:32 -06:00
Behdad Esfahbod 22e1a5a785 [test-paint] Fix warnings 2024-08-06 12:20:34 -06:00
Behdad Esfahbod 7d7541e35d [test-paint] Print paint-color-glyph 2023-08-14 17:55:09 -06:00
Behdad Esfahbod 58effbcc4f . 2023-08-14 16:47:36 -06:00
Behdad Esfahbod 474b99d122 [test-paint] Fix build without FreeType
Fixes https://github.com/harfbuzz/harfbuzz/issues/4103
2023-02-04 10:16:11 -07:00
Behdad Esfahbod e377888990 [ft-colr] Conditionalize on (unreleased0 FreeType 2.13.0
That's the version that the color API is called stable, and
includes changes that we rely on.
2023-01-26 13:27:55 -07:00
Khaled Hosny c08e5d094a [hb-draw] Fix MSVC warning
warning C4305: 'initializing': truncation from 'double' to 'float'
2023-01-21 15:27:56 +02:00
Behdad Esfahbod c86bab3fb4 [test-paint] Use G_GNUC_PRINTF 2023-01-17 06:29:17 -07:00
Behdad Esfahbod f02c4ebb40 [test-paint] Adjust condition for enabling ft backend 2023-01-16 14:17:44 -07:00
Behdad Esfahbod 60a4f2e6f5 [test-paint] Detect FreeType COLRv1 from struct size 2023-01-12 19:12:46 -07:00
Behdad Esfahbod b783967242 [test] Minor save glyph_count 2023-01-12 19:11:10 -07:00
Matthias Clasen cca0ed9bcd test-paint: Add variable font tests
These needs freetype master to work.
2023-01-12 21:09:50 -05:00
Matthias Clasen 1cb5a87feb test-pain: Print out extend for color lines
Update all expected results to include this value.
2023-01-10 22:13:44 -05:00
Matthias Clasen 6648e6e3e5 Add one more paint test
Add a test for the clip_box_top_left_glyph,
since we've seen broken rendering with it.
2023-01-10 22:07:44 -05:00
Matthias Clasen b20871322f test-paint: Fix use of g_test_skip 2023-01-09 16:30:42 -05:00
Matthias Clasen eb0f0279d2 test-paint: Avoid g_test_skip_printf
This is relatively recent api we don't need.
2023-01-09 15:33:34 -05:00
Matthias Clasen e61c2be41c test-paint: Skip tests if ft COLRv1 is missing 2023-01-09 15:25:29 -05:00
Matthias Clasen 1d662632d9 test-paint: More output for failures 2023-01-09 15:01:59 -05:00
Matthias Clasen d0108d31a2 Add more paint tests
These tests compare the output of the ft and ot
implementations for all the glyphs in the test_glyphs
font.
2023-01-09 14:42:30 -05:00
Matthias Clasen 5f976d86a7 test-paint: Use %.3g for results
This produces more readable output.
2023-01-09 14:24:32 -05:00
Matthias Clasen a085efa699 test-paint: Fix font setup for ft
We must call hb_ft_font_set_funcs after
setting the font scale.
2023-01-09 13:11:16 -05:00
Matthias Clasen 26f713a7f5 paint-test: Use larger scales
A scale of 20 is noise, so use 1000.
2023-01-09 12:54:06 -05:00
Matthias Clasen 42047070dd test-paint: More helpful output
No need to print ASCII chars as hex.
2023-01-08 16:08:16 -05:00
Behdad Esfahbod 3fd6c0d97a [test-paint] Remove unused FT_Library 2023-01-08 12:30:26 -07:00
Behdad Esfahbod 28be4f8805 [test-paint] Actually run against hb-ft 2023-01-08 12:19:41 -07:00
Matthias Clasen ed7d0234e1 test-paint: Limit the precision of clip boxes
Update expected test results.
2023-01-08 11:57:43 -07:00
Matthias Clasen f3ce137420 test-paint: Be more flexible for expected results
When generating the expected output with GENERATE_DATA=1,
Glib's test framework puts out some comments at the top
of the file. Ignore them when comparing the expected
output. This makes it possible to directly use the output
of

GENERATE_DATA=1 ./test-paint -p TESTCASE

as expected result for TESTCASE.
2023-01-08 09:01:31 -05:00
Matthias Clasen 2a51567925 [paint] Add a test for recursion 2022-12-26 17:00:20 -07:00
Matthias Clasen 1eb4d002f2 Try to fix the build with msvc 2022-12-26 11:29:26 -07:00
Behdad Esfahbod 6ccbfabd4f [paint] Return bool from paint_image()
Fixes https://github.com/harfbuzz/harfbuzz/issues/3974
2022-12-24 10:44:25 -07:00
Matthias Clasen 3478728edb Fix test-paint build without freetype 2022-12-24 09:16:29 -05:00
Matthias Clasen 9b9d7c7b8e Plug a memory lek in paint tests 2022-12-24 05:34:47 -05:00
Matthias Clasen 55b7af6b62 Tweak paint-tests 2022-12-23 18:34:09 -05:00
Matthias Clasen 44b48845b7 Add tests for hb_color_line_t
Test a few things that were broken with the
ft implementation before.
2022-12-23 16:28:53 -05:00
Behdad Esfahbod a4a86c0ec2 [test-paint] g_test_message 2022-12-23 13:52:22 -07:00
Behdad Esfahbod dcab567988 [test-paint] Don't use g_test_fail_print() for older glib 2022-12-23 13:47:37 -07:00
Matthias Clasen 3b021c5568 Run paint tests with ft font funcs 2022-12-23 13:37:59 -07:00
Matthias Clasen ca190aaba4 Split off the hb-paint tests
They belong in their own file.
2022-12-23 13:37:59 -07:00