| 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/css/StylePropertySet.h" |
| 8 #include "core/dom/DOMException.h" | 8 #include "core/dom/DOMException.h" |
| 9 #include "core/dom/DocumentUserGestureToken.h" | 9 #include "core/dom/DocumentUserGestureToken.h" |
| 10 #include "core/dom/FrameRequestCallback.h" | 10 #include "core/dom/FrameRequestCallback.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "modules/vr/VRFrameData.h" | 21 #include "modules/vr/VRFrameData.h" |
| 22 #include "modules/vr/VRLayer.h" | 22 #include "modules/vr/VRLayer.h" |
| 23 #include "modules/vr/VRPose.h" | 23 #include "modules/vr/VRPose.h" |
| 24 #include "modules/vr/VRStageParameters.h" | 24 #include "modules/vr/VRStageParameters.h" |
| 25 #include "modules/webgl/WebGLRenderingContextBase.h" | 25 #include "modules/webgl/WebGLRenderingContextBase.h" |
| 26 #include "platform/Histogram.h" | 26 #include "platform/Histogram.h" |
| 27 #include "platform/UserGestureIndicator.h" | 27 #include "platform/UserGestureIndicator.h" |
| 28 #include "public/platform/Platform.h" | 28 #include "public/platform/Platform.h" |
| 29 #include "wtf/AutoReset.h" | 29 #include "wtf/AutoReset.h" |
| 30 | 30 |
| 31 #include <array> |
| 32 |
| 31 namespace blink { | 33 namespace blink { |
| 32 | 34 |
| 33 namespace { | 35 namespace { |
| 34 | 36 |
| 37 // Magic numbers used to mark valid pose index values encoded in frame |
| 38 // data. Must match the magic numbers used in vr_shell.cc. |
| 39 static constexpr std::array<uint8_t, 2> kWebVrPosePixelMagicNumbers{{42, 142}}; |
| 40 |
| 35 VREye stringToVREye(const String& whichEye) { | 41 VREye stringToVREye(const String& whichEye) { |
| 36 if (whichEye == "left") | 42 if (whichEye == "left") |
| 37 return VREyeLeft; | 43 return VREyeLeft; |
| 38 if (whichEye == "right") | 44 if (whichEye == "right") |
| 39 return VREyeRight; | 45 return VREyeRight; |
| 40 return VREyeNone; | 46 return VREyeNone; |
| 41 } | 47 } |
| 42 | 48 |
| 43 class VRDisplayFrameRequestCallback : public FrameRequestCallback { | 49 class VRDisplayFrameRequestCallback : public FrameRequestCallback { |
| 44 public: | 50 public: |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 | 611 |
| 606 gl->Enable(GL_SCISSOR_TEST); | 612 gl->Enable(GL_SCISSOR_TEST); |
| 607 // Use a few pixels to ensure we get a clean color. The resolution for the | 613 // Use a few pixels to ensure we get a clean color. The resolution for the |
| 608 // WebGL buffer may not match the final rendered destination size, and | 614 // WebGL buffer may not match the final rendered destination size, and |
| 609 // texture filtering could interfere for single pixels. This isn't visible | 615 // texture filtering could interfere for single pixels. This isn't visible |
| 610 // since the final rendering hides the edges via a vignette effect. | 616 // since the final rendering hides the edges via a vignette effect. |
| 611 gl->Scissor(0, 0, 4, 4); | 617 gl->Scissor(0, 0, 4, 4); |
| 612 gl->ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | 618 gl->ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
| 613 int idx = m_framePose->poseIndex; | 619 int idx = m_framePose->poseIndex; |
| 614 // Careful with the arithmetic here. Float color 1.f is equivalent to int 255. | 620 // Careful with the arithmetic here. Float color 1.f is equivalent to int 255. |
| 615 gl->ClearColor((idx & 255) / 255.0f, ((idx >> 8) & 255) / 255.0f, | 621 // Use the low byte of the index as the red component, and store an arbitrary |
| 616 ((idx >> 16) & 255) / 255.0f, 1.0f); | 622 // magic number in green/blue. This number must match the reading code in |
| 623 // vr_shell.cc. Avoid all-black/all-white. |
| 624 gl->ClearColor((idx & 255) / 255.0f, kWebVrPosePixelMagicNumbers[0] / 255.0f, |
| 625 kWebVrPosePixelMagicNumbers[1] / 255.0f, 1.0f); |
| 617 gl->Clear(GL_COLOR_BUFFER_BIT); | 626 gl->Clear(GL_COLOR_BUFFER_BIT); |
| 618 | 627 |
| 619 // Set the GL state back to what was set by the WebVR application. | 628 // Set the GL state back to what was set by the WebVR application. |
| 620 m_renderingContext->restoreScissorEnabled(); | 629 m_renderingContext->restoreScissorEnabled(); |
| 621 m_renderingContext->restoreScissorBox(); | 630 m_renderingContext->restoreScissorBox(); |
| 622 m_renderingContext->restoreColorMask(); | 631 m_renderingContext->restoreColorMask(); |
| 623 m_renderingContext->restoreClearColor(); | 632 m_renderingContext->restoreClearColor(); |
| 624 | 633 |
| 625 m_display->SubmitFrame(m_framePose.Clone()); | 634 m_display->SubmitFrame(m_framePose.Clone()); |
| 626 m_canUpdateFramePose = true; | 635 m_canUpdateFramePose = true; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 visitor->trace(m_capabilities); | 710 visitor->trace(m_capabilities); |
| 702 visitor->trace(m_stageParameters); | 711 visitor->trace(m_stageParameters); |
| 703 visitor->trace(m_eyeParametersLeft); | 712 visitor->trace(m_eyeParametersLeft); |
| 704 visitor->trace(m_eyeParametersRight); | 713 visitor->trace(m_eyeParametersRight); |
| 705 visitor->trace(m_layer); | 714 visitor->trace(m_layer); |
| 706 visitor->trace(m_renderingContext); | 715 visitor->trace(m_renderingContext); |
| 707 visitor->trace(m_scriptedAnimationController); | 716 visitor->trace(m_scriptedAnimationController); |
| 708 } | 717 } |
| 709 | 718 |
| 710 } // namespace blink | 719 } // namespace blink |
| OLD | NEW |