Bug 723453 - Split cases for ConvertHostARGB - r=joe
authorJeff Gilbert <jgilbert@mozilla.com>
Fri, 10 Feb 2012 15:41:24 -0800
changeset 86646 b84e21604bc425638749bf45089077fe978e09b2
parent 86645 308b3ced990bd3bd579d743d3b90d50f70f0f7ef
child 86647 6e352877ec67f3c0f8e208a869b5b471a42861e2
push id22038
push userbmo@edmorley.co.uk
push dateSat, 11 Feb 2012 19:28:27 +0000
treeherdermozilla-central@9253f058824a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjoe
bugs723453
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 723453 - Split cases for ConvertHostARGB - r=joe
image/encoders/bmp/nsBMPEncoder.cpp
--- a/image/encoders/bmp/nsBMPEncoder.cpp
+++ b/image/encoders/bmp/nsBMPEncoder.cpp
@@ -432,27 +432,36 @@ NS_IMETHODIMP nsBMPEncoder::CloseWithSta
 //
 //    Our colors are stored with premultiplied alphas, but we need
 //    an output with no alpha in machine-independent byte order.
 //
 void
 nsBMPEncoder::ConvertHostARGBRow(const PRUint8* aSrc, PRUint8* aDest,
                                  PRUint32 aPixelWidth)
 {
-  for (PRUint32 x = 0; x < aPixelWidth; x ++) {
-    const PRUint32& pixelIn = ((const PRUint32*)(aSrc))[x];
-    PRUint8 *pixelOut = &aDest[x * BytesPerPixel(mBMPInfoHeader.bpp)];
+  int bytes = BytesPerPixel(mBMPInfoHeader.bpp);
+
+  if (mBMPInfoHeader.bpp == 32) {
+    for (PRUint32 x = 0; x < aPixelWidth; x++) {
+      const PRUint32& pixelIn = ((const PRUint32*)(aSrc))[x];
+      PRUint8 *pixelOut = &aDest[x * bytes];
 
-    PRUint8 alpha = (pixelIn & 0xff000000) >> 24;
-    pixelOut[0] = (((pixelIn & 0xff0000) >> 16));
-    pixelOut[1] = (((pixelIn & 0x00ff00) >>  8));
-    pixelOut[2] = (((pixelIn & 0x0000ff) >>  0));
+      pixelOut[0] = (pixelIn & 0x00ff0000) >> 16;
+      pixelOut[1] = (pixelIn & 0x0000ff00) >>  8;
+      pixelOut[2] = (pixelIn & 0x000000ff) >>  0;
+      pixelOut[3] = (pixelIn & 0xff000000) >> 24;
+    }
+  } else {
+    for (PRUint32 x = 0; x < aPixelWidth; x++) {
+      const PRUint32& pixelIn = ((const PRUint32*)(aSrc))[x];
+      PRUint8 *pixelOut = &aDest[x * bytes];
 
-    if (mBMPInfoHeader.bpp == 32) {
-      pixelOut[3] = alpha;
+      pixelOut[0] = (pixelIn & 0xff0000) >> 16;
+      pixelOut[1] = (pixelIn & 0x00ff00) >>  8;
+      pixelOut[2] = (pixelIn & 0x0000ff) >>  0;
     }
   }
 }
 
 // nsBMPEncoder::StripAlpha
 //
 //    Input is RGBA, output is RGB
 void