Refactor Texture::copy*Image methods to use gl::Error objects.

BUG=angle:520

Change-Id: I8b6bf5d50ee0d1f796eff52919ee65823fdee6cb
Reviewed-on: https://chromium-review.googlesource.com/216647
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Tested-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libGLESv2/libGLESv2.cpp b/src/libGLESv2/libGLESv2.cpp
index 2bb2d39..b4bc4ee 100644
--- a/src/libGLESv2/libGLESv2.cpp
+++ b/src/libGLESv2/libGLESv2.cpp
@@ -899,7 +899,12 @@
           case GL_TEXTURE_2D:
             {
                 gl::Texture2D *texture = context->getTexture2D();
-                texture->copyImage(level, internalformat, x, y, width, height, framebuffer);
+                gl::Error error = texture->copyImage(level, internalformat, x, y, width, height, framebuffer);
+                if (error.isError())
+                {
+                    context->recordError(error);
+                    return;
+                }
             }
             break;
 
@@ -911,7 +916,12 @@
           case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
             {
                 gl::TextureCubeMap *texture = context->getTextureCubeMap();
-                texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer);
+                gl::Error error = texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer);
+                if (error.isError())
+                {
+                    context->recordError(error);
+                    return;
+                }
             }
             break;
 
@@ -952,7 +962,12 @@
           case GL_TEXTURE_2D:
             {
                 gl::Texture2D *texture = context->getTexture2D();
-                texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
+                gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
+                if (error.isError())
+                {
+                    context->recordError(error);
+                    return;
+                }
             }
             break;
 
@@ -964,7 +979,12 @@
           case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
             {
                 gl::TextureCubeMap *texture = context->getTextureCubeMap();
-                texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
+                gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
+                if (error.isError())
+                {
+                    context->recordError(error);
+                    return;
+                }
             }
             break;
 
@@ -5194,7 +5214,12 @@
             return;
         }
 
-        texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer);
+        gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer);
+        if (error.isError())
+        {
+            context->recordError(error);
+            return;
+        }
     }
 }