eliminate a special case in fbRasterizeEdges{4,8}.
authorBertram Felgenhauer <int-e@gmx.de>
Tue, 22 Jan 2008 07:00:05 +0000 (08:00 +0100)
committerBertram Felgenhauer <int-e@gmx.de>
Tue, 22 Jan 2008 07:00:05 +0000 (08:00 +0100)
pixman/pixman-edge-imp.h
pixman/pixman-edge.c

index 9c33f94..0982a46 100644 (file)
@@ -59,7 +59,15 @@ rasterizeEdges (pixman_image_t  *image,
        if (lx < 0)
            lx = 0;
        if (pixman_fixed_to_int (rx) >= width)
+#if N_BITS == 1
            rx = pixman_int_to_fixed (width);
+#else
+           /* Use the last pixel of the scanline, covered 100%.
+            * We can't use the first pixel following the scanline,
+            * because accessing it could result in a buffer overrun.
+            */
+           rx = pixman_int_to_fixed (width) - 1;
+#endif
 
        /* Skip empty (or backwards) sections */
        if (rx > lx)
@@ -117,12 +125,7 @@ rasterizeEdges (pixman_image_t  *image,
                        AddAlpha (N_X_FRAC(N_BITS));
                        StepAlpha;
                    }
-                   /* Do not add in a 0 alpha here. This check is necessary
-                    * to avoid a buffer overrun when rx is exactly on a pixel
-                    * boundary.
-                    */
-                   if (rxs != 0)
-                       AddAlpha (rxs);
+                   AddAlpha (rxs);
                }
            }
 #endif
index 1ed6f10..4a9df9a 100644 (file)
@@ -147,7 +147,11 @@ fbRasterizeEdges8 (pixman_image_t       *image,
            lx = 0;
        rx = r->x;
        if (pixman_fixed_to_int (rx) >= width)
-           rx = pixman_int_to_fixed (width);
+           /* Use the last pixel of the scanline, covered 100%.
+            * We can't use the first pixel following the scanline,
+            * because accessing it could result in a buffer overrun.
+            */
+           rx = pixman_int_to_fixed (width) - 1;
 
        /* Skip empty (or backwards) sections */
        if (rx > lx)
@@ -235,11 +239,7 @@ fbRasterizeEdges8 (pixman_image_t       *image,
                    add_saturate_8 (ap + lxi, N_X_FRAC(8), rxi - lxi);
                }
 
-               /* Do not add in a 0 alpha here. This check is
-                * necessary to avoid a buffer overrun, (when rx
-                * is exactly on a pixel boundary). */
-               if (rxs)
-                   WRITE(image, ap + rxi, clip255 (READ(image, ap + rxi) + rxs));
+               WRITE(image, ap + rxi, clip255 (READ(image, ap + rxi) + rxs));
            }
        }