Re-land "Implements more pack/unpack states."

Pack: row length, skip rows, skip pixels.
Unpack: image height, skip images, skip rows, skip pixels.
Note that PBOs are not covered by this change.

Re-land with fix for test expectations.

BUG=angleproject:512
BUG=angleproject:1095

Change-Id: I71d8d3bd8fc1f2c75ca16ac2634d5eafcbd71f26
Reviewed-on: https://chromium-review.googlesource.com/305522
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/formatutils.cpp b/src/libANGLE/formatutils.cpp
index 0bfe872..0ea125e 100644
--- a/src/libANGLE/formatutils.cpp
+++ b/src/libANGLE/formatutils.cpp
@@ -589,9 +589,23 @@
     return rx::roundUp(rowBytes, static_cast<GLuint>(alignment));
 }
 
-GLuint InternalFormat::computeDepthPitch(GLenum formatType, GLsizei width, GLsizei height, GLint alignment, GLint rowLength) const
+GLuint InternalFormat::computeDepthPitch(GLenum formatType,
+                                         GLsizei width,
+                                         GLsizei height,
+                                         GLint alignment,
+                                         GLint rowLength,
+                                         GLint imageHeight) const
 {
-    return computeRowPitch(formatType, width, alignment, rowLength) * height;
+    GLuint rows;
+    if (imageHeight > 0)
+    {
+        rows = imageHeight;
+    }
+    else
+    {
+        rows = height;
+    }
+    return computeRowPitch(formatType, width, alignment, rowLength) * rows;
 }
 
 GLuint InternalFormat::computeBlockSize(GLenum formatType, GLsizei width, GLsizei height) const
@@ -616,6 +630,15 @@
     }
 }
 
+GLuint InternalFormat::computeSkipPixels(GLint rowPitch,
+                                         GLint depthPitch,
+                                         GLint skipImages,
+                                         GLint skipRows,
+                                         GLint skipPixels) const
+{
+    return skipImages * depthPitch + skipRows * rowPitch + skipPixels * pixelBytes;
+}
+
 GLenum GetSizedInternalFormat(GLenum internalFormat, GLenum type)
 {
     const InternalFormat& formatInfo = GetInternalFormatInfo(internalFormat);