Behdad Esfahbod and Arthur031221
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
..
2026-09-21 11:02:29 -06:00
2026-09-06 12:55:21 -06:00
2026-09-21 12:15:48 -06:00
2026-09-09 12:15:31 -06:00
2026-08-12 18:27:23 -06:00
2025-03-07 18:19:29 -07:00
2026-05-17 15:24:40 -06:00
2026-03-10 09:56:47 -03:00
2025-05-06 13:17:13 +03:00
2025-05-06 13:17:13 +03:00
2025-05-06 13:17:13 +03:00
2025-05-06 13:17:13 +03:00
2026-03-09 22:37:07 -06:00
2025-07-30 01:19:29 +03:00
2025-05-06 13:17:13 +03:00
2026-06-05 15:09:12 -07:00
2024-03-30 02:20:21 +02:00
2026-08-24 19:00:33 -06:00
2026-08-25 09:17:04 -06:00
2026-07-30 11:12:48 -06:00
2026-03-03 05:38:25 -03:00
2026-04-28 13:59:28 -06:00
2026-03-28 02:57:56 -06:00
2025-11-14 14:39:52 +02:00
2026-04-18 19:54:27 -06:00
2026-03-27 23:37:52 -06:00
2026-09-30 15:59:36 -06:00
2025-08-15 00:54:52 -06:00
2026-09-06 12:55:21 -06:00
2026-03-03 06:18:08 -03:00
2023-11-30 16:31:44 +08:00
2026-06-11 13:48:12 +02:00
2026-03-28 16:08:37 -06:00
2026-03-13 01:21:13 +02:00
2026-07-31 04:31:26 +03:00
2026-03-13 01:21:13 +02:00
2026-08-25 15:17:00 -06:00
2026-04-28 15:52:29 +03:00
2026-07-31 04:31:26 +03:00
2023-11-04 15:21:47 -06:00
2026-07-27 19:20:18 -06:00
2026-08-22 22:24:44 -06:00
2026-07-08 00:28:35 -06:00
2024-09-23 08:02:25 -06:00
2026-08-22 22:24:44 -06:00
2026-08-22 22:24:44 -06:00
2024-09-23 08:02:25 -06:00
2026-08-12 17:31:45 -06:00
2026-07-08 01:12:27 -06:00
2025-03-27 15:37:01 -06:00
2025-03-27 14:44:52 -06:00
2023-11-04 15:21:47 -06:00
2025-03-13 01:07:35 -06:00
2023-01-12 10:44:08 -07:00
2026-08-21 15:07:28 -06:00
2025-10-17 15:23:05 -06:00
2026-05-02 11:45:28 -06:00
2026-02-24 16:57:44 -03:00
2026-03-26 15:15:56 -06:00
2026-08-25 16:40:28 +05:30
2026-08-20 04:04:54 -06:00
2026-08-27 15:10:38 -06:00
2025-03-12 23:56:52 -06:00
2026-06-17 02:04:23 -06:00
2023-02-21 18:07:53 +02:00
2026-04-20 01:29:49 +02:00
2026-03-27 19:59:03 -06:00
2025-04-04 16:17:32 -06:00
2026-03-27 19:59:03 -06:00
2025-04-04 16:17:32 -06:00
2026-03-27 19:59:03 -06:00
2025-03-10 16:20:16 -06:00
2026-08-12 18:14:57 -06:00
2026-07-26 17:05:29 -06:00
2026-08-20 18:10:34 -06:00
2026-03-04 09:16:54 -07:00
2026-09-03 22:30:40 -06:00
2025-12-20 17:08:48 -07:00
2026-07-26 11:19:11 -06:00
2026-08-26 18:34:31 -06:00
2026-08-26 17:51:34 -06:00
2026-02-22 00:20:31 -03:00
2023-01-06 11:01:25 -07:00
2026-08-26 16:34:38 -06:00
2026-07-03 22:52:44 -06:00
2026-08-27 16:34:19 -06:00
2024-08-14 10:19:40 -07:00
2026-03-26 15:15:56 -06:00
2026-02-17 13:42:08 -07:00
2026-08-31 11:54:42 -06:00
2026-09-21 00:41:07 +03:00
2026-07-31 04:31:26 +03:00
2026-09-10 14:54:07 -06:00
2026-09-10 14:54:07 -06:00
2026-09-10 14:54:07 -06:00
2025-03-11 11:56:00 -06:00
2026-09-10 14:54:07 -06:00
2026-04-13 00:38:40 -06:00
2026-06-05 15:09:11 -07:00
2025-02-28 01:13:25 -07:00
2026-09-10 12:11:13 -06:00
2026-09-10 12:11:13 -06:00
2026-06-05 15:09:13 -07:00
2025-07-20 21:08:56 +03:00
2026-08-17 15:13:59 -06:00
2026-09-10 16:12:36 -06:00
2026-08-13 19:32:24 -06:00
2025-03-22 16:02:39 -06:00
2026-08-13 19:55:11 -06:00
2026-09-21 00:41:07 +03:00
2026-09-21 00:41:07 +03:00
2026-08-26 17:11:21 -06:00
2026-07-08 00:53:56 -06:00
2026-07-08 01:12:27 -06:00
2026-07-08 01:12:27 -06:00
2025-03-12 18:27:27 -06:00
2026-03-28 03:02:07 -06:00
2026-08-26 17:11:21 -06:00
2025-07-20 21:40:37 +03:00
2026-09-30 13:04:22 -06:00
2025-03-24 00:33:53 +02:00
2025-09-15 23:56:25 -06:00
2026-07-30 15:45:35 -06:00
2026-10-01 13:33:09 -06:00
2025-03-11 11:56:00 -06:00
2026-04-12 20:09:44 -06:00
2026-04-09 23:21:05 -06:00
2025-07-02 20:14:51 +03:00
2025-07-02 20:14:51 +03:00
2026-07-10 01:59:59 -06:00
2025-07-02 20:14:51 +03:00
2023-01-11 13:41:44 -07:00
2026-03-26 19:09:40 -06:00
2026-04-13 23:41:26 -06:00
2026-04-13 23:41:26 -06:00
2026-04-13 23:41:26 -06:00
2026-04-13 23:41:26 -06:00
2026-04-13 23:41:26 -06:00
2026-04-13 23:41:26 -06:00
2026-04-13 23:41:26 -06:00
2026-04-13 23:41:26 -06:00
2026-08-27 17:00:41 -06:00
2026-08-27 17:00:41 -06:00
2026-08-04 23:08:39 -06:00
2026-08-04 23:08:39 -06:00
2026-08-04 23:08:39 -06:00
2026-08-04 23:08:39 -06:00
2026-08-04 23:08:39 -06:00
2026-08-04 23:08:39 -06:00
2026-08-04 23:08:39 -06:00
2026-08-04 23:08:39 -06:00
2026-04-17 14:09:34 -06:00
2026-04-23 03:18:15 -06:00
2026-04-17 14:09:34 -06:00
2026-04-17 14:09:34 -06:00
2026-04-17 14:09:34 -06:00
2026-04-23 03:18:15 -06:00
2026-04-17 14:09:34 -06:00
2026-04-17 14:09:34 -06:00
2026-09-30 17:17:40 -06:00
2026-09-30 17:17:40 -06:00
2026-04-13 12:10:23 -06:00
2026-04-13 12:10:23 -06:00
2026-04-13 12:10:23 -06:00
2026-04-13 12:10:23 -06:00
2026-04-13 12:10:23 -06:00
2026-04-13 12:10:23 -06:00
2026-04-13 12:10:23 -06:00
2026-04-13 12:10:23 -06:00
2026-04-20 05:10:48 +02:00
2026-04-20 05:10:48 +02:00
2026-09-15 21:16:07 -06:00
2022-12-19 00:59:50 +02:00
2026-08-23 22:42:03 -06:00
2024-10-27 16:14:53 -07:00
2026-08-19 11:29:37 -06:00
2026-01-01 21:01:30 -07:00
2026-08-12 17:29:53 -06:00
2026-09-30 17:17:40 -06:00
2026-04-13 11:01:19 -06:00
2023-08-25 07:51:05 -06:00
2023-06-03 14:56:47 -06:00
2026-08-18 15:41:54 -06:00
2023-06-03 15:48:54 -06:00
2026-03-26 15:15:56 -06:00
2023-06-25 18:14:56 -06:00
2025-04-08 01:58:10 -06:00
2024-12-02 14:55:50 -07:00
2026-03-27 19:59:03 -06:00
2026-04-15 05:14:50 -06:00
2026-03-10 01:04:11 -03:00
2026-07-27 19:20:18 -06:00
2026-09-07 12:10:33 -06:00
2025-08-07 22:38:58 -06:00
2026-08-26 16:34:38 -06:00
2026-08-19 13:11:20 -06:00
2026-08-26 16:34:38 -06:00
2026-08-26 16:34:38 -06:00
2026-05-18 15:11:34 -06:00
2026-09-29 17:11:17 -06:00
2026-03-10 00:19:39 -06:00
2026-02-24 16:39:39 -03:00
2022-12-19 00:59:50 +02:00
2026-03-10 00:19:39 -06:00
2025-03-03 02:17:13 -07:00
2026-07-31 17:49:40 +03:00
2026-07-31 17:49:40 +03:00
2026-09-06 16:36:58 -06:00
2026-05-18 15:11:34 -06:00
2026-07-31 04:31:26 +03:00
2023-11-04 15:21:47 -06:00
2026-07-03 18:57:00 -06:00
2026-07-30 15:59:54 -06:00
2026-09-03 14:23:05 -06:00
2026-09-29 18:09:44 -06:00
2023-01-28 12:09:45 -07:00
2025-08-20 00:06:00 -06:00
2026-08-20 02:33:15 -06:00
2026-09-05 14:44:39 -06:00
2023-11-04 15:21:47 -06:00
2026-09-17 00:37:58 +03:00
2025-09-30 13:31:04 -06:00
2026-09-03 22:31:42 -06:00
2025-02-14 21:54:30 +02:00
2025-02-14 21:54:30 +02:00
2026-08-12 18:59:45 -06:00
2026-07-08 01:12:27 -06:00
2026-07-03 18:57:00 -06:00
2026-07-08 00:28:35 -06:00
2026-07-08 01:12:27 -06:00
2026-08-12 18:55:03 -06:00
2023-01-28 12:09:45 -07:00
2023-04-24 13:04:05 -06:00
2023-02-11 23:52:58 +02:00
2026-07-03 18:57:00 -06:00
2023-01-12 18:37:07 -07:00
2025-08-07 22:38:58 -06:00
2024-08-21 12:06:02 -06:00
2026-07-26 11:19:11 -06:00
2026-08-12 18:48:32 -06:00
2026-03-18 23:36:54 +02:00
2025-08-07 22:04:20 -06:00
2026-09-03 22:31:42 -06:00
2026-03-19 00:45:24 +02:00
2025-10-13 13:26:23 -06:00
2026-08-25 10:00:11 -06:00
2026-09-17 00:37:58 +03:00
2026-08-24 19:00:33 -06:00
2026-09-17 00:37:58 +03:00
2026-08-19 16:43:08 -06:00
2026-06-16 13:55:17 +02:00
2024-06-06 13:52:44 -06:00
2026-03-27 19:59:03 -06:00
2025-01-03 05:19:13 -07:00
2026-09-17 00:37:58 +03:00
2025-11-12 14:04:34 -05:00
2026-03-27 19:59:03 -06:00
2023-01-12 17:04:24 -07:00
2025-11-12 14:04:34 -05:00
2026-03-27 19:59:03 -06:00
2025-01-03 05:19:13 -07:00
2023-06-22 11:02:22 -06:00
2026-02-20 11:25:24 -07:00
2026-03-27 19:59:03 -06:00
2025-01-03 05:19:13 -07:00
2026-09-17 00:37:58 +03:00
2023-06-22 20:56:08 -04:00
2026-09-17 00:37:58 +03:00
2026-09-17 00:37:58 +03:00
2025-11-11 12:29:06 -07:00
2026-09-30 15:59:36 -06:00
2026-07-21 18:47:36 -06:00
2026-09-30 18:03:28 -06:00
2026-08-17 19:09:43 -06:00
2026-07-18 07:25:19 -06:00
2026-07-30 12:20:25 -06:00
2026-09-08 12:14:02 -06:00
2026-07-30 12:20:25 -06:00
2024-02-06 14:52:03 -07:00
2024-04-16 17:10:09 -06:00
2026-07-08 01:12:27 -06:00
2025-07-20 07:19:23 -06:00
2026-07-31 04:31:26 +03:00
2026-08-26 17:42:23 -06:00
2026-08-26 17:42:23 -06:00
2025-04-20 04:02:05 -06:00
2025-04-20 04:53:33 -06:00
2026-08-26 18:34:31 -06:00
2026-08-26 18:34:31 -06:00
2026-09-21 00:41:07 +03:00
2026-09-21 00:41:07 +03:00
2026-09-30 18:22:41 -06:00
2026-03-26 15:15:56 -06:00
2026-09-21 11:58:49 -06:00
2026-08-19 13:22:54 -06:00
2026-04-20 01:29:49 +02:00
2026-10-01 20:11:49 -06:00
2026-09-07 12:09:32 -06:00
2026-04-18 10:58:44 -06:00
2026-09-10 14:30:09 -06:00
2026-09-04 17:08:08 -06:00
2026-09-04 17:08:08 -06:00
2025-11-10 02:55:44 -07:00
2026-09-21 00:41:07 +03:00
2026-09-04 17:08:08 -06:00
2025-09-23 11:23:03 -04:00
2026-08-26 22:27:05 +03:00
2026-08-19 16:00:05 -06:00
2026-08-20 04:04:54 -06:00
2026-08-23 22:42:03 -06:00
2026-08-23 22:42:03 -06:00
2026-07-26 11:19:11 -06:00
2025-01-07 11:29:35 -07:00
2025-07-23 21:39:23 +03:00
2026-03-28 02:57:56 -06:00
2025-08-07 22:38:58 -06:00
2024-08-23 08:58:50 -06:00
2023-06-25 18:14:56 -06:00
2026-08-18 10:21:58 -06:00
2026-02-17 13:42:08 -07:00
2026-08-20 05:21:02 -06:00
2026-03-10 19:47:03 +02:00
2026-08-20 05:21:02 -06:00
2026-07-31 17:49:40 +03:00
2026-08-20 02:48:34 -06:00
2023-05-12 11:09:04 -06:00
2026-08-18 12:01:37 -06:00
2025-09-16 23:51:19 -04:00
2026-03-17 09:12:35 -06:00
2025-09-11 16:44:24 -06:00
2025-09-26 12:10:28 -04:00
2026-08-25 14:47:33 -06:00
2026-08-17 13:09:35 -06:00
2026-09-10 12:11:13 -06:00
2026-08-31 11:30:45 -06:00
2025-01-11 18:13:18 +02:00
2026-07-30 12:00:47 -06:00
2026-04-13 03:13:37 -06:00
2025-07-25 00:05:46 -06:00
2025-07-25 00:05:46 -06:00
2025-07-25 00:05:46 -06:00
2026-08-25 14:53:27 -06:00
2025-07-25 02:18:15 -06:00
2026-08-25 14:47:33 -06:00
2026-07-31 17:49:40 +03:00
2025-07-24 22:47:08 -06:00
2026-09-17 00:37:58 +03:00
2026-09-17 00:37:58 +03:00
2026-04-12 20:09:44 -06:00
2023-04-27 00:48:00 +02:00
2026-09-03 16:26:30 -06:00
2026-08-12 18:07:09 -06:00
2025-08-28 15:58:39 -06:00
2026-08-27 17:38:30 -06:00
2026-08-27 17:59:50 -06:00
2026-08-27 17:59:50 -06:00
2026-04-20 01:29:49 +02:00
2026-08-27 17:38:30 -06:00
2026-08-27 17:38:30 -06:00
2026-08-26 17:17:20 -06:00
2026-08-26 18:34:31 -06:00
2026-08-27 17:59:50 -06:00
2026-08-27 17:59:50 -06:00
2026-04-17 13:36:57 -06:00
2026-04-20 01:29:49 +02:00
2026-05-18 15:11:34 -06:00
2026-10-01 02:34:38 +03:00
2023-03-31 17:38:23 -06:00
2023-06-26 18:36:23 -06:00
2023-03-31 17:33:44 -06:00
2023-06-26 18:36:23 -06:00
2023-06-26 18:36:23 -06:00
2026-08-04 13:56:18 -06:00
2026-08-04 13:56:18 -06:00
2023-03-31 17:33:44 -06:00
2026-08-04 13:56:18 -06:00
2023-03-31 17:33:45 -06:00
2026-09-29 17:16:31 -06:00
2026-04-12 19:59:19 -06:00
2026-03-12 02:41:44 -03:00
2026-06-05 15:09:13 -07:00
2026-09-06 16:36:58 -06:00
2025-03-07 18:19:29 -07:00
2026-08-12 18:33:09 -06:00
2026-09-07 12:16:12 -06:00
2023-10-18 07:40:40 -06:00
2026-08-26 17:09:22 -06:00
2025-07-25 03:00:38 -06:00
2025-07-25 03:00:38 -06:00
2025-07-25 03:00:38 -06:00
2025-07-25 03:00:38 -06:00
2025-07-25 03:00:38 -06:00
2026-04-09 23:21:05 -06:00
2025-07-25 03:00:38 -06:00
2023-06-07 16:25:11 -06:00
2025-07-25 03:00:38 -06:00
2026-03-12 10:29:21 -06:00
2026-08-19 11:29:37 -06:00
2026-08-18 15:41:54 -06:00
2025-07-25 03:00:38 -06:00
2025-07-25 03:00:38 -06:00
2025-07-25 03:00:38 -06:00
2025-07-25 03:00:38 -06:00
2025-07-25 03:00:38 -06:00
2026-08-26 18:34:31 -06:00
2025-07-25 03:00:38 -06:00
2026-09-17 18:54:44 -06:00
2026-09-21 11:02:29 -06:00
2025-07-25 03:00:38 -06:00
2026-08-20 04:04:54 -06:00
2026-03-17 09:12:35 -06:00
2025-09-15 19:50:04 -06:00
2023-01-12 17:04:24 -07:00
2025-07-25 03:00:38 -06:00
2023-01-12 17:04:24 -07:00
2026-08-24 19:00:33 -06:00