Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Side by Side Diff: content/common/android/surface_texture_bridge.cc

Issue 11787031: Fix hang in Android WebView release build tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Factor out check and add LOG(WARNING) when fails. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « android_webview/native/aw_contents.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/common/android/surface_texture_bridge.h" 5 #include "content/common/android/surface_texture_bridge.h"
6 6
7 #include <android/native_window_jni.h> 7 #include <android/native_window_jni.h>
8 8
9 // TODO(boliu): Remove this include when we move off ICS.
10 #include "base/android/build_info.h"
9 #include "base/android/jni_android.h" 11 #include "base/android/jni_android.h"
10 #include "base/logging.h" 12 #include "base/logging.h"
11 #include "content/common/android/surface_texture_listener.h" 13 #include "content/common/android/surface_texture_listener.h"
12 #include "jni/SurfaceTexture_jni.h" 14 #include "jni/SurfaceTexture_jni.h"
13 #include "jni/Surface_jni.h" 15 #include "jni/Surface_jni.h"
14 16
15 using base::android::AttachCurrentThread; 17 using base::android::AttachCurrentThread;
16 using base::android::CheckException; 18 using base::android::CheckException;
17 using base::android::GetClass; 19 using base::android::GetClass;
18 using base::android::ScopedJavaLocalRef; 20 using base::android::ScopedJavaLocalRef;
19 21
20 namespace { 22 namespace {
21 bool g_jni_initialized = false; 23 bool g_jni_initialized = false;
22 24
23 void RegisterNativesIfNeeded(JNIEnv* env) { 25 void RegisterNativesIfNeeded(JNIEnv* env) {
24 if (!g_jni_initialized) { 26 if (!g_jni_initialized) {
25 JNI_SurfaceTexture::RegisterNativesImpl(env); 27 JNI_SurfaceTexture::RegisterNativesImpl(env);
26 JNI_Surface::RegisterNativesImpl(env); 28 JNI_Surface::RegisterNativesImpl(env);
27 g_jni_initialized = true; 29 g_jni_initialized = true;
28 } 30 }
29 } 31 }
32
33 // TODO(boliu): Remove this method when when we move off ICS. See
34 // http://crbug.com/161864.
35 bool GlContextMethodsAvailable() {
36 bool available = base::android::BuildInfo::GetInstance()->sdk_int() >= 16;
37 if (!available)
38 LOG(WARNING) << "Running on unsupported device: rendering may not work";
39 return available;
40 }
41
30 } // namespace 42 } // namespace
31 43
32 namespace content { 44 namespace content {
33 45
34 SurfaceTextureBridge::SurfaceTextureBridge(int texture_id) 46 SurfaceTextureBridge::SurfaceTextureBridge(int texture_id)
35 : texture_id_(texture_id) { 47 : texture_id_(texture_id) {
36 JNIEnv* env = AttachCurrentThread(); 48 JNIEnv* env = AttachCurrentThread();
37 CHECK(env); 49 CHECK(env);
38 RegisterNativesIfNeeded(env); 50 RegisterNativesIfNeeded(env);
39 51
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 void SurfaceTextureBridge::SetDefaultBufferSize(int width, int height) { 113 void SurfaceTextureBridge::SetDefaultBufferSize(int width, int height) {
102 JNIEnv* env = AttachCurrentThread(); 114 JNIEnv* env = AttachCurrentThread();
103 CHECK(env); 115 CHECK(env);
104 116
105 JNI_SurfaceTexture::Java_SurfaceTexture_setDefaultBufferSize( 117 JNI_SurfaceTexture::Java_SurfaceTexture_setDefaultBufferSize(
106 env, j_surface_texture_.obj(), static_cast<jint>(width), 118 env, j_surface_texture_.obj(), static_cast<jint>(width),
107 static_cast<jint>(height)); 119 static_cast<jint>(height));
108 } 120 }
109 121
110 void SurfaceTextureBridge::AttachToGLContext(int texture_id) { 122 void SurfaceTextureBridge::AttachToGLContext(int texture_id) {
111 JNIEnv* env = AttachCurrentThread(); 123 if (GlContextMethodsAvailable()) {
112 // Note: This method is only available on JB and greater. 124 JNIEnv* env = AttachCurrentThread();
113 JNI_SurfaceTexture::Java_SurfaceTexture_attachToGLContext( 125 // Note: This method is only available on JB and greater.
114 env, j_surface_texture_.obj(), texture_id); 126 JNI_SurfaceTexture::Java_SurfaceTexture_attachToGLContext(
127 env, j_surface_texture_.obj(), texture_id);
128 }
115 } 129 }
116 130
117 void SurfaceTextureBridge::DetachFromGLContext() { 131 void SurfaceTextureBridge::DetachFromGLContext() {
118 JNIEnv* env = AttachCurrentThread(); 132 if (GlContextMethodsAvailable()) {
119 // Note: This method is only available on JB and greater. 133 JNIEnv* env = AttachCurrentThread();
120 JNI_SurfaceTexture::Java_SurfaceTexture_detachFromGLContext( 134 // Note: This method is only available on JB and greater.
121 env, j_surface_texture_.obj()); 135 JNI_SurfaceTexture::Java_SurfaceTexture_detachFromGLContext(
136 env, j_surface_texture_.obj());
137 }
122 } 138 }
123 139
124 ANativeWindow* SurfaceTextureBridge::CreateSurface() { 140 ANativeWindow* SurfaceTextureBridge::CreateSurface() {
125 JNIEnv* env = AttachCurrentThread(); 141 JNIEnv* env = AttachCurrentThread();
126 ScopedJavaLocalRef<jobject> jsurface( 142 ScopedJavaLocalRef<jobject> jsurface(
127 JNI_Surface::Java_Surface_Constructor( 143 JNI_Surface::Java_Surface_Constructor(
128 env, j_surface_texture_.obj())); 144 env, j_surface_texture_.obj()));
129 DCHECK(!jsurface.is_null()); 145 DCHECK(!jsurface.is_null());
130 ANativeWindow* native_window = ANativeWindow_fromSurface(env, jsurface.obj()); 146 ANativeWindow* native_window = ANativeWindow_fromSurface(env, jsurface.obj());
131 return native_window; 147 return native_window;
132 } 148 }
133 149
134 } // namespace content 150 } // namespace content
OLDNEW
« no previous file with comments | « android_webview/native/aw_contents.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698