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 "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
| 11 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
| 12 #include "base/threading/thread_restrictions.h" | 12 #include "base/threading/thread_restrictions.h" |
| 13 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/browser/android/vr_shell/ui_interface.h" | 15 #include "chrome/browser/android/vr_shell/ui_interface.h" |
| 16 #include "chrome/browser/android/vr_shell/vr_compositor.h" | 16 #include "chrome/browser/android/vr_shell/vr_compositor.h" |
| 17 #include "chrome/browser/android/vr_shell/vr_input_manager.h" | 17 #include "chrome/browser/android/vr_shell/vr_input_manager.h" |
| 18 #include "chrome/browser/android/vr_shell/vr_shell_delegate.h" | 18 #include "chrome/browser/android/vr_shell/vr_shell_delegate.h" |
| 19 #include "chrome/browser/android/vr_shell/vr_shell_gl.h" | 19 #include "chrome/browser/android/vr_shell/vr_shell_gl.h" |
| 20 #include "chrome/browser/android/vr_shell/vr_usage_monitor.h" | 20 #include "chrome/browser/android/vr_shell/vr_usage_monitor.h" |
| 21 #include "chrome/browser/android/vr_shell/vr_web_contents_observer.h" | 21 #include "chrome/browser/android/vr_shell/vr_web_contents_observer.h" |
| 22 #include "content/public/browser/navigation_controller.h" | 22 #include "content/public/browser/navigation_controller.h" |
| 23 #include "content/public/browser/render_view_host.h" | 23 #include "content/public/browser/render_view_host.h" |
| 24 #include "content/public/browser/render_widget_host.h" | 24 #include "content/public/browser/render_widget_host.h" |
| 25 #include "content/public/browser/render_widget_host_view.h" | 25 #include "content/public/browser/render_widget_host_view.h" |
| 26 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 27 #include "content/public/common/referrer.h" | 27 #include "content/public/common/referrer.h" |
| 28 #include "device/vr/android/gvr/gvr_device_provider.h" | 28 #include "device/vr/android/gvr/gvr_device_provider.h" |
| 29 #include "jni/VrShellImpl_jni.h" | 29 #include "jni/VrShellImpl_jni.h" |
| 30 #include "third_party/WebKit/public/platform/WebInputEvent.h" | |
| 30 #include "ui/android/view_android.h" | 31 #include "ui/android/view_android.h" |
| 31 #include "ui/android/window_android.h" | 32 #include "ui/android/window_android.h" |
| 32 #include "ui/base/page_transition_types.h" | 33 #include "ui/base/page_transition_types.h" |
| 33 #include "ui/display/display.h" | 34 #include "ui/display/display.h" |
| 34 #include "ui/display/screen.h" | 35 #include "ui/display/screen.h" |
| 35 | 36 |
| 36 using base::android::JavaParamRef; | 37 using base::android::JavaParamRef; |
| 37 using base::android::JavaRef; | 38 using base::android::JavaRef; |
| 38 | 39 |
| 39 namespace vr_shell { | 40 namespace vr_shell { |
| 40 | 41 |
| 41 namespace { | 42 namespace { |
| 42 vr_shell::VrShell* g_instance; | 43 vr_shell::VrShell* g_instance; |
| 43 | 44 |
| 44 static const char kVrShellUIURL[] = "chrome://vr-shell-ui"; | 45 static const char kVrShellUIURL[] = "chrome://vr-shell-ui"; |
| 45 | 46 |
| 46 class GLThread : public base::Thread { | 47 class GLThread : public base::Thread { |
| 47 public: | 48 public: |
| 48 GLThread(const base::WeakPtr<VrShell>& weak_vr_shell, | 49 GLThread(const base::WeakPtr<VrShell>& weak_vr_shell, |
| 49 const base::WeakPtr<VrInputManager>& content_input_manager, | |
| 50 const base::WeakPtr<VrInputManager>& ui_input_manager, | |
| 51 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, | 50 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, |
| 52 gvr_context* gvr_api, | 51 gvr_context* gvr_api, |
| 53 bool initially_web_vr, | 52 bool initially_web_vr, |
| 54 bool reprojected_rendering) | 53 bool reprojected_rendering) |
| 55 : base::Thread("VrShellGL"), | 54 : base::Thread("VrShellGL"), |
| 56 weak_vr_shell_(weak_vr_shell), | 55 weak_vr_shell_(weak_vr_shell), |
| 57 content_input_manager_(content_input_manager), | |
| 58 ui_input_manager_(ui_input_manager), | |
| 59 main_thread_task_runner_(std::move(main_thread_task_runner)), | 56 main_thread_task_runner_(std::move(main_thread_task_runner)), |
| 60 gvr_api_(gvr_api), | 57 gvr_api_(gvr_api), |
| 61 initially_web_vr_(initially_web_vr), | 58 initially_web_vr_(initially_web_vr), |
| 62 reprojected_rendering_(reprojected_rendering) {} | 59 reprojected_rendering_(reprojected_rendering) {} |
| 63 | 60 |
| 64 ~GLThread() override { | 61 ~GLThread() override { |
| 65 Stop(); | 62 Stop(); |
| 66 } | 63 } |
| 67 base::WeakPtr<VrShellGl> GetVrShellGl() { return weak_vr_shell_gl_; } | 64 base::WeakPtr<VrShellGl> GetVrShellGl() { return weak_vr_shell_gl_; } |
| 68 VrShellGl* GetVrShellGlUnsafe() { return vr_shell_gl_.get(); } | 65 VrShellGl* GetVrShellGlUnsafe() { return vr_shell_gl_.get(); } |
| 69 | 66 |
| 70 protected: | 67 protected: |
| 71 void Init() override { | 68 void Init() override { |
| 72 vr_shell_gl_.reset(new VrShellGl(std::move(weak_vr_shell_), | 69 vr_shell_gl_.reset(new VrShellGl(std::move(weak_vr_shell_), |
| 73 std::move(content_input_manager_), | |
| 74 std::move(ui_input_manager_), | |
| 75 std::move(main_thread_task_runner_), | 70 std::move(main_thread_task_runner_), |
| 76 gvr_api_, | 71 gvr_api_, |
| 77 initially_web_vr_, | 72 initially_web_vr_, |
| 78 reprojected_rendering_)); | 73 reprojected_rendering_)); |
| 79 weak_vr_shell_gl_ = vr_shell_gl_->GetWeakPtr(); | 74 weak_vr_shell_gl_ = vr_shell_gl_->GetWeakPtr(); |
| 80 vr_shell_gl_->Initialize(); | 75 vr_shell_gl_->Initialize(); |
| 81 } | 76 } |
| 82 void CleanUp() override { | 77 void CleanUp() override { |
| 83 vr_shell_gl_.reset(); | 78 vr_shell_gl_.reset(); |
| 84 } | 79 } |
| 85 | 80 |
| 86 private: | 81 private: |
| 87 // Created on GL thread. | 82 // Created on GL thread. |
| 88 std::unique_ptr<VrShellGl> vr_shell_gl_; | 83 std::unique_ptr<VrShellGl> vr_shell_gl_; |
| 89 base::WeakPtr<VrShellGl> weak_vr_shell_gl_; | 84 base::WeakPtr<VrShellGl> weak_vr_shell_gl_; |
| 90 | 85 |
| 91 base::WeakPtr<VrShell> weak_vr_shell_; | 86 base::WeakPtr<VrShell> weak_vr_shell_; |
| 92 base::WeakPtr<VrInputManager> content_input_manager_; | |
| 93 base::WeakPtr<VrInputManager> ui_input_manager_; | |
| 94 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | 87 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
| 95 gvr_context* gvr_api_; | 88 gvr_context* gvr_api_; |
| 96 bool initially_web_vr_; | 89 bool initially_web_vr_; |
| 97 bool reprojected_rendering_; | 90 bool reprojected_rendering_; |
| 98 }; | 91 }; |
| 99 | 92 |
| 93 void SetIsInVR(content::WebContents* contents, bool is_in_vr) { | |
| 94 if (contents->GetRenderWidgetHostView()) | |
| 95 contents->GetRenderWidgetHostView()->SetIsInVR(is_in_vr); | |
| 96 } | |
| 97 | |
| 100 } // namespace | 98 } // namespace |
| 101 | 99 |
| 102 VrShell::VrShell(JNIEnv* env, | 100 VrShell::VrShell(JNIEnv* env, |
| 103 jobject obj, | 101 jobject obj, |
| 104 content::WebContents* main_contents, | 102 content::WebContents* main_contents, |
| 105 ui::WindowAndroid* content_window, | 103 ui::WindowAndroid* content_window, |
| 106 content::WebContents* ui_contents, | 104 content::WebContents* ui_contents, |
| 107 ui::WindowAndroid* ui_window, | 105 ui::WindowAndroid* ui_window, |
| 108 bool for_web_vr, | 106 bool for_web_vr, |
| 109 VrShellDelegate* delegate, | 107 VrShellDelegate* delegate, |
| 110 gvr_context* gvr_api, | 108 gvr_context* gvr_api, |
| 111 bool reprojected_rendering) | 109 bool reprojected_rendering) |
| 112 : WebContentsObserver(ui_contents), | 110 : WebContentsObserver(ui_contents), |
| 113 main_contents_(main_contents), | 111 main_contents_(main_contents), |
| 114 content_compositor_(new VrCompositor(content_window, false)), | 112 content_compositor_( |
| 113 base::MakeUnique<VrCompositor>(content_window, false)), | |
| 115 ui_contents_(ui_contents), | 114 ui_contents_(ui_contents), |
| 116 ui_compositor_(new VrCompositor(ui_window, true)), | 115 ui_compositor_(base::MakeUnique<VrCompositor>(ui_window, true)), |
| 117 delegate_(delegate), | 116 delegate_(delegate), |
| 118 metrics_helper_(new VrMetricsHelper(main_contents_)), | 117 metrics_helper_(base::MakeUnique<VrMetricsHelper>(main_contents_)), |
| 119 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 118 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 120 reprojected_rendering_(reprojected_rendering), | 119 reprojected_rendering_(reprojected_rendering), |
| 121 weak_ptr_factory_(this) { | 120 weak_ptr_factory_(this) { |
| 122 DCHECK(g_instance == nullptr); | 121 DCHECK(g_instance == nullptr); |
| 123 g_instance = this; | 122 g_instance = this; |
| 124 j_vr_shell_.Reset(env, obj); | 123 j_vr_shell_.Reset(env, obj); |
| 125 | 124 |
| 126 content_input_manager_.reset(new VrInputManager(main_contents_)); | 125 content_input_manager_ = base::MakeUnique<VrInputManager>(main_contents_); |
| 127 ui_input_manager_.reset(new VrInputManager(ui_contents_)); | 126 ui_input_manager_ = base::MakeUnique<VrInputManager>(ui_contents_); |
| 128 | 127 |
| 129 content_compositor_->SetLayer(main_contents_); | 128 content_compositor_->SetLayer(main_contents_); |
| 130 ui_compositor_->SetLayer(ui_contents_); | 129 ui_compositor_->SetLayer(ui_contents_); |
| 131 | 130 |
| 132 gl_thread_.reset(new GLThread(weak_ptr_factory_.GetWeakPtr(), | 131 gl_thread_ = base::MakeUnique<GLThread>(weak_ptr_factory_.GetWeakPtr(), |
| 133 content_input_manager_->GetWeakPtr(), | 132 main_thread_task_runner_, gvr_api, |
| 134 ui_input_manager_->GetWeakPtr(), | 133 for_web_vr, reprojected_rendering_); |
| 135 main_thread_task_runner_, | |
| 136 gvr_api, | |
| 137 for_web_vr, | |
| 138 reprojected_rendering_)); | |
| 139 | 134 |
| 140 base::Thread::Options options(base::MessageLoop::TYPE_DEFAULT, 0); | 135 base::Thread::Options options(base::MessageLoop::TYPE_DEFAULT, 0); |
| 141 options.priority = base::ThreadPriority::DISPLAY; | 136 options.priority = base::ThreadPriority::DISPLAY; |
| 142 gl_thread_->StartWithOptions(options); | 137 gl_thread_->StartWithOptions(options); |
| 143 | 138 |
| 144 if (for_web_vr) | 139 if (for_web_vr) |
| 145 metrics_helper_->SetWebVREnabled(true); | 140 metrics_helper_->SetWebVREnabled(true); |
| 146 html_interface_.reset(new UiInterface( | 141 html_interface_ = base::MakeUnique<UiInterface>( |
| 147 for_web_vr ? UiInterface::Mode::WEB_VR : UiInterface::Mode::STANDARD, | 142 for_web_vr ? UiInterface::Mode::WEB_VR : UiInterface::Mode::STANDARD, |
| 148 main_contents_->IsFullscreen())); | 143 main_contents_->IsFullscreen()); |
| 149 vr_web_contents_observer_.reset(new VrWebContentsObserver( | 144 vr_web_contents_observer_ = base::MakeUnique<VrWebContentsObserver>( |
| 150 main_contents, html_interface_.get(), this)); | 145 main_contents_, html_interface_.get(), this); |
| 151 | 146 |
| 152 SetIsInVR(true); | 147 SetIsInVR(main_contents_, true); |
| 153 } | 148 } |
| 154 | 149 |
| 155 void VrShell::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 150 void VrShell::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 156 delete this; | 151 delete this; |
| 157 } | 152 } |
| 158 | 153 |
| 154 void VrShell::SwapContents(JNIEnv* env, const JavaParamRef<jobject>& obj, | |
| 155 const JavaParamRef<jobject>& web_contents) { | |
| 156 SetIsInVR(main_contents_, false); | |
| 157 content::WebContents* contents = | |
| 158 content::WebContents::FromJavaWebContents(web_contents); | |
| 159 main_contents_ = contents; | |
| 160 content_input_manager_ = base::MakeUnique<VrInputManager>(main_contents_); | |
| 161 content_compositor_->SetLayer(main_contents_); | |
| 162 vr_web_contents_observer_ = base::MakeUnique<VrWebContentsObserver>( | |
| 163 main_contents_, html_interface_.get(), this); | |
| 164 SetIsInVR(main_contents_, true); | |
| 165 | |
| 166 // TODO(billorr): Make VrMetricsHelper tab-aware and able to track multiple | |
| 167 // tabs. crbug.com/684661 | |
| 168 metrics_helper_ = base::MakeUnique<VrMetricsHelper>(main_contents_); | |
| 169 metrics_helper_->SetVRActive(true); | |
| 170 metrics_helper_->SetWebVREnabled( | |
| 171 html_interface_->GetMode() == UiInterface::Mode::WEB_VR); | |
| 172 } | |
| 173 | |
| 159 void VrShell::LoadUIContent(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 174 void VrShell::LoadUIContent(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 160 GURL url(kVrShellUIURL); | 175 GURL url(kVrShellUIURL); |
| 161 ui_contents_->GetController().LoadURL( | 176 ui_contents_->GetController().LoadURL( |
| 162 url, content::Referrer(), | 177 url, content::Referrer(), |
| 163 ui::PageTransition::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string("")); | 178 ui::PageTransition::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string("")); |
| 164 } | 179 } |
| 165 | 180 |
| 166 bool RegisterVrShell(JNIEnv* env) { | 181 bool RegisterVrShell(JNIEnv* env) { |
| 167 return RegisterNativesImpl(env); | 182 return RegisterNativesImpl(env); |
| 168 } | 183 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 thread->GetVrShellGl())); | 217 thread->GetVrShellGl())); |
| 203 } | 218 } |
| 204 | 219 |
| 205 void VrShell::OnPause(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 220 void VrShell::OnPause(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 206 GLThread* thread = static_cast<GLThread*>(gl_thread_.get()); | 221 GLThread* thread = static_cast<GLThread*>(gl_thread_.get()); |
| 207 thread->task_runner()->PostTask( | 222 thread->task_runner()->PostTask( |
| 208 FROM_HERE, base::Bind(&VrShellGl::OnPause, thread->GetVrShellGl())); | 223 FROM_HERE, base::Bind(&VrShellGl::OnPause, thread->GetVrShellGl())); |
| 209 | 224 |
| 210 // exit vr session | 225 // exit vr session |
| 211 metrics_helper_->SetVRActive(false); | 226 metrics_helper_->SetVRActive(false); |
| 212 SetIsInVR(false); | 227 SetIsInVR(main_contents_, false); |
| 213 } | 228 } |
| 214 | 229 |
| 215 void VrShell::OnResume(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 230 void VrShell::OnResume(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 216 GLThread* thread = static_cast<GLThread*>(gl_thread_.get()); | 231 GLThread* thread = static_cast<GLThread*>(gl_thread_.get()); |
| 217 thread->task_runner()->PostTask( | 232 thread->task_runner()->PostTask( |
| 218 FROM_HERE, base::Bind(&VrShellGl::OnResume, thread->GetVrShellGl())); | 233 FROM_HERE, base::Bind(&VrShellGl::OnResume, thread->GetVrShellGl())); |
| 219 | 234 |
| 220 metrics_helper_->SetVRActive(true); | 235 metrics_helper_->SetVRActive(true); |
| 221 SetIsInVR(true); | 236 SetIsInVR(main_contents_, true); |
| 222 } | 237 } |
| 223 | 238 |
| 224 void VrShell::SetSurface(JNIEnv* env, | 239 void VrShell::SetSurface(JNIEnv* env, |
| 225 const JavaParamRef<jobject>& obj, | 240 const JavaParamRef<jobject>& obj, |
| 226 const JavaParamRef<jobject>& surface) { | 241 const JavaParamRef<jobject>& surface) { |
| 227 CHECK(!reprojected_rendering_); | 242 CHECK(!reprojected_rendering_); |
| 228 GLThread* thread = static_cast<GLThread*>(gl_thread_.get()); | 243 GLThread* thread = static_cast<GLThread*>(gl_thread_.get()); |
| 229 gfx::AcceleratedWidget window = | 244 gfx::AcceleratedWidget window = |
| 230 ANativeWindow_fromSurface(base::android::AttachCurrentThread(), surface); | 245 ANativeWindow_fromSurface(base::android::AttachCurrentThread(), surface); |
| 231 PostToGlThreadWhenReady(base::Bind(&VrShellGl::InitializeGl, | 246 PostToGlThreadWhenReady(base::Bind(&VrShellGl::InitializeGl, |
| 232 thread->GetVrShellGl(), | 247 thread->GetVrShellGl(), |
| 233 base::Unretained(window))); | 248 base::Unretained(window))); |
| 234 } | 249 } |
| 235 | 250 |
| 236 void VrShell::SetIsInVR(bool is_in_vr) { | |
| 237 main_contents_->GetRenderWidgetHostView()->SetIsInVR(is_in_vr); | |
| 238 } | |
| 239 | |
| 240 base::WeakPtr<VrShell> VrShell::GetWeakPtr( | 251 base::WeakPtr<VrShell> VrShell::GetWeakPtr( |
| 241 const content::WebContents* web_contents) { | 252 const content::WebContents* web_contents) { |
| 242 // Ensure that the WebContents requesting the VrShell instance is the one | 253 // Ensure that the WebContents requesting the VrShell instance is the one |
| 243 // we created. | 254 // we created. |
| 244 if (g_instance != nullptr && g_instance->ui_contents_ == web_contents) | 255 if (g_instance != nullptr && g_instance->ui_contents_ == web_contents) |
| 245 return g_instance->weak_ptr_factory_.GetWeakPtr(); | 256 return g_instance->weak_ptr_factory_.GetWeakPtr(); |
| 246 return base::WeakPtr<VrShell>(nullptr); | 257 return base::WeakPtr<VrShell>(nullptr); |
| 247 } | 258 } |
| 248 | 259 |
| 249 void VrShell::OnDomContentsLoaded() { | 260 void VrShell::OnDomContentsLoaded() { |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 441 | 452 |
| 442 void VrShell::ContentWebContentsDestroyed() { | 453 void VrShell::ContentWebContentsDestroyed() { |
| 443 content_input_manager_.reset(); | 454 content_input_manager_.reset(); |
| 444 main_contents_ = nullptr; | 455 main_contents_ = nullptr; |
| 445 // TODO(mthiesse): Handle web contents being destroyed. | 456 // TODO(mthiesse): Handle web contents being destroyed. |
| 446 ForceExitVr(); | 457 ForceExitVr(); |
| 447 } | 458 } |
| 448 | 459 |
| 449 void VrShell::ContentWasHidden() { | 460 void VrShell::ContentWasHidden() { |
| 450 // Ensure we don't continue sending input to it. | 461 // Ensure we don't continue sending input to it. |
| 451 content_input_manager_.reset(); | 462 content_input_manager_.reset(); |
|
bshe
2017/01/25 22:15:45
Is there case that content was hidden but SwapCont
mthiesse
2017/01/25 22:34:26
I would rather not remove it. SwapContents will be
| |
| 452 // TODO(mthiesse): Handle web contents being hidden. | |
| 453 ForceExitVr(); | |
| 454 } | 463 } |
| 455 | 464 |
| 456 void VrShell::ForceExitVr() { | 465 void VrShell::ForceExitVr() { |
| 457 delegate_->ForceExitVr(); | 466 delegate_->ForceExitVr(); |
| 458 } | 467 } |
| 459 | 468 |
| 460 void VrShell::SetContentCssSize(float width, float height, float dpr) { | 469 void VrShell::SetContentCssSize(float width, float height, float dpr) { |
| 461 JNIEnv* env = base::android::AttachCurrentThread(); | 470 JNIEnv* env = base::android::AttachCurrentThread(); |
| 462 Java_VrShellImpl_setContentCssSize(env, j_vr_shell_.obj(), width, height, | 471 Java_VrShellImpl_setContentCssSize(env, j_vr_shell_.obj(), width, height, |
| 463 dpr); | 472 dpr); |
| 464 } | 473 } |
| 465 | 474 |
| 466 void VrShell::SetUiCssSize(float width, float height, float dpr) { | 475 void VrShell::SetUiCssSize(float width, float height, float dpr) { |
| 467 JNIEnv* env = base::android::AttachCurrentThread(); | 476 JNIEnv* env = base::android::AttachCurrentThread(); |
| 468 Java_VrShellImpl_setUiCssSize(env, j_vr_shell_.obj(), width, height, dpr); | 477 Java_VrShellImpl_setUiCssSize(env, j_vr_shell_.obj(), width, height, dpr); |
| 469 } | 478 } |
| 470 | 479 |
| 480 void VrShell::ProcessUIGesture(std::unique_ptr<blink::WebInputEvent> event) { | |
| 481 if (ui_input_manager_) { | |
| 482 ui_input_manager_->ProcessUpdatedGesture(std::move(event)); | |
| 483 } | |
| 484 | |
| 485 } | |
| 486 | |
| 487 void VrShell::ProcessContentGesture( | |
| 488 std::unique_ptr<blink::WebInputEvent> event) { | |
| 489 if (content_input_manager_) { | |
| 490 content_input_manager_->ProcessUpdatedGesture(std::move(event)); | |
| 491 } | |
| 492 } | |
| 493 | |
| 494 | |
| 471 // ---------------------------------------------------------------------------- | 495 // ---------------------------------------------------------------------------- |
| 472 // Native JNI methods | 496 // Native JNI methods |
| 473 // ---------------------------------------------------------------------------- | 497 // ---------------------------------------------------------------------------- |
| 474 | 498 |
| 475 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj, | 499 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj, |
| 476 const JavaParamRef<jobject>& content_web_contents, | 500 const JavaParamRef<jobject>& content_web_contents, |
| 477 jlong content_window_android, | 501 jlong content_window_android, |
| 478 const JavaParamRef<jobject>& ui_web_contents, | 502 const JavaParamRef<jobject>& ui_web_contents, |
| 479 jlong ui_window_android, jboolean for_web_vr, | 503 jlong ui_window_android, jboolean for_web_vr, |
| 480 const base::android::JavaParamRef<jobject>& delegate, | 504 const base::android::JavaParamRef<jobject>& delegate, |
| 481 jlong gvr_api, jboolean reprojected_rendering) { | 505 jlong gvr_api, jboolean reprojected_rendering) { |
| 482 return reinterpret_cast<intptr_t>(new VrShell( | 506 return reinterpret_cast<intptr_t>(new VrShell( |
| 483 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), | 507 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), |
| 484 reinterpret_cast<ui::WindowAndroid*>(content_window_android), | 508 reinterpret_cast<ui::WindowAndroid*>(content_window_android), |
| 485 content::WebContents::FromJavaWebContents(ui_web_contents), | 509 content::WebContents::FromJavaWebContents(ui_web_contents), |
| 486 reinterpret_cast<ui::WindowAndroid*>(ui_window_android), | 510 reinterpret_cast<ui::WindowAndroid*>(ui_window_android), |
| 487 for_web_vr, VrShellDelegate::GetNativeDelegate(env, delegate), | 511 for_web_vr, VrShellDelegate::GetNativeDelegate(env, delegate), |
| 488 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); | 512 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); |
| 489 } | 513 } |
| 490 | 514 |
| 491 } // namespace vr_shell | 515 } // namespace vr_shell |
| OLD | NEW |