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/css/StylePropertySet.h" | |
7 #include "core/dom/DOMException.h" | 8 #include "core/dom/DOMException.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" |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
329 "Layer bounds must either be an empty array or have 4 values"); | 330 "Layer bounds must either be an empty array or have 4 values"); |
330 resolver->reject(exception); | 331 resolver->reject(exception); |
331 ReportPresentationResult(PresentationResult::InvalidLayerBounds); | 332 ReportPresentationResult(PresentationResult::InvalidLayerBounds); |
332 return promise; | 333 return promise; |
333 } | 334 } |
334 | 335 |
335 if (!m_capabilities->hasExternalDisplay()) { | 336 if (!m_capabilities->hasExternalDisplay()) { |
336 // TODO: Need a proper VR compositor, but for the moment on mobile | 337 // TODO: Need a proper VR compositor, but for the moment on mobile |
337 // we'll just make the canvas fullscreen so that VrShell can pick it | 338 // we'll just make the canvas fullscreen so that VrShell can pick it |
338 // up through the standard (high latency) compositing path. | 339 // up through the standard (high latency) compositing path. |
339 Fullscreen::requestFullscreen(*m_layer.source(), | 340 auto canvas = m_layer.source(); |
340 Fullscreen::UnprefixedRequest); | 341 auto inlineStyle = canvas->inlineStyle(); |
342 if (inlineStyle) { | |
343 m_fullscreenOrigWidth = inlineStyle->getPropertyValue(CSSPropertyWidth); | |
mthiesse
2016/11/16 21:30:41
why are we changing CSS properties?
mthiesse
2016/11/16 21:31:35
Just saw your comment in the CL description. Put i
klausw
2016/11/16 23:37:39
Done, with a bit more detail:
// THREE.js's
| |
344 if (!m_fullscreenOrigWidth.isNull()) { | |
345 canvas->setInlineStyleProperty(CSSPropertyWidth, "100%"); | |
346 } | |
347 m_fullscreenOrigHeight = inlineStyle->getPropertyValue(CSSPropertyHeight); | |
348 if (!m_fullscreenOrigHeight.isNull()) { | |
349 canvas->setInlineStyleProperty(CSSPropertyHeight, "100%"); | |
350 } | |
351 } else { | |
352 m_fullscreenOrigWidth = String(); | |
353 m_fullscreenOrigHeight = String(); | |
354 } | |
355 Fullscreen::requestFullscreen(*canvas, Fullscreen::UnprefixedRequest); | |
341 | 356 |
342 // Check to see if the canvas is still the current fullscreen | 357 // Check to see if the canvas is still the current fullscreen |
343 // element once per second. | 358 // element once per second. |
344 m_fullscreenCheckTimer.startRepeating(1.0, BLINK_FROM_HERE); | 359 m_fullscreenCheckTimer.startRepeating(1.0, BLINK_FROM_HERE); |
345 } | 360 } |
346 | 361 |
347 if (firstPresent) { | 362 if (firstPresent) { |
348 bool secureContext = scriptState->getExecutionContext()->isSecureContext(); | 363 bool secureContext = scriptState->getExecutionContext()->isSecureContext(); |
349 if (!m_display) { | 364 if (!m_display) { |
350 forceExitPresent(); | 365 forceExitPresent(); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
428 | 443 |
429 updateLayerBounds(); | 444 updateLayerBounds(); |
430 | 445 |
431 resolver->resolve(); | 446 resolver->resolve(); |
432 m_navigatorVR->fireVRDisplayPresentChange(this); | 447 m_navigatorVR->fireVRDisplayPresentChange(this); |
433 } | 448 } |
434 | 449 |
435 void VRDisplay::forceExitPresent() { | 450 void VRDisplay::forceExitPresent() { |
436 if (m_isPresenting) { | 451 if (m_isPresenting) { |
437 if (!m_capabilities->hasExternalDisplay()) { | 452 if (!m_capabilities->hasExternalDisplay()) { |
438 Fullscreen::fullyExitFullscreen(m_layer.source()->document()); | 453 auto canvas = m_layer.source(); |
454 Fullscreen::fullyExitFullscreen(canvas->document()); | |
439 m_fullscreenCheckTimer.stop(); | 455 m_fullscreenCheckTimer.stop(); |
456 if (!m_fullscreenOrigWidth.isNull()) { | |
bajones
2016/11/16 21:23:52
This is all so hacky anyway I don't know how much
klausw
2016/11/16 23:37:39
I don't have strong feelings about this, but at th
| |
457 canvas->setInlineStyleProperty(CSSPropertyWidth, m_fullscreenOrigWidth); | |
458 m_fullscreenOrigWidth = String(); | |
459 } | |
460 if (!m_fullscreenOrigHeight.isNull()) { | |
461 canvas->setInlineStyleProperty(CSSPropertyWidth, | |
462 m_fullscreenOrigHeight); | |
463 m_fullscreenOrigHeight = String(); | |
464 } | |
440 } else { | 465 } else { |
441 // Can't get into this presentation mode, so nothing to do here. | 466 // Can't get into this presentation mode, so nothing to do here. |
442 } | 467 } |
443 m_navigatorVR->fireVRDisplayPresentChange(this); | 468 m_navigatorVR->fireVRDisplayPresentChange(this); |
444 } | 469 } |
445 | 470 |
446 m_isPresenting = false; | 471 m_isPresenting = false; |
447 m_renderingContext = nullptr; | 472 m_renderingContext = nullptr; |
448 m_contextGL = nullptr; | 473 m_contextGL = nullptr; |
449 } | 474 } |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
610 visitor->trace(m_capabilities); | 635 visitor->trace(m_capabilities); |
611 visitor->trace(m_stageParameters); | 636 visitor->trace(m_stageParameters); |
612 visitor->trace(m_eyeParametersLeft); | 637 visitor->trace(m_eyeParametersLeft); |
613 visitor->trace(m_eyeParametersRight); | 638 visitor->trace(m_eyeParametersRight); |
614 visitor->trace(m_layer); | 639 visitor->trace(m_layer); |
615 visitor->trace(m_renderingContext); | 640 visitor->trace(m_renderingContext); |
616 visitor->trace(m_scriptedAnimationController); | 641 visitor->trace(m_scriptedAnimationController); |
617 } | 642 } |
618 | 643 |
619 } // namespace blink | 644 } // namespace blink |
OLD | NEW |