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