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

Side by Side Diff: device/vr/android/gvr/gvr_device.cc

Issue 2384593002: Encode frame number in pixel data for pose sync (Closed)
Patch Set: Frame pose sync: fix oscillating off-by-one Created 4 years, 2 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 "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"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 right_eye->offset[0] = -right_eye_mat.m[0][3]; 123 right_eye->offset[0] = -right_eye_mat.m[0][3];
124 right_eye->offset[1] = -right_eye_mat.m[1][3]; 124 right_eye->offset[1] = -right_eye_mat.m[1][3];
125 right_eye->offset[2] = -right_eye_mat.m[2][3]; 125 right_eye->offset[2] = -right_eye_mat.m[2][3];
126 126
127 return device; 127 return device;
128 } 128 }
129 129
130 VRPosePtr GvrDevice::GetPose() { 130 VRPosePtr GvrDevice::GetPose() {
131 TRACE_EVENT0("input", "GvrDevice::GetSensorState"); 131 TRACE_EVENT0("input", "GvrDevice::GetSensorState");
132 132
133 // Increment pose frame counter always, even if it's a faked pose.
134 // This must stay in sync with the m_poseNum counter in
135 // third_party/WebKit/Source/modules/vr/VRDisplay.cpp.
136 ++frameNumStarted_;
137
133 VRPosePtr pose = VRPose::New(); 138 VRPosePtr pose = VRPose::New();
134 139
135 pose->timestamp = base::Time::Now().ToJsTime(); 140 pose->timestamp = base::Time::Now().ToJsTime();
136 141
137 pose->orientation = mojo::Array<float>::New(4); 142 pose->orientation = mojo::Array<float>::New(4);
138 143
139 gvr::GvrApi* gvr_api = GetGvrApi(); 144 gvr::GvrApi* gvr_api = GetGvrApi();
140 if (!gvr_api) { 145 if (!gvr_api) {
141 // If we don't have a GvrApi instance return a static forward orientation. 146 // If we don't have a GvrApi instance return a static forward orientation.
142 pose->orientation[0] = 0.0; 147 pose->orientation[0] = 0.0;
(...skipping 26 matching lines...) Expand all
169 pose->orientation[1] = decomposed_transform.quaternion[1]; 174 pose->orientation[1] = decomposed_transform.quaternion[1];
170 pose->orientation[2] = decomposed_transform.quaternion[2]; 175 pose->orientation[2] = decomposed_transform.quaternion[2];
171 pose->orientation[3] = decomposed_transform.quaternion[3]; 176 pose->orientation[3] = decomposed_transform.quaternion[3];
172 177
173 pose->position = mojo::Array<float>::New(3); 178 pose->position = mojo::Array<float>::New(3);
174 pose->position[0] = decomposed_transform.translate[0]; 179 pose->position[0] = decomposed_transform.translate[0];
175 pose->position[1] = decomposed_transform.translate[1]; 180 pose->position[1] = decomposed_transform.translate[1];
176 pose->position[2] = decomposed_transform.translate[2]; 181 pose->position[2] = decomposed_transform.translate[2];
177 } 182 }
178 183
184 // LOG << "klausw:GvrDevice::GetPose " << frameNumStarted_;
185 delegate_->SetGvrPoseForWebVr(head_mat, frameNumStarted_);
186
179 return pose; 187 return pose;
180 } 188 }
181 189
182 void GvrDevice::ResetPose() { 190 void GvrDevice::ResetPose() {
183 gvr::GvrApi* gvr_api = GetGvrApi(); 191 gvr::GvrApi* gvr_api = GetGvrApi();
184 if (gvr_api) 192 if (gvr_api)
185 gvr_api->ResetTracking(); 193 gvr_api->ResetTracking();
186 } 194 }
187 195
188 bool GvrDevice::RequestPresent(bool secure_origin) { 196 bool GvrDevice::RequestPresent(bool secure_origin) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 } 233 }
226 234
227 gvr::GvrApi* GvrDevice::GetGvrApi() { 235 gvr::GvrApi* GvrDevice::GetGvrApi() {
228 if (!delegate_) 236 if (!delegate_)
229 return nullptr; 237 return nullptr;
230 238
231 return delegate_->gvr_api(); 239 return delegate_->gvr_api();
232 } 240 }
233 241
234 } // namespace device 242 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698