| 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 void GvrDevice::ExitPresent() { | 172 void GvrDevice::ExitPresent() { |
| 173 gvr_provider_->ExitPresent(); | 173 gvr_provider_->ExitPresent(); |
| 174 OnExitPresent(); | 174 OnExitPresent(); |
| 175 } | 175 } |
| 176 | 176 |
| 177 void GvrDevice::SubmitFrame(mojom::VRPosePtr pose) { | 177 void GvrDevice::SubmitFrame(mojom::VRPosePtr pose) { |
| 178 if (delegate_) | 178 if (delegate_) |
| 179 delegate_->SubmitWebVRFrame(); | 179 delegate_->SubmitWebVRFrame(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 void GvrDevice::UpdateLayerBounds(mojom::VRLayerBoundsPtr left_bounds, | 182 void GvrDevice::UpdateLayerBounds(int16_t frame_index, |
| 183 mojom::VRLayerBoundsPtr left_bounds, |
| 183 mojom::VRLayerBoundsPtr right_bounds) { | 184 mojom::VRLayerBoundsPtr right_bounds) { |
| 184 if (!delegate_) | 185 if (!delegate_) |
| 185 return; | 186 return; |
| 186 | 187 |
| 187 gvr::Rectf left_gvr_bounds; | 188 gvr::Rectf left_gvr_bounds; |
| 188 left_gvr_bounds.left = left_bounds->left; | 189 left_gvr_bounds.left = left_bounds->left; |
| 189 left_gvr_bounds.top = 1.0f - left_bounds->top; | 190 left_gvr_bounds.top = 1.0f - left_bounds->top; |
| 190 left_gvr_bounds.right = left_bounds->left + left_bounds->width; | 191 left_gvr_bounds.right = left_bounds->left + left_bounds->width; |
| 191 left_gvr_bounds.bottom = 1.0f - (left_bounds->top + left_bounds->height); | 192 left_gvr_bounds.bottom = 1.0f - (left_bounds->top + left_bounds->height); |
| 192 | 193 |
| 193 gvr::Rectf right_gvr_bounds; | 194 gvr::Rectf right_gvr_bounds; |
| 194 right_gvr_bounds.left = right_bounds->left; | 195 right_gvr_bounds.left = right_bounds->left; |
| 195 right_gvr_bounds.top = 1.0f - right_bounds->top; | 196 right_gvr_bounds.top = 1.0f - right_bounds->top; |
| 196 right_gvr_bounds.right = right_bounds->left + right_bounds->width; | 197 right_gvr_bounds.right = right_bounds->left + right_bounds->width; |
| 197 right_gvr_bounds.bottom = 1.0f - (right_bounds->top + right_bounds->height); | 198 right_gvr_bounds.bottom = 1.0f - (right_bounds->top + right_bounds->height); |
| 198 | 199 |
| 199 delegate_->UpdateWebVRTextureBounds(left_gvr_bounds, right_gvr_bounds); | 200 delegate_->UpdateWebVRTextureBounds(frame_index, left_gvr_bounds, |
| 201 right_gvr_bounds); |
| 200 } | 202 } |
| 201 | 203 |
| 202 void GvrDevice::GetVRVSyncProvider(mojom::VRVSyncProviderRequest request) { | 204 void GvrDevice::GetVRVSyncProvider(mojom::VRVSyncProviderRequest request) { |
| 203 if (delegate_) | 205 if (delegate_) |
| 204 delegate_->OnVRVsyncProviderRequest(std::move(request)); | 206 delegate_->OnVRVsyncProviderRequest(std::move(request)); |
| 205 } | 207 } |
| 206 | 208 |
| 207 void GvrDevice::SetDelegate(GvrDelegate* delegate) { | 209 void GvrDevice::SetDelegate(GvrDelegate* delegate) { |
| 208 delegate_ = delegate; | 210 delegate_ = delegate; |
| 209 | 211 |
| 210 // Notify the clients that this device has changed | 212 // Notify the clients that this device has changed |
| 211 if (delegate_) { | 213 if (delegate_) { |
| 212 delegate_->SetWebVRSecureOrigin(secure_origin_); | 214 delegate_->SetWebVRSecureOrigin(secure_origin_); |
| 213 OnChanged(); | 215 OnChanged(); |
| 214 } | 216 } |
| 215 } | 217 } |
| 216 | 218 |
| 217 gvr::GvrApi* GvrDevice::GetGvrApi() { | 219 gvr::GvrApi* GvrDevice::GetGvrApi() { |
| 218 if (!delegate_) | 220 if (!delegate_) |
| 219 return nullptr; | 221 return nullptr; |
| 220 | 222 |
| 221 return delegate_->gvr_api(); | 223 return delegate_->gvr_api(); |
| 222 } | 224 } |
| 223 | 225 |
| 224 } // namespace device | 226 } // namespace device |
| OLD | NEW |