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 "mojo/services/native_viewport/native_viewport_android.h" | 5 #include "mojo/services/native_viewport/native_viewport_android.h" |
6 | 6 |
7 #include <android/input.h> | 7 #include <android/input.h> |
8 #include <android/native_window_jni.h> | 8 #include <android/native_window_jni.h> |
9 | 9 |
10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 } | 53 } |
54 | 54 |
55 void NativeViewportAndroid::Destroy(JNIEnv* env, jobject obj) { | 55 void NativeViewportAndroid::Destroy(JNIEnv* env, jobject obj) { |
56 delegate_->OnDestroyed(); | 56 delegate_->OnDestroyed(); |
57 } | 57 } |
58 | 58 |
59 void NativeViewportAndroid::SurfaceCreated(JNIEnv* env, | 59 void NativeViewportAndroid::SurfaceCreated(JNIEnv* env, |
60 jobject obj, | 60 jobject obj, |
61 jobject jsurface) { | 61 jobject jsurface) { |
62 base::android::ScopedJavaLocalRef<jobject> protector(env, jsurface); | 62 base::android::ScopedJavaLocalRef<jobject> protector(env, jsurface); |
63 window_ = ANativeWindow_fromSurface(env, jsurface); | 63 // Note: This ensures that any local references used by |
| 64 // ANativeWindow_fromSurface are released immediately. This is needed as a |
| 65 // workaround for https://code.google.com/p/android/issues/detail?id=68174 |
| 66 { |
| 67 base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env); |
| 68 window_ = ANativeWindow_fromSurface(env, jsurface); |
| 69 } |
64 delegate_->OnAcceleratedWidgetAvailable(window_); | 70 delegate_->OnAcceleratedWidgetAvailable(window_); |
65 } | 71 } |
66 | 72 |
67 void NativeViewportAndroid::SurfaceDestroyed(JNIEnv* env, jobject obj) { | 73 void NativeViewportAndroid::SurfaceDestroyed(JNIEnv* env, jobject obj) { |
68 DCHECK(window_); | 74 DCHECK(window_); |
69 ReleaseWindow(); | 75 ReleaseWindow(); |
70 } | 76 } |
71 | 77 |
72 void NativeViewportAndroid::SurfaceSetSize(JNIEnv* env, jobject obj, | 78 void NativeViewportAndroid::SurfaceSetSize(JNIEnv* env, jobject obj, |
73 jint width, jint height) { | 79 jint width, jint height) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 // static | 152 // static |
147 scoped_ptr<NativeViewport> NativeViewport::Create( | 153 scoped_ptr<NativeViewport> NativeViewport::Create( |
148 shell::Context* context, | 154 shell::Context* context, |
149 NativeViewportDelegate* delegate) { | 155 NativeViewportDelegate* delegate) { |
150 return scoped_ptr<NativeViewport>( | 156 return scoped_ptr<NativeViewport>( |
151 new NativeViewportAndroid(context, delegate)).Pass(); | 157 new NativeViewportAndroid(context, delegate)).Pass(); |
152 } | 158 } |
153 | 159 |
154 } // namespace services | 160 } // namespace services |
155 } // namespace mojo | 161 } // namespace mojo |
OLD | NEW |