Chromium Code Reviews| Index: chrome/browser/android/vr_shell/vr_shell.cc |
| diff --git a/chrome/browser/android/vr_shell/vr_shell.cc b/chrome/browser/android/vr_shell/vr_shell.cc |
| index db0123e8b4b3e6b3fad28fa193a8c02f8ad3145d..cc6884e0c60d3a67fdfe4124f0cc3127e3054bcd 100644 |
| --- a/chrome/browser/android/vr_shell/vr_shell.cc |
| +++ b/chrome/browser/android/vr_shell/vr_shell.cc |
| @@ -412,6 +412,10 @@ void VrShell::SetSubmitClient( |
| base::android::ScopedJavaGlobalRef<jobject> VrShell::TakeContentSurface( |
| JNIEnv* env, |
| const JavaParamRef<jobject>& obj) { |
| + if (!content_surface_) { |
| + return base::android::ScopedJavaGlobalRef<jobject>(env, nullptr); |
| + } |
| + taken_surface_ = true; |
| compositor_->SurfaceChanged(nullptr); |
| base::android::ScopedJavaGlobalRef<jobject> surface(env, content_surface_); |
| content_surface_ = nullptr; |
| @@ -420,6 +424,9 @@ base::android::ScopedJavaGlobalRef<jobject> VrShell::TakeContentSurface( |
| void VrShell::RestoreContentSurface(JNIEnv* env, |
| const JavaParamRef<jobject>& obj) { |
| + // Don't try to restore the surface if we haven't successfully taken it yet. |
| + if (!taken_surface_) |
|
ymalik
2017/05/19 17:23:34
should we be restoring taken_surface_ to false?
mthiesse
2017/05/19 17:59:09
Oops yes.
|
| + return; |
| WaitForGlThread(); |
| PostToGlThread(FROM_HERE, base::Bind(&VrShellGl::CreateContentSurface, |
| gl_thread_->GetVrShellGl())); |
| @@ -434,9 +441,9 @@ void VrShell::SetHistoryButtonsEnabled(JNIEnv* env, |
| void VrShell::ContentSurfaceChanged(jobject surface) { |
| content_surface_ = surface; |
| - compositor_->SurfaceChanged(surface); |
| JNIEnv* env = base::android::AttachCurrentThread(); |
| Java_VrShellImpl_contentSurfaceChanged(env, j_vr_shell_.obj()); |
| + compositor_->SurfaceChanged(content_surface_); |
| } |
| void VrShell::GvrDelegateReady() { |