[cairo-commit] src/cairo-image-compositor.c

Chris Wilson ickle at kemper.freedesktop.org
Sat Apr 28 15:17:59 PDT 2012


 src/cairo-image-compositor.c |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

New commits:
commit ec400daf9ec3bbd8403324db7fcdaf175e185e7b
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Apr 28 23:15:52 2012 +0100

    image: Avoid overflow when computing lerp spans for a8
    
    Reported-by: Benjamin Otte <otte at redhat.com>
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-image-compositor.c b/src/cairo-image-compositor.c
index f9ef031..fb4b2fb 100644
--- a/src/cairo-image-compositor.c
+++ b/src/cairo-image-compositor.c
@@ -1950,12 +1950,12 @@ _fill_a8_lerp_opaque_spans (void *abstract_renderer, int y, int h,
 		if (a == 0xff) {
 		    memset(d + spans[0].x, r->u.fill.pixel, len);
 		} else {
-		    uint16_t p = (uint16_t)a * r->u.fill.pixel + 0x7f;
-		    uint16_t ia = ~a;
+		    uint8_t s = mul8_8(a, r->u.fill.pixel);
 		    uint8_t *dst = d + spans[0].x;
+		    a = ~a;
 		    while (len--) {
-			uint16_t t = *dst*ia + p;
-			*dst++ = (t + (t>>8)) >> 8;
+			uint8_t t = mul8_8(*dst, a);
+			*dst++ = t + s;
 		    }
 		}
 	    }
@@ -1974,14 +1974,14 @@ _fill_a8_lerp_opaque_spans (void *abstract_renderer, int y, int h,
 			yy++;
 		    } while (--hh);
 		} else {
-		    uint16_t p = (uint16_t)a * r->u.fill.pixel + 0x7f;
-		    uint16_t ia = ~a;
+		    uint8_t s = mul8_8(a, r->u.fill.pixel);
+		    a = ~a;
 		    do {
 			int len = spans[1].x - spans[0].x;
 			uint8_t *d = r->u.fill.data + r->u.fill.stride*yy + spans[0].x;
 			while (len--) {
-			    uint16_t t = *d*ia + p;
-			    *d++ = (t + (t>>8)) >> 8;
+			    uint8_t t = mul8_8(*d, a);
+			    *d++ = t + s;
 			}
 			yy++;
 		    } while (--hh);


More information about the cairo-commit mailing list