Add a fast path for BGRA to RGBA conversion inside readPixels. Already covered
by existing WebGL conformance tests. 5x speedup observed for reading back a
4096x4096x4 texture on a NVIDIA GeForce 9600M GT (from 1000ms to 200ms).

Review URL: https://codereview.appspot.com/7466044
Author: Evan Wallace

git-svn-id: http://angleproject.googlecode.com/svn/trunk@1999 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/AUTHORS b/AUTHORS
index a2ce915..2eea0c7 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -30,3 +30,4 @@
 Aitor Moreno
 Yuri O'Donnell
 Josh Soref
+Evan Wallace
diff --git a/src/common/version.h b/src/common/version.h
index 2e02334..ce11dc3 100644
--- a/src/common/version.h
+++ b/src/common/version.h
@@ -1,7 +1,7 @@
 #define MAJOR_VERSION 1
 #define MINOR_VERSION 0
 #define BUILD_VERSION 0
-#define BUILD_REVISION 1994
+#define BUILD_REVISION 1999
 
 #define STRINGIFY(x) #x
 #define MACRO_STRINGIFY(x) STRINGIFY(x)
diff --git a/src/libGLESv2/Context.cpp b/src/libGLESv2/Context.cpp
index 45cb606..e150aee 100644
--- a/src/libGLESv2/Context.cpp
+++ b/src/libGLESv2/Context.cpp
@@ -2679,6 +2679,21 @@
                    (rect.right - rect.left) * fastPixelSize);
             continue;
         }
+        else if (desc.Format == D3DFMT_A8R8G8B8 &&
+                 format == GL_RGBA &&
+                 type == GL_UNSIGNED_BYTE)
+        {
+            // Fast path for swapping red with blue
+            for (int i = 0; i < rect.right - rect.left; 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
+            }
+            continue;
+        }
 
         for (int i = 0; i < rect.right - rect.left; i++)
         {