Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: chrome/browser/android/vr_shell/vr_shell.cc

Issue 2524423002: VR: Disable Overscroll Glow in VrShell (Closed)
Patch Set: Fix thread issue + Rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "chrome/browser/android/vr_shell/vr_compositor.h" 11 #include "chrome/browser/android/vr_shell/vr_compositor.h"
12 #include "chrome/browser/android/vr_shell/vr_controller.h" 12 #include "chrome/browser/android/vr_shell/vr_controller.h"
13 #include "chrome/browser/android/vr_shell/vr_gl_util.h" 13 #include "chrome/browser/android/vr_shell/vr_gl_util.h"
14 #include "chrome/browser/android/vr_shell/vr_input_manager.h" 14 #include "chrome/browser/android/vr_shell/vr_input_manager.h"
15 #include "chrome/browser/android/vr_shell/vr_shell_delegate.h" 15 #include "chrome/browser/android/vr_shell/vr_shell_delegate.h"
16 #include "chrome/browser/android/vr_shell/vr_shell_renderer.h" 16 #include "chrome/browser/android/vr_shell/vr_shell_renderer.h"
17 #include "chrome/browser/android/vr_shell/vr_usage_monitor.h" 17 #include "chrome/browser/android/vr_shell/vr_usage_monitor.h"
18 #include "chrome/browser/android/vr_shell/vr_web_contents_observer.h" 18 #include "chrome/browser/android/vr_shell/vr_web_contents_observer.h"
19 #include "content/public/browser/browser_thread.h"
bshe 2016/12/05 19:25:56 nit: this include isn't necessary anymore
asimjour1 2016/12/05 19:37:30 Done.
19 #include "content/public/browser/navigation_controller.h" 20 #include "content/public/browser/navigation_controller.h"
20 #include "content/public/browser/render_view_host.h" 21 #include "content/public/browser/render_view_host.h"
21 #include "content/public/browser/render_widget_host.h" 22 #include "content/public/browser/render_widget_host.h"
22 #include "content/public/browser/render_widget_host_view.h" 23 #include "content/public/browser/render_widget_host_view.h"
23 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
24 #include "content/public/common/referrer.h" 25 #include "content/public/common/referrer.h"
25 #include "device/vr/android/gvr/gvr_device_provider.h" 26 #include "device/vr/android/gvr/gvr_device_provider.h"
26 #include "jni/VrShellImpl_jni.h" 27 #include "jni/VrShellImpl_jni.h"
27 #include "ui/android/view_android.h" 28 #include "ui/android/view_android.h"
28 #include "ui/android/window_android.h" 29 #include "ui/android/window_android.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 182
182 gvr::Mat4f identity; 183 gvr::Mat4f identity;
183 SetIdentityM(identity); 184 SetIdentityM(identity);
184 webvr_head_pose_.resize(kPoseRingBufferSize, identity); 185 webvr_head_pose_.resize(kPoseRingBufferSize, identity);
185 webvr_head_pose_valid_.resize(kPoseRingBufferSize, false); 186 webvr_head_pose_valid_.resize(kPoseRingBufferSize, false);
186 187
187 content_input_manager_.reset(new VrInputManager(main_contents_)); 188 content_input_manager_.reset(new VrInputManager(main_contents_));
188 ui_input_manager_.reset(new VrInputManager(ui_contents_)); 189 ui_input_manager_.reset(new VrInputManager(ui_contents_));
189 weak_content_input_manager_ = content_input_manager_->GetWeakPtr(); 190 weak_content_input_manager_ = content_input_manager_->GetWeakPtr();
190 weak_ui_input_manager_ = ui_input_manager_->GetWeakPtr(); 191 weak_ui_input_manager_ = ui_input_manager_->GetWeakPtr();
192
193 SetShowingOverscrollGlow(false);
191 } 194 }
192 195
193 void VrShell::UpdateCompositorLayers(JNIEnv* env, 196 void VrShell::UpdateCompositorLayers(JNIEnv* env,
194 const JavaParamRef<jobject>& obj) { 197 const JavaParamRef<jobject>& obj) {
195 content_compositor_->SetLayer(main_contents_); 198 content_compositor_->SetLayer(main_contents_);
196 ui_compositor_->SetLayer(ui_contents_); 199 ui_compositor_->SetLayer(ui_contents_);
197 } 200 }
198 201
199 void VrShell::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) { 202 void VrShell::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) {
200 delete this; 203 delete this;
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 void VrShell::OnTriggerEvent(JNIEnv* env, const JavaParamRef<jobject>& obj) { 933 void VrShell::OnTriggerEvent(JNIEnv* env, const JavaParamRef<jobject>& obj) {
931 // Set a flag to handle this on the render thread at the next frame. 934 // Set a flag to handle this on the render thread at the next frame.
932 touch_pending_ = true; 935 touch_pending_ = true;
933 } 936 }
934 937
935 void VrShell::OnPause(JNIEnv* env, const JavaParamRef<jobject>& obj) { 938 void VrShell::OnPause(JNIEnv* env, const JavaParamRef<jobject>& obj) {
936 if (gvr_api_ == nullptr) 939 if (gvr_api_ == nullptr)
937 return; 940 return;
938 controller_->OnPause(); 941 controller_->OnPause();
939 gvr_api_->PauseTracking(); 942 gvr_api_->PauseTracking();
943 SetShowingOverscrollGlow(true);
940 944
941 // exit vr session 945 // exit vr session
942 metrics_helper_->SetVRActive(false); 946 metrics_helper_->SetVRActive(false);
943 } 947 }
944 948
945 void VrShell::OnResume(JNIEnv* env, const JavaParamRef<jobject>& obj) { 949 void VrShell::OnResume(JNIEnv* env, const JavaParamRef<jobject>& obj) {
946 if (gvr_api_ == nullptr) 950 if (gvr_api_ == nullptr)
947 return; 951 return;
948 952
949 gvr_api_->RefreshViewerProfile(); 953 gvr_api_->RefreshViewerProfile();
950 gvr_api_->ResumeTracking(); 954 gvr_api_->ResumeTracking();
951 controller_->OnResume(); 955 controller_->OnResume();
956 SetShowingOverscrollGlow(false);
952 957
953 // exit vr session 958 // exit vr session
954 metrics_helper_->SetVRActive(true); 959 metrics_helper_->SetVRActive(true);
955 } 960 }
956 961
962 void VrShell::SetShowingOverscrollGlow(bool showing_glow) {
963 main_contents_->GetRenderWidgetHostView()->SetShowingOverscrollGlow(
964 showing_glow);
965 }
966
957 base::WeakPtr<VrShell> VrShell::GetWeakPtr( 967 base::WeakPtr<VrShell> VrShell::GetWeakPtr(
958 const content::WebContents* web_contents) { 968 const content::WebContents* web_contents) {
959 // Ensure that the WebContents requesting the VrShell instance is the one 969 // Ensure that the WebContents requesting the VrShell instance is the one
960 // we created. 970 // we created.
961 if (g_instance != nullptr && g_instance->ui_contents_ == web_contents) 971 if (g_instance != nullptr && g_instance->ui_contents_ == web_contents)
962 return g_instance->weak_ptr_factory_.GetWeakPtr(); 972 return g_instance->weak_ptr_factory_.GetWeakPtr();
963 return base::WeakPtr<VrShell>(nullptr); 973 return base::WeakPtr<VrShell>(nullptr);
964 } 974 }
965 975
966 void VrShell::OnDomContentsLoaded() { 976 void VrShell::OnDomContentsLoaded() {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 jboolean for_web_vr) { 1155 jboolean for_web_vr) {
1146 return reinterpret_cast<intptr_t>(new VrShell( 1156 return reinterpret_cast<intptr_t>(new VrShell(
1147 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), 1157 env, obj, content::WebContents::FromJavaWebContents(content_web_contents),
1148 reinterpret_cast<ui::WindowAndroid*>(content_window_android), 1158 reinterpret_cast<ui::WindowAndroid*>(content_window_android),
1149 content::WebContents::FromJavaWebContents(ui_web_contents), 1159 content::WebContents::FromJavaWebContents(ui_web_contents),
1150 reinterpret_cast<ui::WindowAndroid*>(ui_window_android), 1160 reinterpret_cast<ui::WindowAndroid*>(ui_window_android),
1151 for_web_vr)); 1161 for_web_vr));
1152 } 1162 }
1153 1163
1154 } // namespace vr_shell 1164 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698