Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/android/vr_shell/vr_shell.h" | 5 #include "chrome/browser/android/vr_shell/vr_shell.h" |
| 6 | 6 |
| 7 #include <android/native_window_jni.h> | 7 #include <android/native_window_jni.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 405 WaitForGlThread(); | 405 WaitForGlThread(); |
| 406 PostToGlThread( | 406 PostToGlThread( |
| 407 FROM_HERE, | 407 FROM_HERE, |
| 408 base::Bind(&VrShellGl::SetSubmitClient, gl_thread_->GetVrShellGl(), | 408 base::Bind(&VrShellGl::SetSubmitClient, gl_thread_->GetVrShellGl(), |
| 409 base::Passed(submit_client.PassInterface()))); | 409 base::Passed(submit_client.PassInterface()))); |
| 410 } | 410 } |
| 411 | 411 |
| 412 base::android::ScopedJavaGlobalRef<jobject> VrShell::TakeContentSurface( | 412 base::android::ScopedJavaGlobalRef<jobject> VrShell::TakeContentSurface( |
| 413 JNIEnv* env, | 413 JNIEnv* env, |
| 414 const JavaParamRef<jobject>& obj) { | 414 const JavaParamRef<jobject>& obj) { |
| 415 if (!content_surface_) { | |
| 416 return base::android::ScopedJavaGlobalRef<jobject>(env, nullptr); | |
| 417 } | |
| 418 taken_surface_ = true; | |
| 415 compositor_->SurfaceChanged(nullptr); | 419 compositor_->SurfaceChanged(nullptr); |
| 416 base::android::ScopedJavaGlobalRef<jobject> surface(env, content_surface_); | 420 base::android::ScopedJavaGlobalRef<jobject> surface(env, content_surface_); |
| 417 content_surface_ = nullptr; | 421 content_surface_ = nullptr; |
| 418 return surface; | 422 return surface; |
| 419 } | 423 } |
| 420 | 424 |
| 421 void VrShell::RestoreContentSurface(JNIEnv* env, | 425 void VrShell::RestoreContentSurface(JNIEnv* env, |
| 422 const JavaParamRef<jobject>& obj) { | 426 const JavaParamRef<jobject>& obj) { |
| 427 // Don't try to restore the surface if we haven't successfully taken it yet. | |
| 428 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.
| |
| 429 return; | |
| 423 WaitForGlThread(); | 430 WaitForGlThread(); |
| 424 PostToGlThread(FROM_HERE, base::Bind(&VrShellGl::CreateContentSurface, | 431 PostToGlThread(FROM_HERE, base::Bind(&VrShellGl::CreateContentSurface, |
| 425 gl_thread_->GetVrShellGl())); | 432 gl_thread_->GetVrShellGl())); |
| 426 } | 433 } |
| 427 | 434 |
| 428 void VrShell::SetHistoryButtonsEnabled(JNIEnv* env, | 435 void VrShell::SetHistoryButtonsEnabled(JNIEnv* env, |
| 429 const JavaParamRef<jobject>& obj, | 436 const JavaParamRef<jobject>& obj, |
| 430 jboolean can_go_back, | 437 jboolean can_go_back, |
| 431 jboolean can_go_forward) { | 438 jboolean can_go_forward) { |
| 432 ui_->SetHistoryButtonsEnabled(can_go_back, can_go_forward); | 439 ui_->SetHistoryButtonsEnabled(can_go_back, can_go_forward); |
| 433 } | 440 } |
| 434 | 441 |
| 435 void VrShell::ContentSurfaceChanged(jobject surface) { | 442 void VrShell::ContentSurfaceChanged(jobject surface) { |
| 436 content_surface_ = surface; | 443 content_surface_ = surface; |
| 437 compositor_->SurfaceChanged(surface); | |
| 438 JNIEnv* env = base::android::AttachCurrentThread(); | 444 JNIEnv* env = base::android::AttachCurrentThread(); |
| 439 Java_VrShellImpl_contentSurfaceChanged(env, j_vr_shell_.obj()); | 445 Java_VrShellImpl_contentSurfaceChanged(env, j_vr_shell_.obj()); |
| 446 compositor_->SurfaceChanged(content_surface_); | |
| 440 } | 447 } |
| 441 | 448 |
| 442 void VrShell::GvrDelegateReady() { | 449 void VrShell::GvrDelegateReady() { |
| 443 delegate_provider_->SetPresentingDelegate(this, gvr_api_); | 450 delegate_provider_->SetPresentingDelegate(this, gvr_api_); |
| 444 } | 451 } |
| 445 | 452 |
| 446 void VrShell::OnPhysicalBackingSizeChanged( | 453 void VrShell::OnPhysicalBackingSizeChanged( |
| 447 JNIEnv* env, | 454 JNIEnv* env, |
| 448 const JavaParamRef<jobject>& obj, | 455 const JavaParamRef<jobject>& obj, |
| 449 const JavaParamRef<jobject>& jweb_contents, | 456 const JavaParamRef<jobject>& jweb_contents, |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 650 jlong gvr_api, | 657 jlong gvr_api, |
| 651 jboolean reprojected_rendering) { | 658 jboolean reprojected_rendering) { |
| 652 return reinterpret_cast<intptr_t>(new VrShell( | 659 return reinterpret_cast<intptr_t>(new VrShell( |
| 653 env, obj, reinterpret_cast<ui::WindowAndroid*>(window_android), | 660 env, obj, reinterpret_cast<ui::WindowAndroid*>(window_android), |
| 654 for_web_vr, in_cct, | 661 for_web_vr, in_cct, |
| 655 VrShellDelegate::GetNativeVrShellDelegate(env, delegate), | 662 VrShellDelegate::GetNativeVrShellDelegate(env, delegate), |
| 656 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); | 663 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); |
| 657 } | 664 } |
| 658 | 665 |
| 659 } // namespace vr_shell | 666 } // namespace vr_shell |
| OLD | NEW |