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 "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" |
| 11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
| 12 #include "base/values.h" | |
| 12 #include "chrome/browser/android/vr_shell/ui_interface.h" | 13 #include "chrome/browser/android/vr_shell/ui_interface.h" |
| 13 #include "chrome/browser/android/vr_shell/vr_compositor.h" | 14 #include "chrome/browser/android/vr_shell/vr_compositor.h" |
| 14 #include "chrome/browser/android/vr_shell/vr_input_manager.h" | 15 #include "chrome/browser/android/vr_shell/vr_input_manager.h" |
| 15 #include "chrome/browser/android/vr_shell/vr_shell_delegate.h" | 16 #include "chrome/browser/android/vr_shell/vr_shell_delegate.h" |
| 16 #include "chrome/browser/android/vr_shell/vr_shell_gl.h" | 17 #include "chrome/browser/android/vr_shell/vr_shell_gl.h" |
| 17 #include "chrome/browser/android/vr_shell/vr_usage_monitor.h" | 18 #include "chrome/browser/android/vr_shell/vr_usage_monitor.h" |
| 18 #include "chrome/browser/android/vr_shell/vr_web_contents_observer.h" | 19 #include "chrome/browser/android/vr_shell/vr_web_contents_observer.h" |
| 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" |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 // TODO(mthiesse): Remove this blocking wait. Queue up events if thread isn't | 318 // TODO(mthiesse): Remove this blocking wait. Queue up events if thread isn't |
| 318 // finished starting? | 319 // finished starting? |
| 319 thread->WaitUntilThreadStarted(); | 320 thread->WaitUntilThreadStarted(); |
| 320 thread->task_runner()->PostTask( | 321 thread->task_runner()->PostTask( |
| 321 FROM_HERE, base::Bind(&VrShellGl::UIPhysicalBoundsChanged, | 322 FROM_HERE, base::Bind(&VrShellGl::UIPhysicalBoundsChanged, |
| 322 thread->GetVrShellGl(), | 323 thread->GetVrShellGl(), |
| 323 width, height)); | 324 width, height)); |
| 324 ui_compositor_->SetWindowBounds(width, height); | 325 ui_compositor_->SetWindowBounds(width, height); |
| 325 } | 326 } |
| 326 | 327 |
| 327 UiScene* VrShell::GetScene() { | |
| 328 GLThread* thread = static_cast<GLThread*>(gl_thread_.get()); | |
| 329 // TODO(mthiesse): Remove this blocking wait. Queue up events if thread isn't | |
| 330 // finished starting? | |
| 331 thread->WaitUntilThreadStarted(); | |
| 332 if (thread->GetVrShellGlUnsafe()) { | |
| 333 return thread->GetVrShellGlUnsafe()->GetScene(); | |
| 334 } | |
| 335 return nullptr; | |
| 336 } | |
| 337 | |
| 338 UiInterface* VrShell::GetUiInterface() { | 328 UiInterface* VrShell::GetUiInterface() { |
| 339 return html_interface_.get(); | 329 return html_interface_.get(); |
| 340 } | 330 } |
| 341 | 331 |
| 342 void VrShell::QueueTask(base::Callback<void()>& callback) { | 332 void VrShell::UpdateScene(const base::ListValue* args) { |
| 343 gl_thread_->task_runner()->PostTask(FROM_HERE, callback); | 333 GLThread* thread = static_cast<GLThread*>(gl_thread_.get()); |
| 334 // TODO(mthiesse): Remove this blocking wait. Queue up events if thread isn't | |
| 335 // finished starting? | |
| 336 thread->WaitUntilThreadStarted(); | |
|
bshe
2016/12/14 22:05:13
you can probably use the new function that you cre
mthiesse
2016/12/14 22:39:32
This one will probably land first. I'll do this wh
| |
| 337 thread->task_runner()->PostTask( | |
| 338 FROM_HERE, base::Bind(&VrShellGl::UpdateScene, | |
| 339 thread->GetVrShellGl(), | |
| 340 base::Passed(args->CreateDeepCopy()))); | |
| 344 } | 341 } |
| 345 | 342 |
| 346 void VrShell::DoUiAction(const UiAction action) { | 343 void VrShell::DoUiAction(const UiAction action) { |
| 347 content::NavigationController& controller = main_contents_->GetController(); | 344 content::NavigationController& controller = main_contents_->GetController(); |
| 348 switch (action) { | 345 switch (action) { |
| 349 case HISTORY_BACK: | 346 case HISTORY_BACK: |
| 350 if (main_contents_->IsFullscreen()) { | 347 if (main_contents_->IsFullscreen()) { |
| 351 main_contents_->ExitFullscreen(true /* will_cause_resize */); | 348 main_contents_->ExitFullscreen(true /* will_cause_resize */); |
| 352 } else if (controller.CanGoBack()) { | 349 } else if (controller.CanGoBack()) { |
| 353 controller.GoBack(); | 350 controller.GoBack(); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 457 return reinterpret_cast<intptr_t>(new VrShell( | 454 return reinterpret_cast<intptr_t>(new VrShell( |
| 458 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), | 455 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), |
| 459 reinterpret_cast<ui::WindowAndroid*>(content_window_android), | 456 reinterpret_cast<ui::WindowAndroid*>(content_window_android), |
| 460 content::WebContents::FromJavaWebContents(ui_web_contents), | 457 content::WebContents::FromJavaWebContents(ui_web_contents), |
| 461 reinterpret_cast<ui::WindowAndroid*>(ui_window_android), | 458 reinterpret_cast<ui::WindowAndroid*>(ui_window_android), |
| 462 for_web_vr, VrShellDelegate::GetNativeDelegate(env, delegate), | 459 for_web_vr, VrShellDelegate::GetNativeDelegate(env, delegate), |
| 463 reinterpret_cast<gvr_context*>(gvr_api))); | 460 reinterpret_cast<gvr_context*>(gvr_api))); |
| 464 } | 461 } |
| 465 | 462 |
| 466 } // namespace vr_shell | 463 } // namespace vr_shell |
| OLD | NEW |