Fix bugs in DXT support
Review URL: http://codereview.appspot.com/4857045

git-svn-id: https://angleproject.googlecode.com/svn/trunk@722 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/Texture.cpp b/src/libGLESv2/Texture.cpp
index e143535..8f195ea 100644
--- a/src/libGLESv2/Texture.cpp
+++ b/src/libGLESv2/Texture.cpp
@@ -71,11 +71,11 @@
     {
         return D3DFMT_DXT1;
     }
-    else if (type == GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE)
+    else if (format == GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE)
     {
         return D3DFMT_DXT3;
     }
-    else if (type == GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE)
+    else if (format == GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE)
     {
         return D3DFMT_DXT5;
     }
@@ -877,10 +877,10 @@
   destBytes[1] = sourceBytes[1];
   destBytes[2] = line_3_2 & 0xff;
   destBytes[3] = (line_3_2 & 0xff00) >> 8;
-  destBytes[4] = (line_3_2 & 0xff0000) >> 8;
+  destBytes[4] = (line_3_2 & 0xff0000) >> 16;
   destBytes[5] = line_1_0 & 0xff;
   destBytes[6] = (line_1_0 & 0xff00) >> 8;
-  destBytes[7] = (line_1_0 & 0xff0000) >> 8;
+  destBytes[7] = (line_1_0 & 0xff0000) >> 16;
 
   // And flip the DXT1 block using the above function.
   FlipCopyDXT1BlockFull(source + 2, dest + 2);
@@ -1036,7 +1036,7 @@
             break;
         default:
             ASSERT(height % 4 == 0);
-            for (int y = 0; y < height; ++y)
+            for (int y = 0; y < height / 4; ++y)
             {
                 const unsigned int *source = reinterpret_cast<const unsigned int*>(static_cast<const unsigned char*>(input) + y * inputPitch);
                 unsigned int *dest = reinterpret_cast<unsigned int*>(static_cast<unsigned char*>(output) + (y + yoffset) * outputPitch + xoffset * 16);