Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: chrome/browser/android/vr_shell/non_presenting_gvr_delegate.cc

Issue 2770353002: WebVR: add angular velocity estimate to pose (Closed)
Patch Set: Enable linear accel, fix angular velocity to be in seated space Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/non_presenting_gvr_delegate.h" 5 #include "chrome/browser/android/vr_shell/non_presenting_gvr_delegate.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "chrome/browser/android/vr_shell/vr_shell.h" 10 #include "chrome/browser/android/vr_shell/vr_shell.h"
11 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/ gvr.h" 11 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/ gvr.h"
12 12
13 namespace vr_shell { 13 namespace vr_shell {
14 14
15 namespace { 15 namespace {
16 // TODO(klausw): These are duplicates from vr_shell_gl.cc, put in header file?
billorr 2017/03/27 17:33:53 any reason not to do this now?
klausw 2017/03/27 17:55:42 Done - though it's annoying that it's now no longe
16 static constexpr int64_t kPredictionTimeWithoutVsyncNanos = 50000000; 17 static constexpr int64_t kPredictionTimeWithoutVsyncNanos = 50000000;
18 static constexpr int64_t kAngularVelocityEpsilonNanos = 1000000;
17 } // namespace 19 } // namespace
18 20
19 NonPresentingGvrDelegate::NonPresentingGvrDelegate(gvr_context* context) 21 NonPresentingGvrDelegate::NonPresentingGvrDelegate(gvr_context* context)
20 : task_runner_(base::ThreadTaskRunnerHandle::Get()), 22 : task_runner_(base::ThreadTaskRunnerHandle::Get()),
21 binding_(this), 23 binding_(this),
22 weak_ptr_factory_(this) { 24 weak_ptr_factory_(this) {
23 // Context may be null, see VrShellDelegate#createNonPresentingNativeContext 25 // Context may be null, see VrShellDelegate#createNonPresentingNativeContext
24 // for possible reasons a context could fail to be created. For example, 26 // for possible reasons a context could fail to be created. For example,
25 // the user might uninstall apps or clear data after VR support was detected. 27 // the user might uninstall apps or clear data after VR support was detected.
26 if (context) 28 if (context)
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 target_time.monotonic_system_time_nanos += kPredictionTimeWithoutVsyncNanos; 148 target_time.monotonic_system_time_nanos += kPredictionTimeWithoutVsyncNanos;
147 149
148 if (!gvr_api_) { 150 if (!gvr_api_) {
149 callback.Run(device::mojom::VRPosePtr(nullptr), time, -1, 151 callback.Run(device::mojom::VRPosePtr(nullptr), time, -1,
150 device::mojom::VRVSyncProvider::Status::SUCCESS); 152 device::mojom::VRVSyncProvider::Status::SUCCESS);
151 return; 153 return;
152 } 154 }
153 155
154 gvr::Mat4f head_mat = gvr_api_->ApplyNeckModel( 156 gvr::Mat4f head_mat = gvr_api_->ApplyNeckModel(
155 gvr_api_->GetHeadSpaceFromStartSpaceRotation(target_time), 1.0f); 157 gvr_api_->GetHeadSpaceFromStartSpaceRotation(target_time), 1.0f);
156 callback.Run(VrShell::VRPosePtrFromGvrPose(head_mat), time, -1, 158
157 device::mojom::VRVSyncProvider::Status::SUCCESS); 159 target_time.monotonic_system_time_nanos += kAngularVelocityEpsilonNanos;
160 gvr::Mat4f head_mat_2 =
161 gvr_api_->GetHeadSpaceFromStartSpaceRotation(target_time);
162
163 callback.Run(VrShell::VRPosePtrFromGvrPose(head_mat, head_mat_2,
164 kAngularVelocityEpsilonNanos),
165 time, -1, device::mojom::VRVSyncProvider::Status::SUCCESS);
158 } 166 }
159 167
160 bool NonPresentingGvrDelegate::SupportsPresentation() { 168 bool NonPresentingGvrDelegate::SupportsPresentation() {
161 return false; 169 return false;
162 } 170 }
163 171
164 void NonPresentingGvrDelegate::ResetPose() { 172 void NonPresentingGvrDelegate::ResetPose() {
165 // Should never call RecenterTracking when using with Daydream viewers. On 173 // Should never call RecenterTracking when using with Daydream viewers. On
166 // those devices recentering should only be done via the controller. 174 // those devices recentering should only be done via the controller.
167 if (gvr_api_ && gvr_api_->GetViewerType() == GVR_VIEWER_TYPE_CARDBOARD) 175 if (gvr_api_ && gvr_api_->GetViewerType() == GVR_VIEWER_TYPE_CARDBOARD)
168 gvr_api_->RecenterTracking(); 176 gvr_api_->RecenterTracking();
169 } 177 }
170 178
171 void NonPresentingGvrDelegate::CreateVRDisplayInfo( 179 void NonPresentingGvrDelegate::CreateVRDisplayInfo(
172 const base::Callback<void(device::mojom::VRDisplayInfoPtr)>& callback, 180 const base::Callback<void(device::mojom::VRDisplayInfoPtr)>& callback,
173 uint32_t device_id) { 181 uint32_t device_id) {
174 if (!gvr_api_) { 182 if (!gvr_api_) {
175 callback.Run(device::mojom::VRDisplayInfoPtr(nullptr)); 183 callback.Run(device::mojom::VRDisplayInfoPtr(nullptr));
176 return; 184 return;
177 } 185 }
178 186
179 gvr::Sizei webvr_size = VrShell::GetRecommendedWebVrSize(gvr_api_.get()); 187 gvr::Sizei webvr_size = VrShell::GetRecommendedWebVrSize(gvr_api_.get());
180 DVLOG(1) << __FUNCTION__ << ": resize recommended to " << webvr_size.width 188 DVLOG(1) << __FUNCTION__ << ": resize recommended to " << webvr_size.width
181 << "x" << webvr_size.height; 189 << "x" << webvr_size.height;
182 callback.Run( 190 callback.Run(
183 VrShell::CreateVRDisplayInfo(gvr_api_.get(), webvr_size, device_id)); 191 VrShell::CreateVRDisplayInfo(gvr_api_.get(), webvr_size, device_id));
184 } 192 }
185 193
186 } // namespace vr_shell 194 } // namespace vr_shell
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/vr_shell/vr_controller.cc » ('j') | chrome/browser/android/vr_shell/vr_controller.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698