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

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: bajones #40: add sanity check + pointer zeroing 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
« no previous file with comments | « device/vr/android/gvr/gvr_device.h ('k') | device/vr/android/gvr/gvr_device_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 VRPosePtr pose = VRPose::New(); 133 VRPosePtr pose = VRPose::New();
134 134
135 pose->timestamp = base::Time::Now().ToJsTime(); 135 pose->timestamp = base::Time::Now().ToJsTime();
136 136
137 // Increment pose frame counter always, even if it's a faked pose.
138 pose->poseIndex = ++pose_index_;
139
137 pose->orientation = mojo::Array<float>::New(4); 140 pose->orientation = mojo::Array<float>::New(4);
138 141
139 gvr::GvrApi* gvr_api = GetGvrApi(); 142 gvr::GvrApi* gvr_api = GetGvrApi();
140 if (!gvr_api) { 143 if (!gvr_api) {
141 // If we don't have a GvrApi instance return a static forward orientation. 144 // If we don't have a GvrApi instance return a static forward orientation.
142 pose->orientation[0] = 0.0; 145 pose->orientation[0] = 0.0;
143 pose->orientation[1] = 0.0; 146 pose->orientation[1] = 0.0;
144 pose->orientation[2] = 0.0; 147 pose->orientation[2] = 0.0;
145 pose->orientation[3] = 1.0; 148 pose->orientation[3] = 1.0;
146 149
(...skipping 22 matching lines...) Expand all
169 pose->orientation[1] = decomposed_transform.quaternion[1]; 172 pose->orientation[1] = decomposed_transform.quaternion[1];
170 pose->orientation[2] = decomposed_transform.quaternion[2]; 173 pose->orientation[2] = decomposed_transform.quaternion[2];
171 pose->orientation[3] = decomposed_transform.quaternion[3]; 174 pose->orientation[3] = decomposed_transform.quaternion[3];
172 175
173 pose->position = mojo::Array<float>::New(3); 176 pose->position = mojo::Array<float>::New(3);
174 pose->position[0] = decomposed_transform.translate[0]; 177 pose->position[0] = decomposed_transform.translate[0];
175 pose->position[1] = decomposed_transform.translate[1]; 178 pose->position[1] = decomposed_transform.translate[1];
176 pose->position[2] = decomposed_transform.translate[2]; 179 pose->position[2] = decomposed_transform.translate[2];
177 } 180 }
178 181
182 // Save the underlying GVR pose for use by rendering. It can't use a
183 // VRPosePtr since that's a different data type.
184 delegate_->SetGvrPoseForWebVr(head_mat, pose_index_);
185
179 return pose; 186 return pose;
180 } 187 }
181 188
182 void GvrDevice::ResetPose() { 189 void GvrDevice::ResetPose() {
183 gvr::GvrApi* gvr_api = GetGvrApi(); 190 gvr::GvrApi* gvr_api = GetGvrApi();
184 if (gvr_api) 191 if (gvr_api)
185 gvr_api->ResetTracking(); 192 gvr_api->ResetTracking();
186 } 193 }
187 194
188 bool GvrDevice::RequestPresent(bool secure_origin) { 195 bool GvrDevice::RequestPresent(bool secure_origin) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 } 232 }
226 233
227 gvr::GvrApi* GvrDevice::GetGvrApi() { 234 gvr::GvrApi* GvrDevice::GetGvrApi() {
228 if (!delegate_) 235 if (!delegate_)
229 return nullptr; 236 return nullptr;
230 237
231 return delegate_->gvr_api(); 238 return delegate_->gvr_api();
232 } 239 }
233 240
234 } // namespace device 241 } // namespace device
OLDNEW
« no previous file with comments | « device/vr/android/gvr/gvr_device.h ('k') | device/vr/android/gvr/gvr_device_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698