Recognize that ES3 supports texture storage. Add workaround for apparent Adreno bug.

R=robertphillips@google.com

Author: bsalomon@google.com

Review URL: https://chromiumcodereview.appspot.com/22856006

git-svn-id: http://skia.googlecode.com/svn/trunk@10845 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 4123a01..e2ecfd7 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -160,11 +160,17 @@
     fTextureUsageSupport = (kES_GrGLBinding == binding) &&
                             ctxInfo.hasExtension("GL_ANGLE_texture_usage");
 
-    // Tex storage is in desktop 4.2 and can be an extension to desktop or ES.
-    fTexStorageSupport = (kDesktop_GrGLBinding == binding &&
-                          version >= GR_GL_VER(4,2)) ||
-                         ctxInfo.hasExtension("GL_ARB_texture_storage") ||
-                         ctxInfo.hasExtension("GL_EXT_texture_storage");
+    if (kDesktop_GrGLBinding == binding) {
+        // The EXT version can apply to either GL or GLES.
+        fTexStorageSupport = version >= GR_GL_VER(4,2) ||
+                             ctxInfo.hasExtension("GL_ARB_texture_storage") ||
+                             ctxInfo.hasExtension("GL_EXT_texture_storage");
+    } else {
+        // Qualcomm Adreno drivers appear to have issues with texture storage.
+        fTexStorageSupport = (version >= GR_GL_VER(3,0) &&
+                              kQualcomm_GrGLVendor != ctxInfo.vendor()) ||
+                             ctxInfo.hasExtension("GL_EXT_texture_storage");
+    }
 
     // ARB_texture_rg is part of OpenGL 3.0, but mesa doesn't support it if
     // it doesn't have ARB_texture_rg extension.
diff --git a/src/gpu/gl/GrGLInterface.cpp b/src/gpu/gl/GrGLInterface.cpp
index 5dacd2d..d69f5c7 100644
--- a/src/gpu/gl/GrGLInterface.cpp
+++ b/src/gpu/gl/GrGLInterface.cpp
@@ -290,7 +290,7 @@
                 return false;
             }
         }
-    } else if (extensions.has("GL_EXT_texture_storage")) {
+    } else if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_EXT_texture_storage")) {
         if (NULL == fTexStorage2D) {
             return false;
         }
diff --git a/src/gpu/gl/GrGLUtil.cpp b/src/gpu/gl/GrGLUtil.cpp
index 8440c57..99efeaf 100644
--- a/src/gpu/gl/GrGLUtil.cpp
+++ b/src/gpu/gl/GrGLUtil.cpp
@@ -206,6 +206,9 @@
         if (0 == strcmp(vendorString, "Intel")) {
             return kIntel_GrGLVendor;
         }
+        if (0 == strcmp(vendorString, "Qualcomm")) {
+            return kQualcomm_GrGLVendor;
+        }
     }
     return kOther_GrGLVendor;
 }
diff --git a/src/gpu/gl/GrGLUtil.h b/src/gpu/gl/GrGLUtil.h
index b8a96e5..9a82b0b 100644
--- a/src/gpu/gl/GrGLUtil.h
+++ b/src/gpu/gl/GrGLUtil.h
@@ -23,6 +23,7 @@
     kARM_GrGLVendor,
     kImagination_GrGLVendor,
     kIntel_GrGLVendor,
+    kQualcomm_GrGLVendor,
 
     kOther_GrGLVendor
 };
diff --git a/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp b/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp
index 17f7f19..5ad867c 100644
--- a/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp
+++ b/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp
@@ -6,6 +6,7 @@
 
 #include "gl/GrGLExtensions.h"
 #include "gl/GrGLInterface.h"
+#include "gl/GrGLUtil.h"
 
 #ifndef GL_GLEXT_PROTOTYPES
 #define GL_GLEXT_PROTOTYPES
@@ -23,6 +24,12 @@
         if (!extensions.init(kES_GrGLBinding, glGetString, NULL, glGetIntegerv)) {
             return NULL;
         }
+        const char* verStr = reinterpret_cast<const char*>(glGetString(GR_GL_VERSION));
+        GrGLVersion version = GrGLGetVersionFromString(verStr);
+        if (version < GR_GL_VER(2,0)) {
+            return NULL;
+        }
+
         GrGLInterface* interface = new GrGLInterface;
         glInterface.reset(interface);
         interface->fBindingsExported = kES_GrGLBinding;
@@ -94,13 +101,21 @@
         interface->fTexParameteri = glTexParameteri;
         interface->fTexParameteriv = glTexParameteriv;
         interface->fTexSubImage2D = glTexSubImage2D;
-#if GL_ARB_texture_storage
-        interface->fTexStorage2D = glTexStorage2D;
-#elif GL_EXT_texture_storage
-        interface->fTexStorage2D = glTexStorage2DEXT;
+
+        if (version >= GR_GL_VER(3,0)) {
+#if GL_ES_VERSION_3_0
+            interface->fTexStorage2D = glTexStorage2D;
 #else
-        interface->fTexStorage2D = (GrGLTexStorage2DProc) eglGetProcAddress("glTexStorage2DEXT");
+            interface->fTexStorage2D = (GrGLTexStorage2DProc) eglGetProcAddress("glTexStorage2D");
 #endif
+        } else {
+#if GL_EXT_texture_storage
+            interface->fTexStorage2D = glTexStorage2DEXT;
+#else
+            interface->fTexStorage2D = (GrGLTexStorage2DProc) eglGetProcAddress("glTexStorage2DEXT");
+#endif
+        }
+
 #if GL_EXT_discard_framebuffer
         interface->fDiscardFramebuffer = glDiscardFramebufferEXT;
 #endif