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

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

Issue 2550803002: WebVR: avoid race conditions for partially-initialized display (Closed)
Patch Set: Created 4 years 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_delegate.h ('k') | third_party/WebKit/Source/modules/vr/VRDisplay.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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 device->rightEye = mojom::VREyeParameters::New(); 48 device->rightEye = mojom::VREyeParameters::New();
49 mojom::VREyeParametersPtr& left_eye = device->leftEye; 49 mojom::VREyeParametersPtr& left_eye = device->leftEye;
50 mojom::VREyeParametersPtr& right_eye = device->rightEye; 50 mojom::VREyeParametersPtr& right_eye = device->rightEye;
51 51
52 left_eye->fieldOfView = mojom::VRFieldOfView::New(); 52 left_eye->fieldOfView = mojom::VRFieldOfView::New();
53 right_eye->fieldOfView = mojom::VRFieldOfView::New(); 53 right_eye->fieldOfView = mojom::VRFieldOfView::New();
54 54
55 left_eye->offset.resize(3); 55 left_eye->offset.resize(3);
56 right_eye->offset.resize(3); 56 right_eye->offset.resize(3);
57 57
58 // TODO(bajones): GVR has a bug that causes it to return bad render target 58 // Set the render target size to "invalid" to indicate that
59 // sizes when the phone is in portait mode. Send arbitrary, 59 // we can't render into it yet. Other code uses this to check
60 // not-horrifically-wrong values instead. 60 // for valid state.
61 // gvr::Sizei render_target_size = gvr_api->GetRecommendedRenderTargetSize(); 61 gvr::Sizei render_target_size = kInvalidRenderTargetSize;
62 gvr::Sizei render_target_size = kFallbackRenderTargetSize;
63 left_eye->renderWidth = render_target_size.width / 2; 62 left_eye->renderWidth = render_target_size.width / 2;
64 left_eye->renderHeight = render_target_size.height; 63 left_eye->renderHeight = render_target_size.height;
65 64
66 right_eye->renderWidth = left_eye->renderWidth; 65 right_eye->renderWidth = left_eye->renderWidth;
67 right_eye->renderHeight = left_eye->renderHeight; 66 right_eye->renderHeight = left_eye->renderHeight;
68 67
69 gvr::GvrApi* gvr_api = GetGvrApi(); 68 gvr::GvrApi* gvr_api = GetGvrApi();
70 if (!gvr_api) { 69 if (!gvr_api) {
71 // We may not be able to get an instance of GvrApi right away, so 70 // We may not be able to get an instance of GvrApi right away, so
72 // stub in some data till we have one. 71 // stub in some data till we have one.
(...skipping 10 matching lines...) Expand all
83 right_eye->fieldOfView->rightDegrees = 45; 82 right_eye->fieldOfView->rightDegrees = 45;
84 83
85 left_eye->offset[0] = -0.0; 84 left_eye->offset[0] = -0.0;
86 left_eye->offset[1] = -0.0; 85 left_eye->offset[1] = -0.0;
87 left_eye->offset[2] = -0.03; 86 left_eye->offset[2] = -0.03;
88 87
89 right_eye->offset[0] = 0.0; 88 right_eye->offset[0] = 0.0;
90 right_eye->offset[1] = 0.0; 89 right_eye->offset[1] = 0.0;
91 right_eye->offset[2] = 0.03; 90 right_eye->offset[2] = 0.03;
92 91
93 delegate_->SetWebVRRenderSurfaceSize(2 * left_eye->renderWidth, 92 // Tell the delegate not to draw yet, to avoid a race condition
94 left_eye->renderHeight); 93 // (and visible wobble) on entering VR.
94 delegate_->SetWebVRRenderSurfaceSize(kInvalidRenderTargetSize.width,
95 kInvalidRenderTargetSize.height);
95 96
96 return device; 97 return device;
97 } 98 }
98 99
99 // In compositor mode, we have to use the current compositor window's 100 // In compositor mode, we have to use the current compositor window's
100 // surface size. Would be nice to change it, but that needs more browser 101 // surface size. Would be nice to change it, but that needs more browser
101 // internals to be modified. TODO(klausw,crbug.com/655722): remove this once 102 // internals to be modified. TODO(klausw,crbug.com/655722): remove this once
102 // we can pick our own surface size. 103 // we can pick our own surface size.
103 gvr::Sizei compositor_size = delegate_->GetWebVRCompositorSurfaceSize(); 104 gvr::Sizei compositor_size = delegate_->GetWebVRCompositorSurfaceSize();
104 left_eye->renderWidth = compositor_size.width / 2; 105 left_eye->renderWidth = compositor_size.width / 2;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 } 269 }
269 270
270 gvr::GvrApi* GvrDevice::GetGvrApi() { 271 gvr::GvrApi* GvrDevice::GetGvrApi() {
271 if (!delegate_) 272 if (!delegate_)
272 return nullptr; 273 return nullptr;
273 274
274 return delegate_->gvr_api(); 275 return delegate_->gvr_api();
275 } 276 }
276 277
277 } // namespace device 278 } // namespace device
OLDNEW
« no previous file with comments | « device/vr/android/gvr/gvr_delegate.h ('k') | third_party/WebKit/Source/modules/vr/VRDisplay.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698