From fea61c8ba1a69ca26875689e77801e09c6512d92 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 21 Feb 2026 13:35:19 -0300 Subject: [PATCH] hb-raster: use incremental fy in column-crossing loops Precompute delta_fy = 64 * total_dy / total_dx once per edge per row, then accumulate instead of dividing per column. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/hb-raster.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/hb-raster.cc b/src/hb-raster.cc index c7cf9870c..f280526fa 100644 --- a/src/hb-raster.cc +++ b/src/hb-raster.cc @@ -480,6 +480,9 @@ edge_sweep_row (int32_t *area, int32_t total_dx = x1 - x0; int32_t total_dy = fy1 - fy0; + /* fy increment per pixel column (constant since x_b advances by 64). */ + int32_t delta_fy = (int32_t) ((int64_t) 64 * total_dy / total_dx); + if (total_dx > 0) { /* Left-to-right edge. */ @@ -490,8 +493,7 @@ edge_sweep_row (int32_t *area, int32_t fy_prev = fy_b; for (int32_t cx = cx0 + 1; cx < cx1; cx++) { - x_b = (cx + 1) << 6; - fy_b = fy0 + (int32_t) ((int64_t) (x_b - x0) * total_dy / total_dx); + fy_b = fy_prev + delta_fy; cell_add (area, cover, width, cx - x_org, 0, fy_prev, 64, fy_b, wind, x_min, x_max); fy_prev = fy_b; } @@ -508,8 +510,7 @@ edge_sweep_row (int32_t *area, int32_t fy_prev = fy_b; for (int32_t cx = cx0 - 1; cx > cx1; cx--) { - x_b = cx << 6; - fy_b = fy0 + (int32_t) ((int64_t) (x_b - x0) * total_dy / total_dx); + fy_b = fy_prev - delta_fy; cell_add (area, cover, width, cx - x_org, 64, fy_prev, 0, fy_b, wind, x_min, x_max); fy_prev = fy_b; }