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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 // TODO(mthiesse): Remove this blocking wait. Queue up events if thread isn't | 313 // TODO(mthiesse): Remove this blocking wait. Queue up events if thread isn't |
313 // finished starting? | 314 // finished starting? |
314 thread->WaitUntilThreadStarted(); | 315 thread->WaitUntilThreadStarted(); |
315 thread->task_runner()->PostTask( | 316 thread->task_runner()->PostTask( |
316 FROM_HERE, base::Bind(&VrShellGl::UIPhysicalBoundsChanged, | 317 FROM_HERE, base::Bind(&VrShellGl::UIPhysicalBoundsChanged, |
317 thread->GetVrShellGl(), | 318 thread->GetVrShellGl(), |
318 width, height)); | 319 width, height)); |
319 ui_compositor_->SetWindowBounds(gfx::Size(width, height)); | 320 ui_compositor_->SetWindowBounds(gfx::Size(width, height)); |
320 } | 321 } |
321 | 322 |
322 UiScene* VrShell::GetScene() { | |
323 GLThread* thread = static_cast<GLThread*>(gl_thread_.get()); | |
324 // TODO(mthiesse): Remove this blocking wait. Queue up events if thread isn't | |
325 // finished starting? | |
326 thread->WaitUntilThreadStarted(); | |
327 if (thread->GetVrShellGlUnsafe()) { | |
328 return thread->GetVrShellGlUnsafe()->GetScene(); | |
329 } | |
330 return nullptr; | |
331 } | |
332 | |
333 UiInterface* VrShell::GetUiInterface() { | 323 UiInterface* VrShell::GetUiInterface() { |
334 return html_interface_.get(); | 324 return html_interface_.get(); |
335 } | 325 } |
336 | 326 |
337 void VrShell::QueueTask(base::Callback<void()>& callback) { | 327 void VrShell::UpdateScene(const base::ListValue* args) { |
338 gl_thread_->task_runner()->PostTask(FROM_HERE, callback); | 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 thread->task_runner()->PostTask( |
| 333 FROM_HERE, base::Bind(&VrShellGl::UpdateScene, |
| 334 thread->GetVrShellGl(), |
| 335 base::Passed(args->CreateDeepCopy()))); |
339 } | 336 } |
340 | 337 |
341 void VrShell::DoUiAction(const UiAction action) { | 338 void VrShell::DoUiAction(const UiAction action) { |
342 content::NavigationController& controller = main_contents_->GetController(); | 339 content::NavigationController& controller = main_contents_->GetController(); |
343 switch (action) { | 340 switch (action) { |
344 case HISTORY_BACK: | 341 case HISTORY_BACK: |
345 if (main_contents_->IsFullscreen()) { | 342 if (main_contents_->IsFullscreen()) { |
346 main_contents_->ExitFullscreen(true /* will_cause_resize */); | 343 main_contents_->ExitFullscreen(true /* will_cause_resize */); |
347 } else if (controller.CanGoBack()) { | 344 } else if (controller.CanGoBack()) { |
348 controller.GoBack(); | 345 controller.GoBack(); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 return reinterpret_cast<intptr_t>(new VrShell( | 449 return reinterpret_cast<intptr_t>(new VrShell( |
453 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), | 450 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), |
454 reinterpret_cast<ui::WindowAndroid*>(content_window_android), | 451 reinterpret_cast<ui::WindowAndroid*>(content_window_android), |
455 content::WebContents::FromJavaWebContents(ui_web_contents), | 452 content::WebContents::FromJavaWebContents(ui_web_contents), |
456 reinterpret_cast<ui::WindowAndroid*>(ui_window_android), | 453 reinterpret_cast<ui::WindowAndroid*>(ui_window_android), |
457 for_web_vr, VrShellDelegate::GetNativeDelegate(env, delegate), | 454 for_web_vr, VrShellDelegate::GetNativeDelegate(env, delegate), |
458 reinterpret_cast<gvr_context*>(gvr_api))); | 455 reinterpret_cast<gvr_context*>(gvr_api))); |
459 } | 456 } |
460 | 457 |
461 } // namespace vr_shell | 458 } // namespace vr_shell |
OLD | NEW |