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_gl.h" | 5 #include "chrome/browser/android/vr_shell/vr_shell_gl.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 weak_vr_shell_(weak_vr_shell), | 168 weak_vr_shell_(weak_vr_shell), |
| 169 delegate_provider_(delegate_provider), | 169 delegate_provider_(delegate_provider), |
| 170 main_thread_task_runner_(std::move(main_thread_task_runner)), | 170 main_thread_task_runner_(std::move(main_thread_task_runner)), |
| 171 weak_ptr_factory_(this) { | 171 weak_ptr_factory_(this) { |
| 172 GvrInit(gvr_api); | 172 GvrInit(gvr_api); |
| 173 } | 173 } |
| 174 | 174 |
| 175 VrShellGl::~VrShellGl() { | 175 VrShellGl::~VrShellGl() { |
| 176 vsync_task_.Cancel(); | 176 vsync_task_.Cancel(); |
| 177 if (!callback_.is_null()) { | 177 if (!callback_.is_null()) { |
| 178 base::ResetAndReturn(&callback_).Run(nullptr, base::TimeDelta(), -1); | 178 base::ResetAndReturn(&callback_) |
| 179 .Run(nullptr, base::TimeDelta(), -1, | |
| 180 device::mojom::VRVSyncProvider::Error::ERROR_TRY_AGAIN); | |
|
bajones
2017/02/23 17:21:22
Could you clarify this? If the VSyncProvider is be
mthiesse
2017/02/23 18:11:58
Added comments.
| |
| 179 } | 181 } |
| 180 if (binding_.is_bound()) { | 182 if (binding_.is_bound()) { |
| 181 main_thread_task_runner_->PostTask(FROM_HERE, base::Bind( | 183 main_thread_task_runner_->PostTask(FROM_HERE, base::Bind( |
| 182 &VrShellDelegate::OnVRVsyncProviderRequest, delegate_provider_, | 184 &VrShellDelegate::OnVRVsyncProviderRequest, delegate_provider_, |
| 183 base::Passed(binding_.Unbind()))); | 185 base::Passed(binding_.Unbind()))); |
| 184 } | 186 } |
| 185 } | 187 } |
| 186 | 188 |
| 187 void VrShellGl::Initialize() { | 189 void VrShellGl::Initialize() { |
| 188 scene_.reset(new UiScene); | 190 scene_.reset(new UiScene); |
| (...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1084 } | 1086 } |
| 1085 | 1087 |
| 1086 void VrShellGl::OnRequest(device::mojom::VRVSyncProviderRequest request) { | 1088 void VrShellGl::OnRequest(device::mojom::VRVSyncProviderRequest request) { |
| 1087 binding_.Close(); | 1089 binding_.Close(); |
| 1088 binding_.Bind(std::move(request)); | 1090 binding_.Bind(std::move(request)); |
| 1089 } | 1091 } |
| 1090 | 1092 |
| 1091 void VrShellGl::GetVSync(const GetVSyncCallback& callback) { | 1093 void VrShellGl::GetVSync(const GetVSyncCallback& callback) { |
| 1092 if (!pending_vsync_) { | 1094 if (!pending_vsync_) { |
| 1093 if (!callback_.is_null()) { | 1095 if (!callback_.is_null()) { |
| 1096 callback.Run(nullptr, base::TimeDelta(), -1, | |
| 1097 device::mojom::VRVSyncProvider::Error::ERROR_BAD_REQUEST); | |
| 1094 mojo::ReportBadMessage("Requested VSync before waiting for response to " | 1098 mojo::ReportBadMessage("Requested VSync before waiting for response to " |
| 1095 "previous request."); | 1099 "previous request."); |
| 1096 return; | 1100 return; |
| 1097 } | 1101 } |
| 1098 callback_ = callback; | 1102 callback_ = callback; |
| 1099 return; | 1103 return; |
| 1100 } | 1104 } |
| 1101 pending_vsync_ = false; | 1105 pending_vsync_ = false; |
| 1102 SendVSync(pending_time_, callback); | 1106 SendVSync(pending_time_, callback); |
| 1103 } | 1107 } |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 1128 | 1132 |
| 1129 gvr::ClockTimePoint target_time = gvr::GvrApi::GetTimePointNow(); | 1133 gvr::ClockTimePoint target_time = gvr::GvrApi::GetTimePointNow(); |
| 1130 target_time.monotonic_system_time_nanos += kPredictionTimeWithoutVsyncNanos; | 1134 target_time.monotonic_system_time_nanos += kPredictionTimeWithoutVsyncNanos; |
| 1131 | 1135 |
| 1132 gvr::Mat4f head_mat = | 1136 gvr::Mat4f head_mat = |
| 1133 gvr_api_->GetHeadSpaceFromStartSpaceRotation(target_time); | 1137 gvr_api_->GetHeadSpaceFromStartSpaceRotation(target_time); |
| 1134 head_mat = gvr_api_->ApplyNeckModel(head_mat, 1.0f); | 1138 head_mat = gvr_api_->ApplyNeckModel(head_mat, 1.0f); |
| 1135 | 1139 |
| 1136 webvr_head_pose_[frame_index % kPoseRingBufferSize] = head_mat; | 1140 webvr_head_pose_[frame_index % kPoseRingBufferSize] = head_mat; |
| 1137 | 1141 |
| 1138 callback.Run(VrShell::VRPosePtrFromGvrPose(head_mat), time, frame_index); | 1142 callback.Run(VrShell::VRPosePtrFromGvrPose(head_mat), time, frame_index, |
| 1143 device::mojom::VRVSyncProvider::Error::ERROR_NONE); | |
| 1139 } | 1144 } |
| 1140 | 1145 |
| 1141 void VrShellGl::ResetPose() { | 1146 void VrShellGl::ResetPose() { |
| 1142 // Should never call RecenterTracking when using with Daydream viewers. On | 1147 // Should never call RecenterTracking when using with Daydream viewers. On |
| 1143 // those devices recentering should only be done via the controller. | 1148 // those devices recentering should only be done via the controller. |
| 1144 if (gvr_api_ && gvr_api_->GetViewerType() == GVR_VIEWER_TYPE_CARDBOARD) | 1149 if (gvr_api_ && gvr_api_->GetViewerType() == GVR_VIEWER_TYPE_CARDBOARD) |
| 1145 gvr_api_->RecenterTracking(); | 1150 gvr_api_->RecenterTracking(); |
| 1146 } | 1151 } |
| 1147 | 1152 |
| 1148 void VrShellGl::CreateVRDisplayInfo( | 1153 void VrShellGl::CreateVRDisplayInfo( |
| 1149 const base::Callback<void(device::mojom::VRDisplayInfoPtr)>& callback, | 1154 const base::Callback<void(device::mojom::VRDisplayInfoPtr)>& callback, |
| 1150 uint32_t device_id) { | 1155 uint32_t device_id) { |
| 1151 device::mojom::VRDisplayInfoPtr info = VrShell::CreateVRDisplayInfo( | 1156 device::mojom::VRDisplayInfoPtr info = VrShell::CreateVRDisplayInfo( |
| 1152 gvr_api_.get(), content_tex_physical_size_, device_id); | 1157 gvr_api_.get(), content_tex_physical_size_, device_id); |
| 1153 main_thread_task_runner_->PostTask( | 1158 main_thread_task_runner_->PostTask( |
| 1154 FROM_HERE, | 1159 FROM_HERE, |
| 1155 base::Bind(&RunVRDisplayInfoCallback, callback, base::Passed(&info))); | 1160 base::Bind(&RunVRDisplayInfoCallback, callback, base::Passed(&info))); |
| 1156 } | 1161 } |
| 1157 | 1162 |
| 1158 } // namespace vr_shell | 1163 } // namespace vr_shell |
| OLD | NEW |