From 9d26c94dd748623937a0047f79a023113de04876 Mon Sep 17 00:00:00 2001 From: ColdPaleLight Date: Thu, 7 Mar 2024 00:18:03 +0800 Subject: [PATCH] Fix rounding error in non-AA curve edge smoothing. This change ensures precise rounding to the nearest 1/8 pixel by adding 1/16 pixel (in dot6 format) before the shift operation in cases where 'shiftAA' is 0. See http://review.skia.org/820656 for details. --- src/edge.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/edge.rs b/src/edge.rs index b8fd8f5..b6794a4 100644 --- a/src/edge.rs +++ b/src/edge.rs @@ -512,7 +512,7 @@ fn diff_to_shift(dx: FDot6, dy: FDot6, shift_aa: i32) -> i32 { // ... but small enough so that our curves still look smooth // When shift > 0, we're using AA and everything is scaled up so we can // lower the accuracy. - dist = (dist + (1 << 4)) >> (3 + shift_aa); + dist = (dist + (1 << (2 + shift_aa))) >> (3 + shift_aa); // each subdivision (shift value) cuts this dist (error) by 1/4 (32 - dist.leading_zeros() as i32) >> 1