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