Fix rounding of top and bottom coordinates.
authorSøren Sandmann Pedersen <sandmann@redhat.com>
Thu, 12 Nov 2009 22:20:32 +0000 (17:20 -0500)
committerSøren Sandmann Pedersen <sandmann@redhat.com>
Tue, 17 Nov 2009 06:58:01 +0000 (01:58 -0500)
commitf44431986f667eb49571e9365960524361f833c5
treef11752ee0e8e61e43eb891f7de850a124222d2a2
parent3bea18e3ea587c84423e9f7bafff21150c37d287
Fix rounding of top and bottom coordinates.

The rules for trap rasterization is that coordinates are rounded
towards north-west.

The pixman_sample_ceil() function is used to compute the first
(top-most) sample row included in the trap, so when the input
coordinate is already exactly on a sample row, no rounding should take
place.

On the other hand, pixman_sample_floor() is used to compute the final
(bottom-most) sample row, so if the input is precisely on a sample
row, it needs to be rounded down to the previous row.

This commit fixes the rounding computation. The idea of the
computation is like this:

Floor operation that rounds exact matches down: First subtract
pixman_fixed_e to make sure input already on a sample row gets rounded
down. Then find out how many small steps are between the input and the
first fraction. Then add those small steps to the first fraction.

The ceil operation first adds (small_step + pixman_e), then runs a
floor. This ensures that exact matches are not rounded off.

Based on a patch by M Joonas Pihlaja.
pixman/pixman-trap.c