| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 void GvrDevice::ExitPresent() { | 211 void GvrDevice::ExitPresent() { |
| 212 gvr_provider_->ExitPresent(); | 212 gvr_provider_->ExitPresent(); |
| 213 OnExitPresent(); | 213 OnExitPresent(); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void GvrDevice::SubmitFrame(mojom::VRPosePtr pose) { | 216 void GvrDevice::SubmitFrame(mojom::VRPosePtr pose) { |
| 217 if (delegate_) | 217 if (delegate_) |
| 218 delegate_->SubmitWebVRFrame(); | 218 delegate_->SubmitWebVRFrame(); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void GvrDevice::UpdateLayerBounds(mojom::VRLayerBoundsPtr leftBounds, | 221 void GvrDevice::UpdateLayerBounds(mojom::VRLayerBoundsPtr left_bounds, |
| 222 mojom::VRLayerBoundsPtr rightBounds) { | 222 mojom::VRLayerBoundsPtr right_bounds) { |
| 223 if (!delegate_) | 223 if (!delegate_) |
| 224 return; | 224 return; |
| 225 | 225 |
| 226 delegate_->UpdateWebVRTextureBounds(0, // Left eye | 226 gvr::Rectf left_gvr_bounds; |
| 227 leftBounds->left, leftBounds->top, | 227 left_gvr_bounds.left = left_bounds->left; |
| 228 leftBounds->width, leftBounds->height); | 228 left_gvr_bounds.top = 1.0f - left_bounds->top; |
| 229 delegate_->UpdateWebVRTextureBounds(1, // Right eye | 229 left_gvr_bounds.right = left_bounds->left + left_bounds->width; |
| 230 rightBounds->left, rightBounds->top, | 230 left_gvr_bounds.bottom = 1.0f - (left_bounds->top + left_bounds->height); |
| 231 rightBounds->width, rightBounds->height); | 231 |
| 232 gvr::Rectf right_gvr_bounds; |
| 233 right_gvr_bounds.left = right_bounds->left; |
| 234 right_gvr_bounds.top = 1.0f - right_bounds->top; |
| 235 right_gvr_bounds.right = right_bounds->left + right_bounds->width; |
| 236 right_gvr_bounds.bottom = 1.0f - (right_bounds->top + right_bounds->height); |
| 237 |
| 238 delegate_->UpdateWebVRTextureBounds(left_gvr_bounds, right_gvr_bounds); |
| 232 } | 239 } |
| 233 | 240 |
| 234 void GvrDevice::SetDelegate(const base::WeakPtr<GvrDelegate>& delegate) { | 241 void GvrDevice::SetDelegate(const base::WeakPtr<GvrDelegate>& delegate) { |
| 235 delegate_ = delegate; | 242 delegate_ = delegate; |
| 236 | 243 |
| 237 // Notify the clients that this device has changed | 244 // Notify the clients that this device has changed |
| 238 if (delegate_) { | 245 if (delegate_) { |
| 239 delegate_->SetWebVRSecureOrigin(secure_origin_); | 246 delegate_->SetWebVRSecureOrigin(secure_origin_); |
| 240 OnDisplayChanged(); | 247 OnDisplayChanged(); |
| 241 } | 248 } |
| 242 } | 249 } |
| 243 | 250 |
| 244 gvr::GvrApi* GvrDevice::GetGvrApi() { | 251 gvr::GvrApi* GvrDevice::GetGvrApi() { |
| 245 if (!delegate_) | 252 if (!delegate_) |
| 246 return nullptr; | 253 return nullptr; |
| 247 | 254 |
| 248 return delegate_->gvr_api(); | 255 return delegate_->gvr_api(); |
| 249 } | 256 } |
| 250 | 257 |
| 251 } // namespace device | 258 } // namespace device |
| OLD | NEW |