Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: device/vr/android/gvr/gvr_device.cc

Issue 2499793002: Refactoring how WebVR eye bounds are handled (Closed)
Patch Set: Rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/vr/android/gvr/gvr_device.h ('k') | device/vr/vr_device.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « device/vr/android/gvr/gvr_device.h ('k') | device/vr/vr_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698