| 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 "base/threading/platform_thread.h" | 8 #include "base/threading/platform_thread.h" |
| 9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
| 10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 jobject obj, | 99 jobject obj, |
| 100 content::WebContents* main_contents, | 100 content::WebContents* main_contents, |
| 101 ui::WindowAndroid* content_window, | 101 ui::WindowAndroid* content_window, |
| 102 content::WebContents* ui_contents, | 102 content::WebContents* ui_contents, |
| 103 ui::WindowAndroid* ui_window, | 103 ui::WindowAndroid* ui_window, |
| 104 bool for_web_vr, | 104 bool for_web_vr, |
| 105 VrShellDelegate* delegate, | 105 VrShellDelegate* delegate, |
| 106 gvr_context* gvr_api) | 106 gvr_context* gvr_api) |
| 107 : WebContentsObserver(ui_contents), | 107 : WebContentsObserver(ui_contents), |
| 108 main_contents_(main_contents), | 108 main_contents_(main_contents), |
| 109 content_compositor_(new VrCompositor(content_window, false)), |
| 109 ui_contents_(ui_contents), | 110 ui_contents_(ui_contents), |
| 111 ui_compositor_(new VrCompositor(ui_window, true)), |
| 110 delegate_(delegate), | 112 delegate_(delegate), |
| 111 metrics_helper_(new VrMetricsHelper(main_contents)), | 113 metrics_helper_(new VrMetricsHelper(main_contents_)), |
| 112 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 114 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 113 weak_ptr_factory_(this) { | 115 weak_ptr_factory_(this) { |
| 114 DCHECK(g_instance == nullptr); | 116 DCHECK(g_instance == nullptr); |
| 115 g_instance = this; | 117 g_instance = this; |
| 116 j_vr_shell_.Reset(env, obj); | 118 j_vr_shell_.Reset(env, obj); |
| 117 | 119 |
| 118 content_input_manager_.reset(new VrInputManager(main_contents_)); | 120 content_input_manager_.reset(new VrInputManager(main_contents_)); |
| 119 ui_input_manager_.reset(new VrInputManager(ui_contents_)); | 121 ui_input_manager_.reset(new VrInputManager(ui_contents_)); |
| 120 | 122 |
| 123 content_compositor_->SetLayer(main_contents_); |
| 124 ui_compositor_->SetLayer(ui_contents_); |
| 125 |
| 121 gl_thread_.reset(new GLThread(this, weak_ptr_factory_.GetWeakPtr(), | 126 gl_thread_.reset(new GLThread(this, weak_ptr_factory_.GetWeakPtr(), |
| 122 content_input_manager_->GetWeakPtr(), | 127 content_input_manager_->GetWeakPtr(), |
| 123 ui_input_manager_->GetWeakPtr(), | 128 ui_input_manager_->GetWeakPtr(), |
| 124 main_thread_task_runner_, | 129 main_thread_task_runner_, |
| 125 gvr_api)); | 130 gvr_api)); |
| 126 | 131 |
| 127 base::Thread::Options options(base::MessageLoop::TYPE_DEFAULT, 0); | 132 base::Thread::Options options(base::MessageLoop::TYPE_DEFAULT, 0); |
| 128 options.priority = base::ThreadPriority::DISPLAY; | 133 options.priority = base::ThreadPriority::DISPLAY; |
| 129 gl_thread_->StartWithOptions(options); | 134 gl_thread_->StartWithOptions(options); |
| 130 | 135 |
| 131 if (for_web_vr) | 136 if (for_web_vr) |
| 132 metrics_helper_->SetWebVREnabled(true); | 137 metrics_helper_->SetWebVREnabled(true); |
| 133 html_interface_.reset(new UiInterface( | 138 html_interface_.reset(new UiInterface( |
| 134 for_web_vr ? UiInterface::Mode::WEB_VR : UiInterface::Mode::STANDARD, | 139 for_web_vr ? UiInterface::Mode::WEB_VR : UiInterface::Mode::STANDARD, |
| 135 main_contents_->IsFullscreen())); | 140 main_contents_->IsFullscreen())); |
| 136 content_compositor_.reset(new VrCompositor(content_window, false)); | |
| 137 content_compositor_->SetLayer(main_contents_); | |
| 138 ui_compositor_.reset(new VrCompositor(ui_window, true)); | |
| 139 ui_compositor_->SetLayer(ui_contents_); | |
| 140 vr_web_contents_observer_.reset(new VrWebContentsObserver( | 141 vr_web_contents_observer_.reset(new VrWebContentsObserver( |
| 141 main_contents, html_interface_.get(), this)); | 142 main_contents, html_interface_.get(), this)); |
| 142 | 143 |
| 143 SetShowingOverscrollGlow(false); | 144 SetShowingOverscrollGlow(false); |
| 144 } | 145 } |
| 145 | 146 |
| 146 void VrShell::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 147 void VrShell::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 147 delete this; | 148 delete this; |
| 148 } | 149 } |
| 149 | 150 |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 return reinterpret_cast<intptr_t>(new VrShell( | 458 return reinterpret_cast<intptr_t>(new VrShell( |
| 458 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), | 459 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), |
| 459 reinterpret_cast<ui::WindowAndroid*>(content_window_android), | 460 reinterpret_cast<ui::WindowAndroid*>(content_window_android), |
| 460 content::WebContents::FromJavaWebContents(ui_web_contents), | 461 content::WebContents::FromJavaWebContents(ui_web_contents), |
| 461 reinterpret_cast<ui::WindowAndroid*>(ui_window_android), | 462 reinterpret_cast<ui::WindowAndroid*>(ui_window_android), |
| 462 for_web_vr, VrShellDelegate::GetNativeDelegate(env, delegate), | 463 for_web_vr, VrShellDelegate::GetNativeDelegate(env, delegate), |
| 463 reinterpret_cast<gvr_context*>(gvr_api))); | 464 reinterpret_cast<gvr_context*>(gvr_api))); |
| 464 } | 465 } |
| 465 | 466 |
| 466 } // namespace vr_shell | 467 } // namespace vr_shell |
| OLD | NEW |