From: Bertram Felgenhauer Date: Tue, 22 Jan 2008 07:00:05 +0000 (+0100) Subject: eliminate a special case in fbRasterizeEdges{4,8}. X-Git-Tag: pixman-0.10.0~36^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=054be107365cac5dc6cff2b6f705978f1899c79e;p=platform%2Fupstream%2Fpixman.git eliminate a special case in fbRasterizeEdges{4,8}. --- 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)); } }