[raster] Crop paint masks to their visible destination

A paint mask can extend far beyond its destination. Auto-sizing the
mask before imposing the raster dimension cap wastes pixel work and
can discard the visible part of an oversized outline altogether.

Intersect auto-sized masks with the destination clip box before the
dimension cap, and use those clipped dimensions for work accounting.
Widen the extent subtraction to cover disjoint bounds safely.

Add a regression for an oversized outline enclosing a small surface,
and update the sweep test to expect successful one-pixel clipping.
The standalone tall-edge sweep still verifies budget exhaustion.

Tested with the full configured Meson suite and the Bitcount Ink audit.
The worst measured 256 px pixel work falls from 6.84B to 152M units.

Assisted-by: Codex (OpenAI)
This commit is contained in:
Behdad Esfahbod committed 2026-11-12 18:11:03 -06:00
1 parent f6b7a4cb72
commit 3bb72a7b4c
3 files changed
+49 -3

No files matched your search

+2 -1
View File
@@ -804,7 +804,8 @@ test_budget_sweep (void)
hb_paint_pop_clip (funcs, paint);
img = hb_raster_paint_render (paint);
g_assert_nonnull (img);
g_assert_cmpuint (hb_raster_image_get_buffer (img)[3], ==, 0);
/* Paint masks crop the same edges to the visible one-pixel surface. */
g_assert_cmpuint (hb_raster_image_get_buffer (img)[3], ==, 255);
hb_raster_image_destroy (img);
hb_raster_paint_destroy (paint);
}