summaryrefslogtreecommitdiff
path: root/src/cairo-tor-scan-converter.c
diff options
context:
space:
mode:
authorM Joonas Pihlaja <jpihlaja@cc.helsinki.fi>2009-05-02 18:05:20 +0300
committerM Joonas Pihlaja <jpihlaja@cc.helsinki.fi>2009-07-10 19:06:48 +0300
commit9686331cb07a8f9018f28dc7d6d6e3726e289fda (patch)
treecdc147ff9a0b7d4a65d8b530b40555808c242ecc /src/cairo-tor-scan-converter.c
parentfbd88db938bf3bb03934795da9b3d184c4f43608 (diff)
downloadcairo-9686331cb07a8f9018f28dc7d6d6e3726e289fda.tar.gz
[spans] Round rasterization grid pixel areas instead of truncating.
When converting a grid pixel area into the range [0,255] the GRID_AREA_TO_ALPHA() macro would truncate extra bits off the result rather than rounding. This could cause seams between abutting collinear edges of separately rendered polygons even when the coordinates of the abutting edges were the same. Reported by Soeren Sandmann on the cairo mailing list: http://lists.cairographics.org/archives/cairo/2009-May/017043.html
Diffstat (limited to 'src/cairo-tor-scan-converter.c')
-rw-r--r--src/cairo-tor-scan-converter.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cairo-tor-scan-converter.c b/src/cairo-tor-scan-converter.c
index 4abafc41e..7d37f475c 100644
--- a/src/cairo-tor-scan-converter.c
+++ b/src/cairo-tor-scan-converter.c
@@ -295,9 +295,9 @@ typedef int grid_area_t;
#elif GRID_XY == 15
# define GRID_AREA_TO_ALPHA(c) (((c) << 4) + (c))
#elif GRID_XY == 2*256*15
-# define GRID_AREA_TO_ALPHA(c) (((c) + ((c)<<4)) >> 9)
+# define GRID_AREA_TO_ALPHA(c) (((c) + ((c)<<4) + 256) >> 9)
#else
-# define GRID_AREA_TO_ALPHA(c) ((c)*255 / GRID_XY) /* tweak me for rounding */
+# define GRID_AREA_TO_ALPHA(c) (((c)*255 + GRID_XY/2) / GRID_XY)
#endif
#define UNROLL3(x) x x x