fix cairo's a1-traps-sample test
authorBertram Felgenhauer <int-e@gmx.de>
Tue, 22 Jan 2008 06:57:54 +0000 (07:57 +0100)
committerBertram Felgenhauer <int-e@gmx.de>
Tue, 22 Jan 2008 06:57:54 +0000 (07:57 +0100)
For 1 bit alpha targets, the left and right boundaries of edges were
not rounded correctly.

pixman/pixman-edge-imp.h
pixman/pixman-private.h

index 2cf6d73..9c33f94 100644 (file)
@@ -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);
 
index 33a9e7c..075feb6 100644 (file)
@@ -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))