Implemented copying from A1R5G5B5 to L8 and A8L8.
Fixed the copying range.
TRAC #14885
Signed-off-by: Daniel Koch

Author:    Nicolas Capens

git-svn-id: https://angleproject.googlecode.com/svn/trunk@515 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/Texture.cpp b/src/libGLESv2/Texture.cpp
index b7dc370..9e3b404 100644
--- a/src/libGLESv2/Texture.cpp
+++ b/src/libGLESv2/Texture.cpp
@@ -987,7 +987,7 @@
               case D3DFMT_L8:
                 for(int y = 0; y < height; y++)
                 {
-                    for(int x = 0; x < height; x++)
+                    for(int x = 0; x < width; x++)
                     {
                         dest[x] = source[x * 4 + 2];
                     }
@@ -999,7 +999,7 @@
               case D3DFMT_A8L8:
                 for(int y = 0; y < height; y++)
                 {
-                    for(int x = 0; x < height; x++)
+                    for(int x = 0; x < width; x++)
                     {
                         dest[x * 2 + 0] = source[x * 4 + 2];
                         dest[x * 2 + 1] = source[x * 4 + 3];
@@ -1019,7 +1019,7 @@
               case D3DFMT_L8:
                 for(int y = 0; y < height; y++)
                 {
-                    for(int x = 0; x < height; x++)
+                    for(int x = 0; x < width; x++)
                     {
                         unsigned char red = source[x * 2 + 1] & 0xF8;
                         dest[x] = red | (red >> 5);
@@ -1033,6 +1033,40 @@
                 UNREACHABLE();
             }
             break;
+          case D3DFMT_A1R5G5B5:
+            switch(getD3DFormat())
+            {
+              case D3DFMT_L8:
+                for(int y = 0; y < height; y++)
+                {
+                    for(int x = 0; x < width; x++)
+                    {
+                        unsigned char red = source[x * 2 + 1] & 0x7C;
+                        dest[x] = (red << 1) | (red >> 4);
+                    }
+
+                    source += sourceLock.Pitch;
+                    dest += destLock.Pitch;
+                }
+                break;
+              case D3DFMT_A8L8:
+                for(int y = 0; y < height; y++)
+                {
+                    for(int x = 0; x < width; x++)
+                    {
+                        unsigned char red = source[x * 2 + 1] & 0x7C;
+                        dest[x * 2 + 0] = (red << 1) | (red >> 4);
+                        dest[x * 2 + 1] = (signed char)source[x * 2 + 1] >> 7;
+                    }
+
+                    source += sourceLock.Pitch;
+                    dest += destLock.Pitch;
+                }
+                break;
+              default:
+                UNREACHABLE();
+            }
+            break;
           default:
             UNREACHABLE();
         }