| Index: ui/gl/android/surface_texture.cc
|
| diff --git a/ui/gl/android/surface_texture.cc b/ui/gl/android/surface_texture.cc
|
| index 309e55b765fbcc1336dac50f7309bf3787430d38..2cd25173d61bd8fc333a61308402b11280f65ba4 100644
|
| --- a/ui/gl/android/surface_texture.cc
|
| +++ b/ui/gl/android/surface_texture.cc
|
| @@ -16,9 +16,13 @@
|
| namespace gl {
|
|
|
| scoped_refptr<SurfaceTexture> SurfaceTexture::Create(int texture_id) {
|
| + return new SurfaceTexture(CreateJavaSurfaceTexture(texture_id));
|
| +}
|
| +
|
| +base::android::ScopedJavaLocalRef<jobject>
|
| +SurfaceTexture::CreateJavaSurfaceTexture(int texture_id) {
|
| JNIEnv* env = base::android::AttachCurrentThread();
|
| - return new SurfaceTexture(
|
| - Java_SurfaceTexturePlatformWrapper_create(env, texture_id));
|
| + return Java_SurfaceTexturePlatformWrapper_create(env, texture_id);
|
| }
|
|
|
| SurfaceTexture::SurfaceTexture(
|
| @@ -27,8 +31,16 @@ SurfaceTexture::SurfaceTexture(
|
| }
|
|
|
| SurfaceTexture::~SurfaceTexture() {
|
| + DestroyJavaObject();
|
| +}
|
| +
|
| +void SurfaceTexture::DestroyJavaObject() {
|
| + if (j_surface_texture_.is_null())
|
| + return;
|
| +
|
| JNIEnv* env = base::android::AttachCurrentThread();
|
| Java_SurfaceTexturePlatformWrapper_destroy(env, j_surface_texture_);
|
| + j_surface_texture_.Reset();
|
| }
|
|
|
| void SurfaceTexture::SetFrameAvailableCallback(
|
|
|