Files
harfbuzz/test/api
Behdad EsfahbodandArthur031221 f20f4c20bc [raster] Fix background color and stride handling (#6310)
* [raster] Fix background color premultiplication and stride handling

ensure_initialized()'s background fill had two bugs:

1. The background pixel was built with HB_COLOR(blue, green, red,
   alpha), which packs channels through HB_TAG's bit layout
   (b<<24 | g<<16 | r<<8 | a). Every other pixel in this buffer is
   premultiplied BGRA32 (b | g<<8 | r<<16 | a<<24, see hb-raster.hh's
   SRC_OVER comment: "premultiplied src over premultiplied dst"), so
   the background was both unpremultiplied and in the wrong byte
   positions: a half-transparent red background (blue=0, green=0,
   red=255, alpha=128) filled the buffer with 0x0000ff80 instead of
   the correct premultiplied 0x80800000.

2. The fill then wrote that pixel into a contiguous run of
   width * height uint32_t slots starting at the buffer origin,
   assuming every row is packed at exactly width * 4 bytes. Once a
   caller sets a stride wider than that (row padding, alignment,
   embedding the glyph image inside a larger atlas), the fill drifts
   across row boundaries after the first row, leaving later rows
   partially uninitialized or wrongly colored.

Build bg with color_to_premul_pixel(), the same helper solid fills
already use, and fill row by row using the actual stride.

Added two regression tests in test/api/test-raster.cc:
test_background_premultiplied (default stride, half-alpha background,
checks the stored pixel is premultiplied) and test_background_stride
(stride much wider than width * 4, opaque background, checks every
row).

Assisted-by: Claude

* [raster] Handle unaligned background strides

A caller-supplied stride does not have to be word-aligned, so casting
each row to uint32_t * can perform misaligned stores.

Use hb_packed_t<uint32_t> for the row writes, and exercise an odd
stride in the regression test with byte-wise pixel checks.

Tests: meson test -C build

Assisted-by: Codex <noreply@openai.com>

---------

Co-authored-by: Arthur031221 <levi74108520963@gmail.com>
2026-10-01 20:11:49 -06:00
..
2025-04-06 18:08:50 -06:00
2026-07-30 19:02:25 -06:00
2026-08-25 14:47:33 -06:00
2026-09-04 14:14:49 -06:00
2026-07-31 04:31:26 +03:00
2025-04-05 22:37:10 -06:00
2020-01-31 16:37:30 -05:00
2020-01-29 10:21:00 -05:00
2020-01-15 13:36:01 -08:00
2025-06-08 13:43:27 +03:00