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

Side by Side Diff: third_party/WebKit/Source/modules/vr/VRDisplay.cpp

Issue 2309523003: Plumbing through more WebVR presentation code (Closed)
Patch Set: Created 4 years, 3 months 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
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 "modules/vr/VRDisplay.h" 5 #include "modules/vr/VRDisplay.h"
6 6
7 #include "core/dom/DOMException.h" 7 #include "core/dom/DOMException.h"
8 #include "core/dom/Fullscreen.h" 8 #include "core/dom/Fullscreen.h"
9 #include "core/inspector/ConsoleMessage.h" 9 #include "core/inspector/ConsoleMessage.h"
10 #include "modules/vr/NavigatorVR.h" 10 #include "modules/vr/NavigatorVR.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 161
162 m_isPresenting = true; 162 m_isPresenting = true;
163 163
164 resolver->resolve(); 164 resolver->resolve();
165 165
166 m_navigatorVR->fireVRDisplayPresentChange(this); 166 m_navigatorVR->fireVRDisplayPresentChange(this);
167 167
168 // Check to see if the canvas is still the current fullscreen 168 // Check to see if the canvas is still the current fullscreen
169 // element once per second. 169 // element once per second.
170 m_fullscreenCheckTimer.startRepeating(1.0, BLINK_FROM_HERE); 170 m_fullscreenCheckTimer.startRepeating(1.0, BLINK_FROM_HERE);
171
172 controller()->requestPresent(m_displayId);
171 } else { 173 } else {
172 DOMException* exception = DOMException::create(InvalidStateError, "V R Presentation not implemented for this VRDisplay"); 174 DOMException* exception = DOMException::create(InvalidStateError, "V R Presentation not implemented for this VRDisplay");
173 resolver->reject(exception); 175 resolver->reject(exception);
174 } 176 }
177
178 // Set up the texture bounds for the provided layer
179 device::blink::VRLayerBoundsPtr leftBounds = device::blink::VRLayerBound s::New();
180 device::blink::VRLayerBoundsPtr rightBounds = device::blink::VRLayerBoun ds::New();
181
182 if (m_layer.hasLeftBounds()) {
183 leftBounds->left = m_layer.leftBounds()[0];
184 leftBounds->top = m_layer.leftBounds()[1];
185 leftBounds->width = m_layer.leftBounds()[2];
186 leftBounds->height = m_layer.leftBounds()[3];
187 } else {
188 // Left eye defaults
189 leftBounds->left = 0.0f;
190 leftBounds->top = 0.0f;
191 leftBounds->width = 0.5f;
192 leftBounds->height = 1.0f;
193 }
194
195 if (m_layer.hasRightBounds()) {
196 rightBounds->left = m_layer.rightBounds()[0];
197 rightBounds->top = m_layer.rightBounds()[1];
198 rightBounds->width = m_layer.rightBounds()[2];
199 rightBounds->height = m_layer.rightBounds()[3];
200 } else {
201 // Right eye defaults
202 rightBounds->left = 0.5f;
203 rightBounds->top = 0.0f;
204 rightBounds->width = 0.5f;
205 rightBounds->height = 1.0f;
206 }
207
208 controller()->updateLayerBounds(m_displayId, std::move(leftBounds), std: :move(rightBounds));
175 } else { 209 } else {
176 DOMException* exception = DOMException::create(InvalidStateError, "Inval id layer source"); 210 DOMException* exception = DOMException::create(InvalidStateError, "Inval id layer source");
177 resolver->reject(exception); 211 resolver->reject(exception);
178 } 212 }
179 213
180 return promise; 214 return promise;
181 } 215 }
182 216
183 ScriptPromise VRDisplay::exitPresent(ScriptState* scriptState) 217 ScriptPromise VRDisplay::exitPresent(ScriptState* scriptState)
184 { 218 {
185 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 219 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
186 ScriptPromise promise = resolver->promise(); 220 ScriptPromise promise = resolver->promise();
187 221
188 if (!m_isPresenting) { 222 if (!m_isPresenting) {
189 // Can't stop presenting if we're not presenting. 223 // Can't stop presenting if we're not presenting.
190 DOMException* exception = DOMException::create(InvalidStateError, "VRDis play is not presenting"); 224 DOMException* exception = DOMException::create(InvalidStateError, "VRDis play is not presenting");
191 resolver->reject(exception); 225 resolver->reject(exception);
192 return promise; 226 return promise;
193 } 227 }
194 228
195 if (!m_capabilities->hasExternalDisplay()) { 229 if (!m_capabilities->hasExternalDisplay()) {
196 Fullscreen::fullyExitFullscreen(m_layer.source()->document()); 230 Fullscreen::fullyExitFullscreen(m_layer.source()->document());
197 m_fullscreenCheckTimer.stop(); 231 m_fullscreenCheckTimer.stop();
232 controller()->exitPresent(m_displayId);
198 } else { 233 } else {
199 // Can't get into this presentation mode, so nothing to do here. 234 // Can't get into this presentation mode, so nothing to do here.
200 } 235 }
201 236
202 m_isPresenting = false; 237 m_isPresenting = false;
203 238
204 // TODO: Resolve when exit is confirmed 239 // TODO: Resolve when exit is confirmed
205 resolver->resolve(); 240 resolver->resolve();
206 241
207 m_navigatorVR->fireVRDisplayPresentChange(this); 242 m_navigatorVR->fireVRDisplayPresentChange(this);
208 243
209 return promise; 244 return promise;
210 } 245 }
211 246
212 HeapVector<VRLayer> VRDisplay::getLayers() 247 HeapVector<VRLayer> VRDisplay::getLayers()
213 { 248 {
214 HeapVector<VRLayer> layers; 249 HeapVector<VRLayer> layers;
215 250
216 if (m_isPresenting) { 251 if (m_isPresenting) {
217 layers.append(m_layer); 252 layers.append(m_layer);
218 } 253 }
219 254
220 return layers; 255 return layers;
221 } 256 }
222 257
223 void VRDisplay::submitFrame(VRPose* pose) 258 void VRDisplay::submitFrame(VRPose* pose)
224 { 259 {
260 controller()->submitFrame(m_displayId);
225 } 261 }
226 262
227 void VRDisplay::didProcessTask() 263 void VRDisplay::didProcessTask()
228 { 264 {
229 // Pose should be stable until control is returned to the user agent. 265 // Pose should be stable until control is returned to the user agent.
230 if (!m_canUpdateFramePose) { 266 if (!m_canUpdateFramePose) {
231 Platform::current()->currentThread()->removeTaskObserver(this); 267 Platform::current()->currentThread()->removeTaskObserver(this);
232 m_canUpdateFramePose = true; 268 m_canUpdateFramePose = true;
233 } 269 }
234 } 270 }
235 271
236 void VRDisplay::onFullscreenCheck(TimerBase*) 272 void VRDisplay::onFullscreenCheck(TimerBase*)
237 { 273 {
238 // TODO: This is a temporary measure to track if fullscreen mode has been 274 // TODO: This is a temporary measure to track if fullscreen mode has been
239 // exited by the UA. If so we need to end VR presentation. Soon we won't 275 // exited by the UA. If so we need to end VR presentation. Soon we won't
240 // depend on the Fullscreen API to fake VR presentation, so this will 276 // depend on the Fullscreen API to fake VR presentation, so this will
241 // become unnessecary. Until that point, though, this seems preferable to 277 // become unnessecary. Until that point, though, this seems preferable to
242 // adding a bunch of notification plumbing to Fullscreen. 278 // adding a bunch of notification plumbing to Fullscreen.
243 if (!Fullscreen::isCurrentFullScreenElement(*m_layer.source())) { 279 if (!Fullscreen::isCurrentFullScreenElement(*m_layer.source())) {
244 m_isPresenting = false; 280 m_isPresenting = false;
245 m_navigatorVR->fireVRDisplayPresentChange(this); 281 m_navigatorVR->fireVRDisplayPresentChange(this);
246 m_fullscreenCheckTimer.stop(); 282 m_fullscreenCheckTimer.stop();
283 controller()->exitPresent(m_displayId);
247 } 284 }
248 } 285 }
249 286
250 DEFINE_TRACE(VRDisplay) 287 DEFINE_TRACE(VRDisplay)
251 { 288 {
252 visitor->trace(m_navigatorVR); 289 visitor->trace(m_navigatorVR);
253 visitor->trace(m_capabilities); 290 visitor->trace(m_capabilities);
254 visitor->trace(m_stageParameters); 291 visitor->trace(m_stageParameters);
255 visitor->trace(m_eyeParametersLeft); 292 visitor->trace(m_eyeParametersLeft);
256 visitor->trace(m_eyeParametersRight); 293 visitor->trace(m_eyeParametersRight);
257 visitor->trace(m_framePose); 294 visitor->trace(m_framePose);
258 visitor->trace(m_layer); 295 visitor->trace(m_layer);
259 } 296 }
260 297
261 } // namespace blink 298 } // namespace blink
OLDNEW
« device/vr/android/gvr/gvr_device.cc ('K') | « third_party/WebKit/Source/modules/vr/VRController.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698