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_gl_thread.h" | 5 #include "chrome/browser/android/vr_shell/vr_gl_thread.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "chrome/browser/android/vr_shell/ui_interface.h" | |
| 9 #include "chrome/browser/android/vr_shell/ui_scene.h" | 10 #include "chrome/browser/android/vr_shell/ui_scene.h" |
| 10 #include "chrome/browser/android/vr_shell/ui_scene_manager.h" | 11 #include "chrome/browser/android/vr_shell/ui_scene_manager.h" |
| 11 #include "chrome/browser/android/vr_shell/vr_input_manager.h" | 12 #include "chrome/browser/android/vr_shell/vr_input_manager.h" |
| 12 #include "chrome/browser/android/vr_shell/vr_shell.h" | 13 #include "chrome/browser/android/vr_shell/vr_shell.h" |
| 13 #include "chrome/browser/android/vr_shell/vr_shell_gl.h" | 14 #include "chrome/browser/android/vr_shell/vr_shell_gl.h" |
| 14 | 15 |
| 15 namespace vr_shell { | 16 namespace vr_shell { |
| 16 | 17 |
| 18 void RunDisplayInfoCallback( | |
|
cjgrant
2017/05/02 18:07:06
This will need a rebase with Michael's change I th
ymalik
2017/05/02 20:28:40
Yes. Rebased.
| |
| 19 const base::Callback<void(device::mojom::VRDisplayInfoPtr)>& callback, | |
| 20 device::mojom::VRDisplayInfoPtr info) { | |
| 21 callback.Run(std::move(info)); | |
| 22 } | |
| 23 | |
| 17 VrGLThread::VrGLThread( | 24 VrGLThread::VrGLThread( |
| 18 const base::WeakPtr<VrShell>& weak_vr_shell, | 25 const base::WeakPtr<VrShell>& weak_vr_shell, |
| 19 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, | 26 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, |
| 20 gvr_context* gvr_api, | 27 gvr_context* gvr_api, |
| 21 bool initially_web_vr, | 28 bool initially_web_vr, |
| 22 bool reprojected_rendering) | 29 bool reprojected_rendering) |
| 23 : base::Thread("VrShellGL"), | 30 : base::Thread("VrShellGL"), |
| 24 weak_vr_shell_(weak_vr_shell), | 31 weak_vr_shell_(weak_vr_shell), |
| 25 main_thread_task_runner_(std::move(main_thread_task_runner)), | 32 main_thread_task_runner_(std::move(main_thread_task_runner)), |
| 26 gvr_api_(gvr_api), | 33 gvr_api_(gvr_api), |
| 27 initially_web_vr_(initially_web_vr), | 34 initially_web_vr_(initially_web_vr), |
| 28 reprojected_rendering_(reprojected_rendering) {} | 35 reprojected_rendering_(reprojected_rendering), |
| 36 weak_ptr_factory_(this) {} | |
| 29 | 37 |
| 30 VrGLThread::~VrGLThread() { | 38 VrGLThread::~VrGLThread() { |
| 31 Stop(); | 39 Stop(); |
| 32 } | 40 } |
| 33 | 41 |
| 34 void VrGLThread::Init() { | 42 void VrGLThread::Init() { |
| 35 scene_ = base::MakeUnique<UiScene>(); | 43 scene_ = base::MakeUnique<UiScene>(); |
| 36 vr_shell_gl_ = base::MakeUnique<VrShellGl>( | 44 vr_shell_gl_ = base::MakeUnique<VrShellGl>( |
| 37 std::move(weak_vr_shell_), std::move(main_thread_task_runner_), gvr_api_, | 45 weak_ptr_factory_.GetWeakPtr(), gvr_api_, initially_web_vr_, |
| 38 initially_web_vr_, reprojected_rendering_, scene_.get()); | 46 reprojected_rendering_, scene_.get()); |
| 39 scene_manager_ = base::MakeUnique<UiSceneManager>(scene_.get()); | 47 scene_manager_ = base::MakeUnique<UiSceneManager>( |
| 48 weak_ptr_factory_.GetWeakPtr(), scene_.get()); | |
| 40 | 49 |
| 41 weak_vr_shell_gl_ = vr_shell_gl_->GetWeakPtr(); | 50 weak_vr_shell_gl_ = vr_shell_gl_->GetWeakPtr(); |
| 42 weak_scene_manager_ = scene_manager_->GetWeakPtr(); | 51 weak_scene_manager_ = scene_manager_->GetWeakPtr(); |
| 43 vr_shell_gl_->Initialize(); | 52 vr_shell_gl_->Initialize(); |
| 44 } | 53 } |
| 45 | 54 |
| 55 void VrGLThread::ContentSurfaceChanged(jobject surface) { | |
|
cjgrant
2017/05/02 18:07:06
This is cool. Thanks for rejigging this to keep t
ymalik
2017/05/02 20:28:40
Acknowledged.
| |
| 56 main_thread_task_runner_->PostTask( | |
| 57 FROM_HERE, | |
| 58 base::Bind(&VrShell::ContentSurfaceChanged, weak_vr_shell_, surface)); | |
| 59 } | |
| 60 | |
| 61 void VrGLThread::GvrDelegateReady() { | |
| 62 main_thread_task_runner_->PostTask( | |
| 63 FROM_HERE, base::Bind(&VrShell::GvrDelegateReady, weak_vr_shell_)); | |
| 64 } | |
| 65 | |
| 66 void VrGLThread::UpdateGamepadData(device::GvrGamepadData pad) { | |
| 67 main_thread_task_runner_->PostTask( | |
| 68 FROM_HERE, base::Bind(&VrShell::UpdateGamepadData, weak_vr_shell_, pad)); | |
| 69 } | |
| 70 | |
| 71 void VrGLThread::AppButtonGesturePerformed(UiInterface::Direction direction) { | |
| 72 main_thread_task_runner_->PostTask( | |
| 73 FROM_HERE, base::Bind(&VrShell::AppButtonGesturePerformed, weak_vr_shell_, | |
| 74 direction)); | |
| 75 } | |
| 76 | |
| 77 void VrGLThread::AppButtonPressed() { | |
| 78 weak_vr_shell_gl_->GetTaskRunner()->PostTask( | |
| 79 FROM_HERE, | |
| 80 base::Bind(&UiSceneManager::AppButtonPressed, weak_scene_manager_)); | |
| 81 } | |
| 82 | |
| 83 void VrGLThread::ProcessContentGesture( | |
| 84 std::unique_ptr<blink::WebInputEvent> event) { | |
| 85 main_thread_task_runner_->PostTask( | |
| 86 FROM_HERE, base::Bind(&VrShell::ProcessContentGesture, weak_vr_shell_, | |
| 87 base::Passed(std::move(event)))); | |
| 88 } | |
| 89 | |
| 90 void VrGLThread::ForceExitVr() { | |
| 91 main_thread_task_runner_->PostTask( | |
| 92 FROM_HERE, base::Bind(&VrShell::ForceExitVr, weak_vr_shell_)); | |
| 93 } | |
| 94 | |
| 95 void VrGLThread::RunVRDisplayInfoCallback( | |
| 96 const base::Callback<void(device::mojom::VRDisplayInfoPtr)>& callback, | |
| 97 device::mojom::VRDisplayInfoPtr* info) { | |
| 98 main_thread_task_runner_->PostTask( | |
| 99 FROM_HERE, | |
| 100 base::Bind(&RunDisplayInfoCallback, callback, base::Passed(info))); | |
| 101 } | |
| 102 | |
| 103 void VrGLThread::OnContentPaused(bool enabled) { | |
| 104 main_thread_task_runner_->PostTask( | |
| 105 FROM_HERE, | |
| 106 base::Bind(&VrShell::OnContentPaused, weak_vr_shell_, enabled)); | |
| 107 } | |
| 108 | |
| 46 void VrGLThread::CleanUp() { | 109 void VrGLThread::CleanUp() { |
| 47 scene_manager_.reset(); | 110 scene_manager_.reset(); |
| 48 vr_shell_gl_.reset(); | 111 vr_shell_gl_.reset(); |
| 49 scene_.reset(); | 112 scene_.reset(); |
| 50 } | 113 } |
| 51 | 114 |
| 52 } // namespace vr_shell | 115 } // namespace vr_shell |
| OLD | NEW |