| 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 "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
| 8 #include "chrome/browser/android/vr_shell/ui_elements.h" | 8 #include "chrome/browser/android/vr_shell/ui_elements.h" |
| 9 #include "chrome/browser/android/vr_shell/ui_interface.h" | 9 #include "chrome/browser/android/vr_shell/ui_interface.h" |
| 10 #include "chrome/browser/android/vr_shell/ui_scene.h" | 10 #include "chrome/browser/android/vr_shell/ui_scene.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 181 |
| 182 gvr::Mat4f identity; | 182 gvr::Mat4f identity; |
| 183 SetIdentityM(identity); | 183 SetIdentityM(identity); |
| 184 webvr_head_pose_.resize(kPoseRingBufferSize, identity); | 184 webvr_head_pose_.resize(kPoseRingBufferSize, identity); |
| 185 webvr_head_pose_valid_.resize(kPoseRingBufferSize, false); | 185 webvr_head_pose_valid_.resize(kPoseRingBufferSize, false); |
| 186 | 186 |
| 187 content_input_manager_.reset(new VrInputManager(main_contents_)); | 187 content_input_manager_.reset(new VrInputManager(main_contents_)); |
| 188 ui_input_manager_.reset(new VrInputManager(ui_contents_)); | 188 ui_input_manager_.reset(new VrInputManager(ui_contents_)); |
| 189 weak_content_input_manager_ = content_input_manager_->GetWeakPtr(); | 189 weak_content_input_manager_ = content_input_manager_->GetWeakPtr(); |
| 190 weak_ui_input_manager_ = ui_input_manager_->GetWeakPtr(); | 190 weak_ui_input_manager_ = ui_input_manager_->GetWeakPtr(); |
| 191 |
| 192 SetShowingOverscrollGlowOnUI(false); |
| 191 } | 193 } |
| 192 | 194 |
| 193 void VrShell::UpdateCompositorLayersOnUI(JNIEnv* env, | 195 void VrShell::UpdateCompositorLayersOnUI(JNIEnv* env, |
| 194 const JavaParamRef<jobject>& obj) { | 196 const JavaParamRef<jobject>& obj) { |
| 195 content_compositor_->SetLayer(main_contents_); | 197 content_compositor_->SetLayer(main_contents_); |
| 196 ui_compositor_->SetLayer(ui_contents_); | 198 ui_compositor_->SetLayer(ui_contents_); |
| 197 } | 199 } |
| 198 | 200 |
| 199 void VrShell::DestroyOnUI(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 201 void VrShell::DestroyOnUI(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 200 delete this; | 202 delete this; |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 touch_pending_ = true; | 934 touch_pending_ = true; |
| 933 } | 935 } |
| 934 | 936 |
| 935 void VrShell::OnPauseOnUI(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 937 void VrShell::OnPauseOnUI(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 936 if (gvr_api_ == nullptr) | 938 if (gvr_api_ == nullptr) |
| 937 return; | 939 return; |
| 938 | 940 |
| 939 // TODO(mthiesse): Clean up threading here. | 941 // TODO(mthiesse): Clean up threading here. |
| 940 controller_->OnPause(); | 942 controller_->OnPause(); |
| 941 gvr_api_->PauseTracking(); | 943 gvr_api_->PauseTracking(); |
| 944 SetShowingOverscrollGlowOnUI(true); |
| 942 | 945 |
| 943 // exit vr session | 946 // exit vr session |
| 944 metrics_helper_->SetVRActive(false); | 947 metrics_helper_->SetVRActive(false); |
| 945 } | 948 } |
| 946 | 949 |
| 947 void VrShell::OnResumeOnUI(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 950 void VrShell::OnResumeOnUI(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 948 if (gvr_api_ == nullptr) | 951 if (gvr_api_ == nullptr) |
| 949 return; | 952 return; |
| 950 | 953 |
| 951 // TODO(mthiesse): Clean up threading here. | 954 // TODO(mthiesse): Clean up threading here. |
| 952 gvr_api_->RefreshViewerProfile(); | 955 gvr_api_->RefreshViewerProfile(); |
| 953 gvr_api_->ResumeTracking(); | 956 gvr_api_->ResumeTracking(); |
| 954 controller_->OnResume(); | 957 controller_->OnResume(); |
| 958 SetShowingOverscrollGlowOnUI(false); |
| 955 | 959 |
| 956 // exit vr session | 960 // exit vr session |
| 957 metrics_helper_->SetVRActive(true); | 961 metrics_helper_->SetVRActive(true); |
| 958 } | 962 } |
| 959 | 963 |
| 964 void VrShell::SetShowingOverscrollGlowOnUI(bool showing_glow) { |
| 965 main_contents_->GetRenderWidgetHostView()->SetShowingOverscrollGlow( |
| 966 showing_glow); |
| 967 } |
| 968 |
| 960 base::WeakPtr<VrShell> VrShell::GetWeakPtrOnUI( | 969 base::WeakPtr<VrShell> VrShell::GetWeakPtrOnUI( |
| 961 const content::WebContents* web_contents) { | 970 const content::WebContents* web_contents) { |
| 962 // Ensure that the WebContents requesting the VrShell instance is the one | 971 // Ensure that the WebContents requesting the VrShell instance is the one |
| 963 // we created. | 972 // we created. |
| 964 if (g_instance != nullptr && g_instance->ui_contents_ == web_contents) | 973 if (g_instance != nullptr && g_instance->ui_contents_ == web_contents) |
| 965 return g_instance->weak_ptr_factory_.GetWeakPtr(); | 974 return g_instance->weak_ptr_factory_.GetWeakPtr(); |
| 966 return base::WeakPtr<VrShell>(nullptr); | 975 return base::WeakPtr<VrShell>(nullptr); |
| 967 } | 976 } |
| 968 | 977 |
| 969 void VrShell::OnDomContentsLoadedOnUI() { | 978 void VrShell::OnDomContentsLoadedOnUI() { |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1149 jboolean for_web_vr) { | 1158 jboolean for_web_vr) { |
| 1150 return reinterpret_cast<intptr_t>(new VrShell( | 1159 return reinterpret_cast<intptr_t>(new VrShell( |
| 1151 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), | 1160 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), |
| 1152 reinterpret_cast<ui::WindowAndroid*>(content_window_android), | 1161 reinterpret_cast<ui::WindowAndroid*>(content_window_android), |
| 1153 content::WebContents::FromJavaWebContents(ui_web_contents), | 1162 content::WebContents::FromJavaWebContents(ui_web_contents), |
| 1154 reinterpret_cast<ui::WindowAndroid*>(ui_window_android), | 1163 reinterpret_cast<ui::WindowAndroid*>(ui_window_android), |
| 1155 for_web_vr)); | 1164 for_web_vr)); |
| 1156 } | 1165 } |
| 1157 | 1166 |
| 1158 } // namespace vr_shell | 1167 } // namespace vr_shell |
| OLD | NEW |