From 054be107365cac5dc6cff2b6f705978f1899c79e Mon Sep 17 00:00:00 2001 From: Bertram Felgenhauer Date: Tue, 22 Jan 2008 08:00:05 +0100 Subject: [PATCH] eliminate a special case in fbRasterizeEdges{4,8}. --- pixman/pixman-edge-imp.h | 15 +++++++++------ pixman/pixman-edge.c | 12 ++++++------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/pixman/pixman-edge-imp.h b/pixman/pixman-edge-imp.h index 9c33f94..0982a46 100644 --- a/pixman/pixman-edge-imp.h +++ b/pixman/pixman-edge-imp.h @@ -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 diff --git a/pixman/pixman-edge.c b/pixman/pixman-edge.c index 1ed6f10..4a9df9a 100644 --- a/pixman/pixman-edge.c +++ b/pixman/pixman-edge.c @@ -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)); } } -- 2.7.4