From eb1636876e081585bd4b7d85a9b55d88c6fccf5f Mon Sep 17 00:00:00 2001 From: Ginn Chen Date: Thu, 19 Feb 2009 21:00:41 +0800 Subject: [PATCH] Bug 479022 fast path of nsCanvasRenderingContext2D::PutImage() is wrong on BIG ENDIAN machine r=vladmir --- content/canvas/src/nsCanvasRenderingContext2D.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/content/canvas/src/nsCanvasRenderingContext2D.cpp b/content/canvas/src/nsCanvasRenderingContext2D.cpp index f58efef0d19..7cc55bb596d 100644 --- a/content/canvas/src/nsCanvasRenderingContext2D.cpp +++ b/content/canvas/src/nsCanvasRenderingContext2D.cpp @@ -3819,18 +3819,20 @@ nsCanvasRenderingContext2D::PutImageData() PRUint8 ir, ig, ib, ia; PRUint8 *ptr = imgPtr; for (int32 i = 0; i < w*h; i++) { -#ifdef IS_LITTLE_ENDIAN ir = ptr[0]; ig = ptr[1]; ib = ptr[2]; ia = ptr[3]; + +#ifdef IS_LITTLE_ENDIAN ptr[0] = (ib*ia + 254) / 255; ptr[1] = (ig*ia + 254) / 255; ptr[2] = (ir*ia + 254) / 255; #else - ptr[0] = (ptr[0]*ptr[3] + 254) / 255; - ptr[1] = (ptr[1]*ptr[3] + 254) / 255; - ptr[2] = (ptr[2]*ptr[3] + 254) / 255; + ptr[0] = ia; + ptr[1] = (ir*ia + 254) / 255; + ptr[2] = (ig*ia + 254) / 255; + ptr[3] = (ib*ia + 254) / 255; #endif ptr += 4; }