OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/gl/android/surface_texture.h" | 5 #include "ui/gl/android/surface_texture.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. | 9 // TODO(boliu): Remove this include when we move off ICS. |
10 #include "base/android/build_info.h" | 10 #include "base/android/build_info.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 if (GlContextMethodsAvailable()) { | 116 if (GlContextMethodsAvailable()) { |
117 JNIEnv* env = base::android::AttachCurrentThread(); | 117 JNIEnv* env = base::android::AttachCurrentThread(); |
118 Java_SurfaceTexturePlatformWrapper_detachFromGLContext( | 118 Java_SurfaceTexturePlatformWrapper_detachFromGLContext( |
119 env, j_surface_texture_.obj()); | 119 env, j_surface_texture_.obj()); |
120 } | 120 } |
121 } | 121 } |
122 | 122 |
123 ANativeWindow* SurfaceTexture::CreateSurface() { | 123 ANativeWindow* SurfaceTexture::CreateSurface() { |
124 JNIEnv* env = base::android::AttachCurrentThread(); | 124 JNIEnv* env = base::android::AttachCurrentThread(); |
125 ScopedJavaSurface surface(this); | 125 ScopedJavaSurface surface(this); |
| 126 // Note: This ensures that any local references used by |
| 127 // ANativeWindow_fromSurface are released immediately. This is needed as a |
| 128 // workaround for https://code.google.com/p/android/issues/detail?id=68174 |
| 129 base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env); |
126 ANativeWindow* native_window = ANativeWindow_fromSurface( | 130 ANativeWindow* native_window = ANativeWindow_fromSurface( |
127 env, surface.j_surface().obj()); | 131 env, surface.j_surface().obj()); |
128 return native_window; | 132 return native_window; |
129 } | 133 } |
130 | 134 |
131 // static | 135 // static |
132 bool SurfaceTexture::IsSingleBufferModeSupported() { | 136 bool SurfaceTexture::IsSingleBufferModeSupported() { |
133 return base::android::BuildInfo::GetInstance()->sdk_int() >= 19; | 137 return base::android::BuildInfo::GetInstance()->sdk_int() >= 19; |
134 } | 138 } |
135 | 139 |
136 bool SurfaceTexture::RegisterSurfaceTexture(JNIEnv* env) { | 140 bool SurfaceTexture::RegisterSurfaceTexture(JNIEnv* env) { |
137 return RegisterNativesImpl(env); | 141 return RegisterNativesImpl(env); |
138 } | 142 } |
139 | 143 |
140 } // namespace gfx | 144 } // namespace gfx |
OLD | NEW |