Bug 479022 fast path of nsCanvasRenderingContext2D::PutImage() is wrong on BIG ENDIAN machine r=vladmir

This commit is contained in:
Ginn Chen 2009-02-19 21:00:41 +08:00
Родитель b6c2a8283b
Коммит 22b269f2d5
1 изменённых файлов: 6 добавлений и 4 удалений

Просмотреть файл

@ -3819,18 +3819,20 @@ nsCanvasRenderingContext2D::PutImageData()
PRUint8 ir, ig, ib, ia; PRUint8 ir, ig, ib, ia;
PRUint8 *ptr = imgPtr; PRUint8 *ptr = imgPtr;
for (int32 i = 0; i < w*h; i++) { for (int32 i = 0; i < w*h; i++) {
#ifdef IS_LITTLE_ENDIAN
ir = ptr[0]; ir = ptr[0];
ig = ptr[1]; ig = ptr[1];
ib = ptr[2]; ib = ptr[2];
ia = ptr[3]; ia = ptr[3];
#ifdef IS_LITTLE_ENDIAN
ptr[0] = (ib*ia + 254) / 255; ptr[0] = (ib*ia + 254) / 255;
ptr[1] = (ig*ia + 254) / 255; ptr[1] = (ig*ia + 254) / 255;
ptr[2] = (ir*ia + 254) / 255; ptr[2] = (ir*ia + 254) / 255;
#else #else
ptr[0] = (ptr[0]*ptr[3] + 254) / 255; ptr[0] = ia;
ptr[1] = (ptr[1]*ptr[3] + 254) / 255; ptr[1] = (ir*ia + 254) / 255;
ptr[2] = (ptr[2]*ptr[3] + 254) / 255; ptr[2] = (ig*ia + 254) / 255;
ptr[3] = (ib*ia + 254) / 255;
#endif #endif
ptr += 4; ptr += 4;
} }