Use gl::Rectangle as a param to Image::copy.

BUG=angle:729

Change-Id: I13194760df35cb18db6ac43d567e6b393e838d56
Reviewed-on: https://chromium-review.googlesource.com/221268
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libGLESv2/renderer/d3d/TextureD3D.cpp b/src/libGLESv2/renderer/d3d/TextureD3D.cpp
index 9991842..f61fc0d 100644
--- a/src/libGLESv2/renderer/d3d/TextureD3D.cpp
+++ b/src/libGLESv2/renderer/d3d/TextureD3D.cpp
@@ -549,9 +549,11 @@
     GLenum sizedInternalFormat = gl::GetSizedInternalFormat(format, GL_UNSIGNED_BYTE);
     redefineImage(level, sizedInternalFormat, width, height);
 
+    gl::Rectangle sourceRect(x, y, width, height);
+
     if (!mImageArray[level]->isRenderableFormat())
     {
-        mImageArray[level]->copy(0, 0, 0, x, y, width, height, source);
+        mImageArray[level]->copy(0, 0, 0, sourceRect, source);
         mDirtyImages = true;
     }
     else
@@ -561,12 +563,6 @@
 
         if (width != 0 && height != 0 && isValidLevel(level))
         {
-            gl::Rectangle sourceRect;
-            sourceRect.x = x;
-            sourceRect.width = width;
-            sourceRect.y = y;
-            sourceRect.height = height;
-
             mRenderer->copyImage2D(source, sourceRect, format, 0, 0, mTexStorage, level);
         }
     }
@@ -580,9 +576,11 @@
     // the current level we're copying to is defined (with appropriate format, width & height)
     bool canCreateRenderTarget = isLevelComplete(level) && isLevelComplete(0);
 
+    gl::Rectangle sourceRect(x, y, width, height);
+
     if (!mImageArray[level]->isRenderableFormat() || (!mTexStorage && !canCreateRenderTarget))
     {
-        mImageArray[level]->copy(xoffset, yoffset, 0, x, y, width, height, source);
+        mImageArray[level]->copy(xoffset, yoffset, 0, sourceRect, source);
         mDirtyImages = true;
     }
     else
@@ -593,12 +591,6 @@
         {
             updateStorageLevel(level);
 
-            gl::Rectangle sourceRect;
-            sourceRect.x = x;
-            sourceRect.width = width;
-            sourceRect.y = y;
-            sourceRect.height = height;
-
             mRenderer->copyImage2D(source, sourceRect,
                                    gl::GetInternalFormatInfo(getBaseLevelInternalFormat()).format,
                                    xoffset, yoffset, mTexStorage, level);
@@ -1002,9 +994,11 @@
 
     redefineImage(faceIndex, level, sizedInternalFormat, width, height);
 
+    gl::Rectangle sourceRect(x, y, width, height);
+
     if (!mImageArray[faceIndex][level]->isRenderableFormat())
     {
-        mImageArray[faceIndex][level]->copy(0, 0, 0, x, y, width, height, source);
+        mImageArray[faceIndex][level]->copy(0, 0, 0, sourceRect, source);
         mDirtyImages = true;
     }
     else
@@ -1016,12 +1010,6 @@
 
         if (width > 0 && isValidFaceLevel(faceIndex, level))
         {
-            gl::Rectangle sourceRect;
-            sourceRect.x = x;
-            sourceRect.width = width;
-            sourceRect.y = y;
-            sourceRect.height = height;
-
             mRenderer->copyImageCube(source, sourceRect, format, 0, 0, mTexStorage, target, level);
         }
     }
@@ -1036,9 +1024,11 @@
     // rely on the "getBaseLevel*" methods reliably otherwise.
     bool canCreateRenderTarget = isFaceLevelComplete(faceIndex, level) && isCubeComplete();
 
+    gl::Rectangle sourceRect(x, y, width, height);
+
     if (!mImageArray[faceIndex][level]->isRenderableFormat() || (!mTexStorage && !canCreateRenderTarget))
     {
-        mImageArray[faceIndex][level]->copy(0, 0, 0, x, y, width, height, source);
+        mImageArray[faceIndex][level]->copy(0, 0, 0, sourceRect, source);
         mDirtyImages = true;
     }
     else
@@ -1049,12 +1039,6 @@
         {
             updateStorageFaceLevel(faceIndex, level);
 
-            gl::Rectangle sourceRect;
-            sourceRect.x = x;
-            sourceRect.width = width;
-            sourceRect.y = y;
-            sourceRect.height = height;
-
             mRenderer->copyImageCube(source, sourceRect, gl::GetInternalFormatInfo(getBaseLevelInternalFormat()).format,
                                      xoffset, yoffset, mTexStorage, target, level);
         }
@@ -1565,9 +1549,11 @@
     // the current level we're copying to is defined (with appropriate format, width & height)
     bool canCreateRenderTarget = isLevelComplete(level) && isLevelComplete(0);
 
+    gl::Rectangle sourceRect(x, y, width, height);
+
     if (!mImageArray[level]->isRenderableFormat() || (!mTexStorage && !canCreateRenderTarget))
     {
-        mImageArray[level]->copy(xoffset, yoffset, zoffset, x, y, width, height, source);
+        mImageArray[level]->copy(xoffset, yoffset, zoffset, sourceRect, source);
         mDirtyImages = true;
     }
     else
@@ -1578,12 +1564,6 @@
         {
             updateStorageLevel(level);
 
-            gl::Rectangle sourceRect;
-            sourceRect.x = x;
-            sourceRect.width = width;
-            sourceRect.y = y;
-            sourceRect.height = height;
-
             mRenderer->copyImage3D(source, sourceRect,
                                    gl::GetInternalFormatInfo(getBaseLevelInternalFormat()).format,
                                    xoffset, yoffset, zoffset, mTexStorage, level);
@@ -2036,9 +2016,11 @@
     // the current level we're copying to is defined (with appropriate format, width & height)
     bool canCreateRenderTarget = isLevelComplete(level) && isLevelComplete(0);
 
+    gl::Rectangle sourceRect(x, y, width, height);
+
     if (!mImageArray[level][0]->isRenderableFormat() || (!mTexStorage && !canCreateRenderTarget))
     {
-        mImageArray[level][zoffset]->copy(xoffset, yoffset, 0, x, y, width, height, source);
+        mImageArray[level][zoffset]->copy(xoffset, yoffset, 0, sourceRect, source);
         mDirtyImages = true;
     }
     else
@@ -2049,12 +2031,6 @@
         {
             updateStorageLevel(level);
 
-            gl::Rectangle sourceRect;
-            sourceRect.x = x;
-            sourceRect.width = width;
-            sourceRect.y = y;
-            sourceRect.height = height;
-
             mRenderer->copyImage2DArray(source, sourceRect, gl::GetInternalFormatInfo(getInternalFormat(0)).format,
                                         xoffset, yoffset, zoffset, mTexStorage, level);
         }