Index: content/common/android/surface_texture_bridge.cc |
diff --git a/content/common/android/surface_texture_bridge.cc b/content/common/android/surface_texture_bridge.cc |
index bdf54eeb0a2a6dd88ae2f3c59837fcf4e42670b6..eb4b27ebc78d12cc2289a4b7eb76e27f835d598f 100644 |
--- a/content/common/android/surface_texture_bridge.cc |
+++ b/content/common/android/surface_texture_bridge.cc |
@@ -6,6 +6,8 @@ |
#include <android/native_window_jni.h> |
+// TODO(boliu): Remove this include when we move off ICS. |
+#include "base/android/build_info.h" |
#include "base/android/jni_android.h" |
#include "base/logging.h" |
#include "content/common/android/surface_texture_listener.h" |
@@ -27,6 +29,16 @@ void RegisterNativesIfNeeded(JNIEnv* env) { |
g_jni_initialized = true; |
} |
} |
+ |
+// TODO(boliu): Remove this method when when we move off ICS. See |
+// http://crbug.com/161864. |
+bool GlContextMethodsAvailable() { |
+ bool available = base::android::BuildInfo::GetInstance()->sdk_int() >= 16; |
+ if (!available) |
+ LOG(WARNING) << "Running on unsupported device: rendering may not work"; |
+ return available; |
+} |
+ |
} // namespace |
namespace content { |
@@ -108,17 +120,21 @@ void SurfaceTextureBridge::SetDefaultBufferSize(int width, int height) { |
} |
void SurfaceTextureBridge::AttachToGLContext(int texture_id) { |
- JNIEnv* env = AttachCurrentThread(); |
- // Note: This method is only available on JB and greater. |
- JNI_SurfaceTexture::Java_SurfaceTexture_attachToGLContext( |
- env, j_surface_texture_.obj(), texture_id); |
+ if (GlContextMethodsAvailable()) { |
+ JNIEnv* env = AttachCurrentThread(); |
+ // Note: This method is only available on JB and greater. |
+ JNI_SurfaceTexture::Java_SurfaceTexture_attachToGLContext( |
+ env, j_surface_texture_.obj(), texture_id); |
+ } |
} |
void SurfaceTextureBridge::DetachFromGLContext() { |
- JNIEnv* env = AttachCurrentThread(); |
- // Note: This method is only available on JB and greater. |
- JNI_SurfaceTexture::Java_SurfaceTexture_detachFromGLContext( |
- env, j_surface_texture_.obj()); |
+ if (GlContextMethodsAvailable()) { |
+ JNIEnv* env = AttachCurrentThread(); |
+ // Note: This method is only available on JB and greater. |
+ JNI_SurfaceTexture::Java_SurfaceTexture_detachFromGLContext( |
+ env, j_surface_texture_.obj()); |
+ } |
} |
ANativeWindow* SurfaceTextureBridge::CreateSurface() { |