Fast path for BGRA to RGBA readPixels conversions.

From http://code.google.com/p/angleproject/source/detail?r=1999

TRAC #22825

Signed-off-by: Geoff Lang
Signed-off-by: Shannon Woods
Author: Jamie Madill

git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2104 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/renderer/Renderer11.cpp b/src/libGLESv2/renderer/Renderer11.cpp
index 3cbdd5d..c209013 100644
--- a/src/libGLESv2/renderer/Renderer11.cpp
+++ b/src/libGLESv2/renderer/Renderer11.cpp
@@ -3386,6 +3386,25 @@
             memcpy(dest + j * outputPitch, source + j * inputPitch, area.width * fastPixelSize);
         }
     }
+    else if (textureDesc.Format == DXGI_FORMAT_B8G8R8A8_UNORM &&
+             format == GL_RGBA &&
+             type == GL_UNSIGNED_BYTE)
+    {
+        // Fast path for swapping red with blue
+        unsigned char *dest = static_cast<unsigned char*>(pixels);
+
+        for (int j = 0; j < area.height; j++)
+        {
+            for (int i = 0; i < area.width; i++)
+            {
+                unsigned int argb = *(unsigned int*)(source + 4 * i + j * inputPitch);
+                *(unsigned int*)(dest + 4 * i + j * outputPitch) =
+                    (argb & 0xFF00FF00) |       // Keep alpha and green
+                    (argb & 0x00FF0000) >> 16 | // Move red to blue
+                    (argb & 0x000000FF) << 16;  // Move blue to red
+            }
+        }
+    }
     else
     {
         gl::Color pixelColor;