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