| 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 #ifndef VRDisplay_h | 5 #ifndef VRDisplay_h |
| 6 #define VRDisplay_h | 6 #define VRDisplay_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptWrappable.h" | 8 #include "bindings/core/v8/ScriptWrappable.h" |
| 9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
| 10 #include "core/dom/FrameRequestCallback.h" | 10 #include "core/dom/FrameRequestCallback.h" |
| 11 #include "device/vr/vr_service.mojom-blink.h" | 11 #include "device/vr/vr_service.mojom-blink.h" |
| 12 #include "modules/vr/VRDisplayCapabilities.h" | 12 #include "modules/vr/VRDisplayCapabilities.h" |
| 13 #include "modules/vr/VRLayer.h" | 13 #include "modules/vr/VRLayer.h" |
| 14 #include "mojo/public/cpp/bindings/binding.h" | |
| 15 #include "platform/Timer.h" | 14 #include "platform/Timer.h" |
| 16 #include "platform/heap/Handle.h" | 15 #include "platform/heap/Handle.h" |
| 17 #include "public/platform/WebGraphicsContext3DProvider.h" | 16 #include "public/platform/WebGraphicsContext3DProvider.h" |
| 18 #include "wtf/Forward.h" | 17 #include "wtf/Forward.h" |
| 19 #include "wtf/text/WTFString.h" | 18 #include "wtf/text/WTFString.h" |
| 20 | 19 |
| 21 namespace gpu { | 20 namespace gpu { |
| 22 namespace gles2 { | 21 namespace gles2 { |
| 23 class GLES2Interface; | 22 class GLES2Interface; |
| 24 } | 23 } |
| 25 } | 24 } |
| 26 | 25 |
| 27 namespace blink { | 26 namespace blink { |
| 28 | 27 |
| 29 class NavigatorVR; | 28 class NavigatorVR; |
| 30 class ScriptedAnimationController; | 29 class ScriptedAnimationController; |
| 31 class VRController; | 30 class VRController; |
| 32 class VREyeParameters; | 31 class VREyeParameters; |
| 33 class VRFrameData; | 32 class VRFrameData; |
| 34 class VRStageParameters; | 33 class VRStageParameters; |
| 35 class VRPose; | 34 class VRPose; |
| 36 | 35 |
| 37 class WebGLRenderingContextBase; | 36 class WebGLRenderingContextBase; |
| 38 | 37 |
| 39 enum VREye { VREyeNone, VREyeLeft, VREyeRight }; | 38 enum VREye { VREyeNone, VREyeLeft, VREyeRight }; |
| 40 | 39 |
| 41 class VRDisplay final : public GarbageCollectedFinalized<VRDisplay>, | 40 class VRDisplay final : public GarbageCollectedFinalized<VRDisplay>, |
| 42 public device::mojom::blink::VRDisplayClient, | |
| 43 public ScriptWrappable { | 41 public ScriptWrappable { |
| 44 DEFINE_WRAPPERTYPEINFO(); | 42 DEFINE_WRAPPERTYPEINFO(); |
| 45 USING_PRE_FINALIZER(VRDisplay, dispose); | |
| 46 | 43 |
| 47 public: | 44 public: |
| 48 ~VRDisplay(); | 45 ~VRDisplay(); |
| 49 | 46 |
| 50 unsigned displayId() const { return m_displayId; } | 47 unsigned displayId() const { return m_displayId; } |
| 51 const String& displayName() const { return m_displayName; } | 48 const String& displayName() const { return m_displayName; } |
| 52 | 49 |
| 53 VRDisplayCapabilities* capabilities() const { return m_capabilities; } | 50 VRDisplayCapabilities* capabilities() const { return m_capabilities; } |
| 54 VRStageParameters* stageParameters() const { return m_stageParameters; } | 51 VRStageParameters* stageParameters() const { return m_stageParameters; } |
| 55 | 52 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 77 | 74 |
| 78 HeapVector<VRLayer> getLayers(); | 75 HeapVector<VRLayer> getLayers(); |
| 79 | 76 |
| 80 void submitFrame(); | 77 void submitFrame(); |
| 81 | 78 |
| 82 DECLARE_VIRTUAL_TRACE(); | 79 DECLARE_VIRTUAL_TRACE(); |
| 83 | 80 |
| 84 protected: | 81 protected: |
| 85 friend class VRController; | 82 friend class VRController; |
| 86 | 83 |
| 87 VRDisplay(NavigatorVR*, | 84 VRDisplay(NavigatorVR*); |
| 88 device::mojom::blink::VRDisplayPtr, | |
| 89 device::mojom::blink::VRDisplayClientRequest); | |
| 90 | 85 |
| 91 void update(const device::mojom::blink::VRDisplayInfoPtr&); | 86 void update(const device::blink::VRDisplayPtr&); |
| 92 | 87 |
| 93 void updatePose(); | 88 void updatePose(); |
| 94 | 89 |
| 95 void beginPresent(ScriptPromiseResolver*); | 90 void beginPresent(ScriptPromiseResolver*); |
| 96 void forceExitPresent(); | 91 void forceExitPresent(); |
| 97 | 92 |
| 98 void updateLayerBounds(); | 93 void updateLayerBounds(); |
| 99 void disconnected(); | 94 void disconnected(); |
| 100 | 95 |
| 101 VRController* controller(); | 96 VRController* controller(); |
| 102 | 97 |
| 103 private: | 98 private: |
| 104 void onFullscreenCheck(TimerBase*); | 99 void onFullscreenCheck(TimerBase*); |
| 105 void onPresentComplete(ScriptPromiseResolver*, bool); | |
| 106 | |
| 107 void onDisplayConnected(); | |
| 108 void onDisplayDisconnected(); | |
| 109 | |
| 110 // VRDisplayClient | |
| 111 void OnDisplayChanged(device::mojom::blink::VRDisplayInfoPtr) override; | |
| 112 void OnExitPresent() override; | |
| 113 | 100 |
| 114 ScriptedAnimationController& ensureScriptedAnimationController(Document*); | 101 ScriptedAnimationController& ensureScriptedAnimationController(Document*); |
| 115 | 102 |
| 116 Member<NavigatorVR> m_navigatorVR; | 103 Member<NavigatorVR> m_navigatorVR; |
| 117 unsigned m_displayId; | 104 unsigned m_displayId; |
| 118 String m_displayName; | 105 String m_displayName; |
| 119 bool m_isConnected; | 106 bool m_isConnected; |
| 120 bool m_isPresenting; | 107 bool m_isPresenting; |
| 121 bool m_canUpdateFramePose; | 108 bool m_canUpdateFramePose; |
| 122 unsigned m_compositorHandle; | 109 unsigned m_compositorHandle; |
| 123 Member<VRDisplayCapabilities> m_capabilities; | 110 Member<VRDisplayCapabilities> m_capabilities; |
| 124 Member<VRStageParameters> m_stageParameters; | 111 Member<VRStageParameters> m_stageParameters; |
| 125 Member<VREyeParameters> m_eyeParametersLeft; | 112 Member<VREyeParameters> m_eyeParametersLeft; |
| 126 Member<VREyeParameters> m_eyeParametersRight; | 113 Member<VREyeParameters> m_eyeParametersRight; |
| 127 device::mojom::blink::VRPosePtr m_framePose; | 114 device::blink::VRPosePtr m_framePose; |
| 128 VRLayer m_layer; | 115 VRLayer m_layer; |
| 129 double m_depthNear; | 116 double m_depthNear; |
| 130 double m_depthFar; | 117 double m_depthFar; |
| 131 | 118 |
| 132 void dispose(); | |
| 133 | |
| 134 Timer<VRDisplay> m_fullscreenCheckTimer; | 119 Timer<VRDisplay> m_fullscreenCheckTimer; |
| 135 gpu::gles2::GLES2Interface* m_contextGL; | 120 gpu::gles2::GLES2Interface* m_contextGL; |
| 136 Member<WebGLRenderingContextBase> m_renderingContext; | 121 Member<WebGLRenderingContextBase> m_renderingContext; |
| 137 | 122 |
| 138 Member<ScriptedAnimationController> m_scriptedAnimationController; | 123 Member<ScriptedAnimationController> m_scriptedAnimationController; |
| 139 bool m_animationCallbackRequested; | 124 bool m_animationCallbackRequested; |
| 140 bool m_inAnimationFrame; | 125 bool m_inAnimationFrame; |
| 141 | |
| 142 device::mojom::blink::VRDisplayPtr m_display; | |
| 143 | |
| 144 mojo::Binding<device::mojom::blink::VRDisplayClient> m_binding; | |
| 145 }; | 126 }; |
| 146 | 127 |
| 147 using VRDisplayVector = HeapVector<Member<VRDisplay>>; | 128 using VRDisplayVector = HeapVector<Member<VRDisplay>>; |
| 148 | 129 |
| 149 enum class PresentationResult { | 130 enum class PresentationResult { |
| 150 Requested = 0, | 131 Requested = 0, |
| 151 Success = 1, | 132 Success = 1, |
| 152 SuccessAlreadyPresenting = 2, | 133 SuccessAlreadyPresenting = 2, |
| 153 VRDisplayCannotPresent = 3, | 134 VRDisplayCannotPresent = 3, |
| 154 PresentationNotSupportedByDisplay = 4, | 135 PresentationNotSupportedByDisplay = 4, |
| 155 VRDisplayNotFound = 5, | 136 VRDisplayNotFound = 5, |
| 156 NotInitiatedByUserGesture = 6, | 137 NotInitiatedByUserGesture = 6, |
| 157 InvalidNumberOfLayers = 7, | 138 InvalidNumberOfLayers = 7, |
| 158 InvalidLayerSource = 8, | 139 InvalidLayerSource = 8, |
| 159 LayerSourceMissingWebGLContext = 9, | 140 LayerSourceMissingWebGLContext = 9, |
| 160 InvalidLayerBounds = 10, | 141 InvalidLayerBounds = 10, |
| 161 ServiceInactive = 11, | 142 ServiceInactive = 11, |
| 162 RequestDenied = 12, | 143 RequestDenied = 12, |
| 163 PresentationResultMax, // Must be last member of enum. | 144 PresentationResultMax, // Must be last member of enum. |
| 164 }; | 145 }; |
| 165 | 146 |
| 166 void ReportPresentationResult(PresentationResult); | 147 void ReportPresentationResult(PresentationResult); |
| 167 | 148 |
| 168 } // namespace blink | 149 } // namespace blink |
| 169 | 150 |
| 170 #endif // VRDisplay_h | 151 #endif // VRDisplay_h |
| OLD | NEW |