EGL: Implement EGL Image extensions.

BUG=angleproject:2507

Change-Id: Ica33166e9e23e933977c3ab034d4f5a8cada9fb1
Reviewed-on: https://chromium-review.googlesource.com/1143454
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/tests/gl_tests/ImageTest.cpp b/src/tests/gl_tests/ImageTest.cpp
index 055df84..bb83d70 100644
--- a/src/tests/gl_tests/ImageTest.cpp
+++ b/src/tests/gl_tests/ImageTest.cpp
@@ -458,6 +458,9 @@
 // you change extension availability.
 TEST_P(ImageTest, ANGLEExtensionAvailability)
 {
+    // Android support is based on driver extension availability.
+    ANGLE_SKIP_TEST_IF(IsOpenGLES() && IsAndroid());
+
     if (IsD3D11() || IsD3D9())
     {
         EXPECT_TRUE(hasOESExt());
@@ -1292,6 +1295,10 @@
 
 TEST_P(ImageTest, Source3DTargetRenderbuffer)
 {
+    // Qualcom drivers appear to always bind the 0 layer of the source 3D texture when the target is
+    // a renderbuffer. They work correctly when the target is a 2D texture. http://anglebug.com/2745
+    ANGLE_SKIP_TEST_IF(IsAndroid() && IsOpenGLES());
+
     EGLWindow *window = getEGLWindow();
     ANGLE_SKIP_TEST_IF(!hasOESExt() || !hasBaseExt() || !has3DTextureExt());
 
@@ -1621,6 +1628,10 @@
 // Respecify the source texture, orphaning it.  The target texture should not have updated data.
 TEST_P(ImageTest, Respecification)
 {
+    // Respecification of textures that does not change the size of the level attached to the EGL
+    // image does not cause orphaning on Qualcomm devices. http://anglebug.com/2744
+    ANGLE_SKIP_TEST_IF(IsAndroid() && IsOpenGLES());
+
     EGLWindow *window = getEGLWindow();
     ANGLE_SKIP_TEST_IF(!hasOESExt() || !hasBaseExt() || !has2DTextureExt());
 
@@ -1652,6 +1663,41 @@
     glDeleteTextures(1, &target);
 }
 
+// Respecify the source texture with a different size, orphaning it.  The target texture should not
+// have updated data.
+TEST_P(ImageTest, RespecificationDifferentSize)
+{
+    EGLWindow *window = getEGLWindow();
+    ANGLE_SKIP_TEST_IF(!hasOESExt() || !hasBaseExt() || !has2DTextureExt());
+
+    GLubyte originalData[4] = {255, 0, 255, 255};
+    GLubyte updateData[16]  = {0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255};
+
+    // Create the Image
+    GLuint source;
+    EGLImageKHR image;
+    createEGLImage2DTextureSource(1, 1, GL_RGBA, GL_UNSIGNED_BYTE, originalData, &source, &image);
+
+    // Create the target
+    GLuint target;
+    createEGLImageTargetTexture2D(image, &target);
+
+    // Respecify source
+    glBindTexture(GL_TEXTURE_2D, source);
+    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, updateData);
+
+    // Expect that the target texture has the original data
+    verifyResults2D(target, originalData);
+
+    // Expect that the source texture has the updated data
+    verifyResults2D(source, updateData);
+
+    // Clean up
+    glDeleteTextures(1, &source);
+    eglDestroyImageKHR(window->getDisplay(), image);
+    glDeleteTextures(1, &target);
+}
+
 // First render to a target texture, then respecify the source texture, orphaning it.
 // The target texture's FBO should be notified of the target texture's orphaning.
 TEST_P(ImageTest, RespecificationWithFBO)
@@ -1705,6 +1751,10 @@
 // data
 TEST_P(ImageTest, RespecificationOfOtherLevel)
 {
+    // Respecification of textures that does not change the size of the level attached to the EGL
+    // image does not cause orphaning on Qualcomm devices. http://anglebug.com/2744
+    ANGLE_SKIP_TEST_IF(IsAndroid() && IsOpenGLES());
+
     EGLWindow *window = getEGLWindow();
     ANGLE_SKIP_TEST_IF(!hasOESExt() || !hasBaseExt() || !has2DTextureExt());