| 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 "device/vr/android/gvr/gvr_device.h" | 5 #include "device/vr/android/gvr/gvr_device.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 | 9 |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
| 12 #include "device/vr/android/gvr/gvr_delegate.h" | 12 #include "device/vr/android/gvr/gvr_delegate.h" |
| 13 #include "device/vr/vr_device_manager.h" | 13 #include "device/vr/vr_device_manager.h" |
| 14 #include "third_party/gvr-android-sdk/src/ndk/include/vr/gvr/capi/include/gvr.h" | 14 #include "third_party/gvr-android-sdk/src/ndk-beta/include/vr/gvr/capi/include/g
vr.h" |
| 15 #include "third_party/gvr-android-sdk/src/ndk/include/vr/gvr/capi/include/gvr_ty
pes.h" | 15 #include "third_party/gvr-android-sdk/src/ndk-beta/include/vr/gvr/capi/include/g
vr_types.h" |
| 16 #include "ui/gfx/transform.h" | 16 #include "ui/gfx/transform.h" |
| 17 #include "ui/gfx/transform_util.h" | 17 #include "ui/gfx/transform_util.h" |
| 18 | 18 |
| 19 namespace device { | 19 namespace device { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 static const uint64_t kPredictionTimeWithoutVsyncNanos = 50000000; | 23 static const uint64_t kPredictionTimeWithoutVsyncNanos = 50000000; |
| 24 | 24 |
| 25 } // namespace | 25 } // namespace |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 pose->orientation[1] = 0.0; | 143 pose->orientation[1] = 0.0; |
| 144 pose->orientation[2] = 0.0; | 144 pose->orientation[2] = 0.0; |
| 145 pose->orientation[3] = 1.0; | 145 pose->orientation[3] = 1.0; |
| 146 | 146 |
| 147 return pose; | 147 return pose; |
| 148 } | 148 } |
| 149 | 149 |
| 150 gvr::ClockTimePoint target_time = gvr::GvrApi::GetTimePointNow(); | 150 gvr::ClockTimePoint target_time = gvr::GvrApi::GetTimePointNow(); |
| 151 target_time.monotonic_system_time_nanos += kPredictionTimeWithoutVsyncNanos; | 151 target_time.monotonic_system_time_nanos += kPredictionTimeWithoutVsyncNanos; |
| 152 | 152 |
| 153 gvr::Mat4f head_mat = | 153 gvr::Mat4f head_mat = gvr_api->GetHeadPoseInStartSpace(target_time); |
| 154 gvr_api->GetHeadSpaceFromStartSpaceRotation(target_time); | |
| 155 head_mat = gvr_api->ApplyNeckModel(head_mat, 1.0f); | |
| 156 | 154 |
| 157 gfx::Transform inv_transform( | 155 gfx::Transform inv_transform( |
| 158 head_mat.m[0][0], head_mat.m[0][1], head_mat.m[0][2], head_mat.m[0][3], | 156 head_mat.m[0][0], head_mat.m[0][1], head_mat.m[0][2], head_mat.m[0][3], |
| 159 head_mat.m[1][0], head_mat.m[1][1], head_mat.m[1][2], head_mat.m[1][3], | 157 head_mat.m[1][0], head_mat.m[1][1], head_mat.m[1][2], head_mat.m[1][3], |
| 160 head_mat.m[2][0], head_mat.m[2][1], head_mat.m[2][2], head_mat.m[2][3], | 158 head_mat.m[2][0], head_mat.m[2][1], head_mat.m[2][2], head_mat.m[2][3], |
| 161 head_mat.m[3][0], head_mat.m[3][1], head_mat.m[3][2], head_mat.m[3][3]); | 159 head_mat.m[3][0], head_mat.m[3][1], head_mat.m[3][2], head_mat.m[3][3]); |
| 162 | 160 |
| 163 gfx::Transform transform; | 161 gfx::Transform transform; |
| 164 if (inv_transform.GetInverse(&transform)) { | 162 if (inv_transform.GetInverse(&transform)) { |
| 165 gfx::DecomposedTransform decomposed_transform; | 163 gfx::DecomposedTransform decomposed_transform; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 } | 218 } |
| 221 | 219 |
| 222 gvr::GvrApi* GvrDevice::GetGvrApi() { | 220 gvr::GvrApi* GvrDevice::GetGvrApi() { |
| 223 if (!delegate_) | 221 if (!delegate_) |
| 224 return nullptr; | 222 return nullptr; |
| 225 | 223 |
| 226 return delegate_->gvr_api(); | 224 return delegate_->gvr_api(); |
| 227 } | 225 } |
| 228 | 226 |
| 229 } // namespace device | 227 } // namespace device |
| OLD | NEW |