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" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 176 |
177 return pose; | 177 return pose; |
178 } | 178 } |
179 | 179 |
180 void GvrDevice::ResetPose() { | 180 void GvrDevice::ResetPose() { |
181 gvr::GvrApi* gvr_api = GetGvrApi(); | 181 gvr::GvrApi* gvr_api = GetGvrApi(); |
182 if (gvr_api) | 182 if (gvr_api) |
183 gvr_api->ResetTracking(); | 183 gvr_api->ResetTracking(); |
184 } | 184 } |
185 | 185 |
186 bool GvrDevice::RequestPresent() { | 186 bool GvrDevice::RequestPresent(bool secure_origin) { |
| 187 LOG(ERROR) << "GvrDevice::RequestPresent: " << secure_origin; |
| 188 secure_origin_ = secure_origin; |
| 189 if (delegate_) |
| 190 delegate_->SetWebVRSecureOrigin(secure_origin_); |
187 return gvr_provider_->RequestPresent(); | 191 return gvr_provider_->RequestPresent(); |
188 } | 192 } |
189 | 193 |
190 void GvrDevice::ExitPresent() { | 194 void GvrDevice::ExitPresent() { |
191 gvr_provider_->ExitPresent(); | 195 gvr_provider_->ExitPresent(); |
192 } | 196 } |
193 | 197 |
194 void GvrDevice::SubmitFrame(VRPosePtr pose) { | 198 void GvrDevice::SubmitFrame(VRPosePtr pose) { |
195 if (delegate_) | 199 if (delegate_) |
196 delegate_->SubmitWebVRFrame(); | 200 delegate_->SubmitWebVRFrame(); |
197 } | 201 } |
198 | 202 |
199 void GvrDevice::UpdateLayerBounds(VRLayerBoundsPtr leftBounds, | 203 void GvrDevice::UpdateLayerBounds(VRLayerBoundsPtr leftBounds, |
200 VRLayerBoundsPtr rightBounds) { | 204 VRLayerBoundsPtr rightBounds) { |
201 if (!delegate_) | 205 if (!delegate_) |
202 return; | 206 return; |
203 | 207 |
204 delegate_->UpdateWebVRTextureBounds(0, // Left eye | 208 delegate_->UpdateWebVRTextureBounds(0, // Left eye |
205 leftBounds->left, leftBounds->top, | 209 leftBounds->left, leftBounds->top, |
206 leftBounds->width, leftBounds->height); | 210 leftBounds->width, leftBounds->height); |
207 delegate_->UpdateWebVRTextureBounds(1, // Right eye | 211 delegate_->UpdateWebVRTextureBounds(1, // Right eye |
208 rightBounds->left, rightBounds->top, | 212 rightBounds->left, rightBounds->top, |
209 rightBounds->width, rightBounds->height); | 213 rightBounds->width, rightBounds->height); |
210 } | 214 } |
211 | 215 |
212 void GvrDevice::SetDelegate(GvrDelegate* delegate) { | 216 void GvrDevice::SetDelegate(GvrDelegate* delegate) { |
213 delegate_ = delegate; | 217 delegate_ = delegate; |
214 | 218 |
215 // Notify the clients that this device has changed | 219 // Notify the clients that this device has changed |
216 if (delegate_) | 220 if (delegate_) { |
| 221 delegate_->SetWebVRSecureOrigin(secure_origin_); |
217 VRDeviceManager::GetInstance()->OnDeviceChanged(GetVRDevice()); | 222 VRDeviceManager::GetInstance()->OnDeviceChanged(GetVRDevice()); |
| 223 } |
218 } | 224 } |
219 | 225 |
220 gvr::GvrApi* GvrDevice::GetGvrApi() { | 226 gvr::GvrApi* GvrDevice::GetGvrApi() { |
221 if (!delegate_) | 227 if (!delegate_) |
222 return nullptr; | 228 return nullptr; |
223 | 229 |
224 return delegate_->gvr_api(); | 230 return delegate_->gvr_api(); |
225 } | 231 } |
226 | 232 |
227 } // namespace device | 233 } // namespace device |
OLD | NEW |