Skip to content

Commit

Permalink
Fix rounding error in non-AA curve edge smoothing.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ColdPaleLight committed Mar 6, 2024
1 parent 47a6d70 commit 9d26c94
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9d26c94

Please sign in to comment.