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 "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/DocumentUserGestureToken.h" |
8 #include "core/dom/FrameRequestCallback.h" | 9 #include "core/dom/FrameRequestCallback.h" |
9 #include "core/dom/Fullscreen.h" | 10 #include "core/dom/Fullscreen.h" |
10 #include "core/dom/ScriptedAnimationController.h" | 11 #include "core/dom/ScriptedAnimationController.h" |
11 #include "core/frame/UseCounter.h" | 12 #include "core/frame/UseCounter.h" |
12 #include "core/inspector/ConsoleMessage.h" | 13 #include "core/inspector/ConsoleMessage.h" |
13 #include "gpu/command_buffer/client/gles2_interface.h" | 14 #include "gpu/command_buffer/client/gles2_interface.h" |
14 #include "modules/vr/NavigatorVR.h" | 15 #include "modules/vr/NavigatorVR.h" |
15 #include "modules/vr/VRController.h" | 16 #include "modules/vr/VRController.h" |
16 #include "modules/vr/VRDisplayCapabilities.h" | 17 #include "modules/vr/VRDisplayCapabilities.h" |
17 #include "modules/vr/VREyeParameters.h" | 18 #include "modules/vr/VREyeParameters.h" |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 m_layer.rightBounds().size() != 4)) { | 329 m_layer.rightBounds().size() != 4)) { |
329 forceExitPresent(); | 330 forceExitPresent(); |
330 DOMException* exception = DOMException::create( | 331 DOMException* exception = DOMException::create( |
331 InvalidStateError, | 332 InvalidStateError, |
332 "Layer bounds must either be an empty array or have 4 values"); | 333 "Layer bounds must either be an empty array or have 4 values"); |
333 resolver->reject(exception); | 334 resolver->reject(exception); |
334 ReportPresentationResult(PresentationResult::InvalidLayerBounds); | 335 ReportPresentationResult(PresentationResult::InvalidLayerBounds); |
335 return promise; | 336 return promise; |
336 } | 337 } |
337 | 338 |
338 if (!m_capabilities->hasExternalDisplay()) { | |
339 // TODO: Need a proper VR compositor, but for the moment on mobile | |
340 // we'll just make the canvas fullscreen so that VrShell can pick it | |
341 // up through the standard (high latency) compositing path. | |
342 Fullscreen::requestFullscreen(*m_layer.source(), | |
343 Fullscreen::UnprefixedRequest); | |
344 | |
345 // Check to see if the canvas is still the current fullscreen | |
346 // element once per second. | |
347 m_fullscreenCheckTimer.startRepeating(1.0, BLINK_FROM_HERE); | |
348 } | |
349 | |
350 if (firstPresent) { | 339 if (firstPresent) { |
351 bool secureContext = scriptState->getExecutionContext()->isSecureContext(); | 340 bool secureContext = scriptState->getExecutionContext()->isSecureContext(); |
352 if (!m_display) { | 341 if (!m_display) { |
353 forceExitPresent(); | 342 forceExitPresent(); |
354 DOMException* exception = DOMException::create( | 343 DOMException* exception = DOMException::create( |
355 InvalidStateError, "The service is no longer active."); | 344 InvalidStateError, "The service is no longer active."); |
356 resolver->reject(exception); | 345 resolver->reject(exception); |
357 return promise; | 346 return promise; |
358 } | 347 } |
359 m_display->RequestPresent( | 348 m_display->RequestPresent( |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 m_display->ExitPresent(); | 391 m_display->ExitPresent(); |
403 | 392 |
404 resolver->resolve(); | 393 resolver->resolve(); |
405 | 394 |
406 forceExitPresent(); | 395 forceExitPresent(); |
407 | 396 |
408 return promise; | 397 return promise; |
409 } | 398 } |
410 | 399 |
411 void VRDisplay::beginPresent(ScriptPromiseResolver* resolver) { | 400 void VRDisplay::beginPresent(ScriptPromiseResolver* resolver) { |
| 401 Document* doc = m_navigatorVR->document(); |
| 402 std::unique_ptr<UserGestureIndicator> gestureIndicator; |
412 if (m_capabilities->hasExternalDisplay()) { | 403 if (m_capabilities->hasExternalDisplay()) { |
413 forceExitPresent(); | 404 forceExitPresent(); |
414 DOMException* exception = DOMException::create( | 405 DOMException* exception = DOMException::create( |
415 InvalidStateError, | 406 InvalidStateError, |
416 "VR Presentation not implemented for this VRDisplay."); | 407 "VR Presentation not implemented for this VRDisplay."); |
417 resolver->reject(exception); | 408 resolver->reject(exception); |
418 ReportPresentationResult( | 409 ReportPresentationResult( |
419 PresentationResult::PresentationNotSupportedByDisplay); | 410 PresentationResult::PresentationNotSupportedByDisplay); |
420 return; | 411 return; |
| 412 } else { |
| 413 // TODO: Need a proper VR compositor, but for the moment on mobile |
| 414 // we'll just make the canvas fullscreen so that VrShell can pick it |
| 415 // up through the standard (high latency) compositing path. |
| 416 if (doc) { |
| 417 // Since the callback for requestPresent is asynchronous, we've lost our |
| 418 // UserGestureToken, and need to create a new one to enter fullscreen. |
| 419 gestureIndicator = |
| 420 wrapUnique(new UserGestureIndicator(DocumentUserGestureToken::create( |
| 421 doc, UserGestureToken::Status::PossiblyExistingGesture))); |
| 422 } |
| 423 Fullscreen::requestFullscreen(*m_layer.source(), |
| 424 Fullscreen::UnprefixedRequest); |
| 425 |
| 426 // Check to see if the canvas is still the current fullscreen |
| 427 // element once per second. |
| 428 m_fullscreenCheckTimer.startRepeating(1.0, BLINK_FROM_HERE); |
421 } | 429 } |
422 | 430 |
423 Document* doc = m_navigatorVR->document(); | |
424 if (doc) { | 431 if (doc) { |
425 Platform::current()->recordRapporURL("VR.WebVR.PresentSuccess", | 432 Platform::current()->recordRapporURL("VR.WebVR.PresentSuccess", |
426 WebURL(doc->url())); | 433 WebURL(doc->url())); |
427 } | 434 } |
428 | 435 |
429 m_isPresenting = true; | 436 m_isPresenting = true; |
430 ReportPresentationResult(PresentationResult::Success); | 437 ReportPresentationResult(PresentationResult::Success); |
431 | 438 |
432 updateLayerBounds(); | 439 updateLayerBounds(); |
433 | 440 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 visitor->trace(m_capabilities); | 635 visitor->trace(m_capabilities); |
629 visitor->trace(m_stageParameters); | 636 visitor->trace(m_stageParameters); |
630 visitor->trace(m_eyeParametersLeft); | 637 visitor->trace(m_eyeParametersLeft); |
631 visitor->trace(m_eyeParametersRight); | 638 visitor->trace(m_eyeParametersRight); |
632 visitor->trace(m_layer); | 639 visitor->trace(m_layer); |
633 visitor->trace(m_renderingContext); | 640 visitor->trace(m_renderingContext); |
634 visitor->trace(m_scriptedAnimationController); | 641 visitor->trace(m_scriptedAnimationController); |
635 } | 642 } |
636 | 643 |
637 } // namespace blink | 644 } // namespace blink |
OLD | NEW |