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_interface.h" |
| 10 #include "chrome/browser/android/vr_shell/ui_scene.h" | 10 #include "chrome/browser/android/vr_shell/ui_scene.h" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 reprojected_rendering_(reprojected_rendering) {} | 29 reprojected_rendering_(reprojected_rendering) {} |
| 30 | 30 |
| 31 VrGLThread::~VrGLThread() { | 31 VrGLThread::~VrGLThread() { |
| 32 Stop(); | 32 Stop(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void VrGLThread::Init() { | 35 void VrGLThread::Init() { |
| 36 scene_ = base::MakeUnique<UiScene>(); | 36 scene_ = base::MakeUnique<UiScene>(); |
| 37 vr_shell_gl_ = base::MakeUnique<VrShellGl>( | 37 vr_shell_gl_ = base::MakeUnique<VrShellGl>( |
| 38 this, gvr_api_, initially_web_vr_, reprojected_rendering_, scene_.get()); | 38 this, gvr_api_, initially_web_vr_, reprojected_rendering_, scene_.get()); |
| 39 | |
| 39 scene_manager_ = base::MakeUnique<UiSceneManager>(this, scene_.get()); | 40 scene_manager_ = base::MakeUnique<UiSceneManager>(this, scene_.get()); |
| 41 scene_manager_->SetWebVRMode(initially_web_vr_); | |
| 40 | 42 |
| 41 weak_vr_shell_gl_ = vr_shell_gl_->GetWeakPtr(); | 43 weak_vr_shell_gl_ = vr_shell_gl_->GetWeakPtr(); |
| 42 weak_scene_manager_ = scene_manager_->GetWeakPtr(); | 44 weak_scene_manager_ = scene_manager_->GetWeakPtr(); |
| 43 vr_shell_gl_->Initialize(); | 45 vr_shell_gl_->Initialize(); |
| 44 } | 46 } |
| 45 | 47 |
| 46 void VrGLThread::ContentSurfaceChanged(jobject surface) { | 48 void VrGLThread::ContentSurfaceChanged(jobject surface) { |
| 47 main_thread_task_runner_->PostTask( | 49 main_thread_task_runner_->PostTask( |
| 48 FROM_HERE, | 50 FROM_HERE, |
| 49 base::Bind(&VrShell::ContentSurfaceChanged, weak_vr_shell_, surface)); | 51 base::Bind(&VrShell::ContentSurfaceChanged, weak_vr_shell_, surface)); |
| 50 } | 52 } |
| 51 | 53 |
| 52 void VrGLThread::GvrDelegateReady() { | 54 void VrGLThread::GvrDelegateReady() { |
| 53 main_thread_task_runner_->PostTask( | 55 main_thread_task_runner_->PostTask( |
| 54 FROM_HERE, base::Bind(&VrShell::GvrDelegateReady, weak_vr_shell_)); | 56 FROM_HERE, base::Bind(&VrShell::GvrDelegateReady, weak_vr_shell_)); |
| 55 } | 57 } |
| 56 | 58 |
| 57 void VrGLThread::UpdateGamepadData(device::GvrGamepadData pad) { | 59 void VrGLThread::UpdateGamepadData(device::GvrGamepadData pad) { |
| 58 main_thread_task_runner_->PostTask( | 60 main_thread_task_runner_->PostTask( |
| 59 FROM_HERE, base::Bind(&VrShell::UpdateGamepadData, weak_vr_shell_, pad)); | 61 FROM_HERE, base::Bind(&VrShell::UpdateGamepadData, weak_vr_shell_, pad)); |
| 60 } | 62 } |
| 61 | 63 |
| 62 void VrGLThread::AppButtonGesturePerformed(UiInterface::Direction direction) { | 64 void VrGLThread::AppButtonClicked() { |
| 63 main_thread_task_runner_->PostTask( | |
| 64 FROM_HERE, base::Bind(&VrShell::AppButtonGesturePerformed, weak_vr_shell_, | |
| 65 direction)); | |
| 66 } | |
| 67 | |
| 68 void VrGLThread::OnAppButtonClicked() { | |
| 69 weak_vr_shell_gl_->GetTaskRunner()->PostTask( | 65 weak_vr_shell_gl_->GetTaskRunner()->PostTask( |
| 70 FROM_HERE, | 66 FROM_HERE, |
| 71 base::Bind(&UiSceneManager::OnAppButtonClicked, weak_scene_manager_)); | 67 base::Bind(&UiSceneManager::OnAppButtonClicked, weak_scene_manager_)); |
| 72 } | 68 } |
| 73 | 69 |
| 70 void VrGLThread::AppButtonGesturePerformed(UiInterface::Direction direction) { | |
| 71 weak_vr_shell_gl_->GetTaskRunner()->PostTask( | |
|
mthiesse
2017/05/08 16:04:55
Should this be task_runner()->PostTask()?
cjgrant
2017/05/08 19:17:22
Done. Good call.
| |
| 72 FROM_HERE, base::Bind(&UiSceneManager::OnAppButtonGesturePerformed, | |
| 73 weak_scene_manager_, direction)); | |
| 74 } | |
| 75 | |
| 74 void VrGLThread::ProcessContentGesture( | 76 void VrGLThread::ProcessContentGesture( |
| 75 std::unique_ptr<blink::WebInputEvent> event) { | 77 std::unique_ptr<blink::WebInputEvent> event) { |
| 76 main_thread_task_runner_->PostTask( | 78 main_thread_task_runner_->PostTask( |
| 77 FROM_HERE, base::Bind(&VrShell::ProcessContentGesture, weak_vr_shell_, | 79 FROM_HERE, base::Bind(&VrShell::ProcessContentGesture, weak_vr_shell_, |
| 78 base::Passed(std::move(event)))); | 80 base::Passed(std::move(event)))); |
| 79 } | 81 } |
| 80 | 82 |
| 81 void VrGLThread::ForceExitVr() { | 83 void VrGLThread::ForceExitVr() { |
| 82 main_thread_task_runner_->PostTask( | 84 main_thread_task_runner_->PostTask( |
| 83 FROM_HERE, base::Bind(&VrShell::ForceExitVr, weak_vr_shell_)); | 85 FROM_HERE, base::Bind(&VrShell::ForceExitVr, weak_vr_shell_)); |
| 84 } | 86 } |
| 85 | 87 |
| 86 void VrGLThread::RunVRDisplayInfoCallback( | 88 void VrGLThread::RunVRDisplayInfoCallback( |
| 87 const base::Callback<void(device::mojom::VRDisplayInfoPtr)>& callback, | 89 const base::Callback<void(device::mojom::VRDisplayInfoPtr)>& callback, |
| 88 device::mojom::VRDisplayInfoPtr* info) { | 90 device::mojom::VRDisplayInfoPtr* info) { |
| 89 main_thread_task_runner_->PostTask(FROM_HERE, | 91 main_thread_task_runner_->PostTask(FROM_HERE, |
| 90 base::Bind(callback, base::Passed(info))); | 92 base::Bind(callback, base::Passed(info))); |
| 91 } | 93 } |
| 92 | 94 |
| 93 void VrGLThread::OnContentPaused(bool enabled) { | 95 void VrGLThread::OnContentPaused(bool enabled) { |
| 94 main_thread_task_runner_->PostTask( | 96 main_thread_task_runner_->PostTask( |
| 95 FROM_HERE, | 97 FROM_HERE, |
| 96 base::Bind(&VrShell::OnContentPaused, weak_vr_shell_, enabled)); | 98 base::Bind(&VrShell::OnContentPaused, weak_vr_shell_, enabled)); |
| 97 } | 99 } |
| 98 | 100 |
| 101 void VrGLThread::SetWebVr(bool enabled) {} | |
| 102 | |
| 103 void VrGLThread::SetURL(const GURL& gurl) { | |
| 104 WaitUntilThreadStarted(); | |
| 105 task_runner()->PostTask(FROM_HERE, base::Bind(&UiSceneManager::SetURL, | |
| 106 weak_scene_manager_, gurl)); | |
| 107 } | |
| 108 | |
| 109 void VrGLThread::SetFullscreen(bool enabled) { | |
| 110 WaitUntilThreadStarted(); | |
| 111 task_runner()->PostTask(FROM_HERE, base::Bind(&UiSceneManager::SetFullscreen, | |
| 112 weak_scene_manager_, enabled)); | |
| 113 } | |
| 114 | |
| 115 void VrGLThread::SetSecurityLevel(int level) { | |
| 116 WaitUntilThreadStarted(); | |
| 117 task_runner()->PostTask(FROM_HERE, | |
| 118 base::Bind(&UiSceneManager::SetSecurityLevel, | |
| 119 weak_scene_manager_, level)); | |
| 120 } | |
| 121 | |
| 122 void VrGLThread::SetWebVRSecureOrigin(bool secure) { | |
| 123 WaitUntilThreadStarted(); | |
| 124 task_runner()->PostTask(FROM_HERE, | |
| 125 base::Bind(&UiSceneManager::SetWebVRSecureOrigin, | |
| 126 weak_scene_manager_, secure)); | |
| 127 } | |
| 128 | |
| 129 void VrGLThread::SetLoading(bool loading) { | |
| 130 WaitUntilThreadStarted(); | |
| 131 task_runner()->PostTask(FROM_HERE, base::Bind(&UiSceneManager::SetLoading, | |
| 132 weak_scene_manager_, loading)); | |
| 133 } | |
| 134 | |
| 135 void VrGLThread::SetLoadProgress(double progress) { | |
| 136 WaitUntilThreadStarted(); | |
| 137 task_runner()->PostTask(FROM_HERE, | |
| 138 base::Bind(&UiSceneManager::SetLoadProgress, | |
| 139 weak_scene_manager_, progress)); | |
| 140 } | |
| 141 | |
| 142 void VrGLThread::SetHistoryButtonsEnabled(bool can_go_back, | |
| 143 bool can_go_forward) { | |
| 144 WaitUntilThreadStarted(); | |
| 145 task_runner()->PostTask( | |
| 146 FROM_HERE, base::Bind(&UiSceneManager::SetHistoryButtonsEnabled, | |
| 147 weak_scene_manager_, can_go_forward, can_go_back)); | |
| 148 } | |
| 149 | |
| 99 void VrGLThread::CleanUp() { | 150 void VrGLThread::CleanUp() { |
| 100 scene_manager_.reset(); | 151 scene_manager_.reset(); |
| 101 vr_shell_gl_.reset(); | 152 vr_shell_gl_.reset(); |
| 102 scene_.reset(); | 153 scene_.reset(); |
| 103 } | 154 } |
| 104 | 155 |
| 105 } // namespace vr_shell | 156 } // namespace vr_shell |
| OLD | NEW |