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-beta/include/vr/gvr/capi/include/g vr.h" | 14 #include "third_party/gvr-android-sdk/src/ndk/include/vr/gvr/capi/include/gvr.h" |
15 #include "third_party/gvr-android-sdk/src/ndk-beta/include/vr/gvr/capi/include/g vr_types.h" | 15 #include "third_party/gvr-android-sdk/src/ndk/include/vr/gvr/capi/include/gvr_ty pes.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 = gvr_api->GetHeadPoseInStartSpace(target_time); | 153 gvr::Mat4f head_mat = |
154 gvr_api->GetHeadSpaceFromStartSpaceRotation(target_time); | |
155 head_mat = gvr_api->ApplyNeckModel(head_mat, 1.0f); | |
154 | 156 |
155 gfx::Transform inv_transform( | 157 gfx::Transform inv_transform( |
billorr
2016/09/23 17:26:24
do we have a naming convention for transforms? I
| |
156 head_mat.m[0][0], head_mat.m[0][1], head_mat.m[0][2], head_mat.m[0][3], | 158 head_mat.m[0][0], head_mat.m[0][1], head_mat.m[0][2], head_mat.m[0][3], |
157 head_mat.m[1][0], head_mat.m[1][1], head_mat.m[1][2], head_mat.m[1][3], | 159 head_mat.m[1][0], head_mat.m[1][1], head_mat.m[1][2], head_mat.m[1][3], |
158 head_mat.m[2][0], head_mat.m[2][1], head_mat.m[2][2], head_mat.m[2][3], | 160 head_mat.m[2][0], head_mat.m[2][1], head_mat.m[2][2], head_mat.m[2][3], |
159 head_mat.m[3][0], head_mat.m[3][1], head_mat.m[3][2], head_mat.m[3][3]); | 161 head_mat.m[3][0], head_mat.m[3][1], head_mat.m[3][2], head_mat.m[3][3]); |
160 | 162 |
161 gfx::Transform transform; | 163 gfx::Transform transform; |
162 if (inv_transform.GetInverse(&transform)) { | 164 if (inv_transform.GetInverse(&transform)) { |
163 gfx::DecomposedTransform decomposed_transform; | 165 gfx::DecomposedTransform decomposed_transform; |
164 gfx::DecomposeTransform(&decomposed_transform, transform); | 166 gfx::DecomposeTransform(&decomposed_transform, transform); |
165 | 167 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 } | 220 } |
219 | 221 |
220 gvr::GvrApi* GvrDevice::GetGvrApi() { | 222 gvr::GvrApi* GvrDevice::GetGvrApi() { |
221 if (!delegate_) | 223 if (!delegate_) |
222 return nullptr; | 224 return nullptr; |
223 | 225 |
224 return delegate_->gvr_api(); | 226 return delegate_->gvr_api(); |
225 } | 227 } |
226 | 228 |
227 } // namespace device | 229 } // namespace device |
OLD | NEW |