From 5467807e757ad6a5ec45085c963425f9dd6d2414 Mon Sep 17 00:00:00 2001 From: Bertram Felgenhauer Date: Tue, 22 Jan 2008 07:57:54 +0100 Subject: [PATCH] fix cairo's a1-traps-sample test For 1 bit alpha targets, the left and right boundaries of edges were not rounded correctly. --- pixman/pixman-edge-imp.h | 12 ++++++++++-- pixman/pixman-private.h | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pixman/pixman-edge-imp.h b/pixman/pixman-edge-imp.h index 2cf6d73..9c33f94 100644 --- a/pixman/pixman-edge-imp.h +++ b/pixman/pixman-edge-imp.h @@ -45,11 +45,19 @@ rasterizeEdges (pixman_image_t *image, int lxi; int rxi; - /* clip X */ +#if N_BITS == 1 + /* For the non-antialiased case, round the coordinates up, in effect + * sampling the center of the pixel. (The AA case does a similar + * adjustment in RenderSamplesX) */ + lx = l->x + X_FRAC_FIRST(1); + rx = r->x + X_FRAC_FIRST(1); +#else lx = l->x; + rx = r->x; +#endif + /* clip X */ if (lx < 0) lx = 0; - rx = r->x; if (pixman_fixed_to_int (rx) >= width) rx = pixman_int_to_fixed (width); diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h index 33a9e7c..075feb6 100644 --- a/pixman/pixman-private.h +++ b/pixman/pixman-private.h @@ -748,7 +748,7 @@ union pixman_image #define MAX_ALPHA(n) ((1 << (n)) - 1) #define N_Y_FRAC(n) ((n) == 1 ? 1 : (1 << ((n)/2)) - 1) -#define N_X_FRAC(n) ((1 << ((n)/2)) + 1) +#define N_X_FRAC(n) ((n) == 1 ? 1 : (1 << ((n)/2)) + 1) #define STEP_Y_SMALL(n) (pixman_fixed_1 / N_Y_FRAC(n)) #define STEP_Y_BIG(n) (pixman_fixed_1 - (N_Y_FRAC(n) - 1) * STEP_Y_SMALL(n)) -- 2.7.4