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 "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "core/dom/FrameRequestCallback.h" | 9 #include "core/dom/FrameRequestCallback.h" |
10 #include "core/events/EventTarget.h" | 10 #include "core/events/EventTarget.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 class VRStageParameters; | 34 class VRStageParameters; |
35 class VRPose; | 35 class VRPose; |
36 | 36 |
37 class WebGLRenderingContextBase; | 37 class WebGLRenderingContextBase; |
38 | 38 |
39 enum VREye { VREyeNone, VREyeLeft, VREyeRight }; | 39 enum VREye { VREyeNone, VREyeLeft, VREyeRight }; |
40 | 40 |
41 class VRDisplay final : public EventTargetWithInlineData, | 41 class VRDisplay final : public EventTargetWithInlineData, |
42 public ActiveScriptWrappable<VRDisplay>, | 42 public ActiveScriptWrappable<VRDisplay>, |
43 public ContextLifecycleObserver, | 43 public ContextLifecycleObserver, |
44 public device::mojom::blink::VRDisplayClient { | 44 public device::mojom::blink::VRDisplayClient, |
| 45 public device::mojom::blink::VRSubmitFrameClient { |
45 DEFINE_WRAPPERTYPEINFO(); | 46 DEFINE_WRAPPERTYPEINFO(); |
46 USING_GARBAGE_COLLECTED_MIXIN(VRDisplay); | 47 USING_GARBAGE_COLLECTED_MIXIN(VRDisplay); |
47 USING_PRE_FINALIZER(VRDisplay, dispose); | 48 USING_PRE_FINALIZER(VRDisplay, dispose); |
48 | 49 |
49 public: | 50 public: |
50 ~VRDisplay(); | 51 ~VRDisplay(); |
51 | 52 |
52 unsigned displayId() const { return m_displayId; } | 53 unsigned displayId() const { return m_displayId; } |
53 const String& displayName() const { return m_displayName; } | 54 const String& displayName() const { return m_displayName; } |
54 | 55 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 110 |
110 void beginPresent(); | 111 void beginPresent(); |
111 void forceExitPresent(); | 112 void forceExitPresent(); |
112 | 113 |
113 void updateLayerBounds(); | 114 void updateLayerBounds(); |
114 void disconnected(); | 115 void disconnected(); |
115 | 116 |
116 VRController* controller(); | 117 VRController* controller(); |
117 | 118 |
118 private: | 119 private: |
119 void onFullscreenCheck(TimerBase*); | |
120 void onPresentComplete(bool); | 120 void onPresentComplete(bool); |
121 | 121 |
122 void onConnected(); | 122 void onConnected(); |
123 void onDisconnected(); | 123 void onDisconnected(); |
124 | 124 |
125 void stopPresenting(); | 125 void stopPresenting(); |
126 | 126 |
127 void OnPresentChange(); | 127 void OnPresentChange(); |
128 | 128 |
| 129 // VRSubmitFrameClient |
| 130 void OnSubmitFrameTransferred(); |
| 131 void OnSubmitFrameRendered(); |
| 132 |
129 // VRDisplayClient | 133 // VRDisplayClient |
130 void OnChanged(device::mojom::blink::VRDisplayInfoPtr) override; | 134 void OnChanged(device::mojom::blink::VRDisplayInfoPtr) override; |
131 void OnExitPresent() override; | 135 void OnExitPresent() override; |
132 void OnBlur() override; | 136 void OnBlur() override; |
133 void OnFocus() override; | 137 void OnFocus() override; |
134 void OnActivate(device::mojom::blink::VRDisplayEventReason) override; | 138 void OnActivate(device::mojom::blink::VRDisplayEventReason) override; |
135 void OnDeactivate(device::mojom::blink::VRDisplayEventReason) override; | 139 void OnDeactivate(device::mojom::blink::VRDisplayEventReason) override; |
136 | 140 |
137 void OnVSync(device::mojom::blink::VRPosePtr, | 141 void OnVSync(device::mojom::blink::VRPosePtr, |
138 mojo::common::mojom::blink::TimeDeltaPtr, | 142 mojo::common::mojom::blink::TimeDeltaPtr, |
139 int16_t frameId, | 143 int16_t frameId, |
140 device::mojom::blink::VRVSyncProvider::Status); | 144 device::mojom::blink::VRVSyncProvider::Status); |
141 void ConnectVSyncProvider(); | 145 void ConnectVSyncProvider(); |
| 146 void OnVSyncConnectionError(); |
142 | 147 |
143 ScriptedAnimationController& ensureScriptedAnimationController(Document*); | 148 ScriptedAnimationController& ensureScriptedAnimationController(Document*); |
144 | 149 |
145 Member<NavigatorVR> m_navigatorVR; | 150 Member<NavigatorVR> m_navigatorVR; |
146 unsigned m_displayId = 0; | 151 unsigned m_displayId = 0; |
147 String m_displayName; | 152 String m_displayName; |
148 bool m_isConnected = false; | 153 bool m_isConnected = false; |
149 bool m_isPresenting = false; | 154 bool m_isPresenting = false; |
150 bool m_isValidDeviceForPresenting = true; | 155 bool m_isValidDeviceForPresenting = true; |
151 Member<VRDisplayCapabilities> m_capabilities; | 156 Member<VRDisplayCapabilities> m_capabilities; |
152 Member<VRStageParameters> m_stageParameters; | 157 Member<VRStageParameters> m_stageParameters; |
153 Member<VREyeParameters> m_eyeParametersLeft; | 158 Member<VREyeParameters> m_eyeParametersLeft; |
154 Member<VREyeParameters> m_eyeParametersRight; | 159 Member<VREyeParameters> m_eyeParametersRight; |
155 device::mojom::blink::VRPosePtr m_framePose; | 160 device::mojom::blink::VRPosePtr m_framePose; |
156 | 161 |
157 // This frame ID is vr-specific and is used to track when frames arrive at the | 162 // This frame ID is vr-specific and is used to track when frames arrive at the |
158 // VR compositor so that it knows which poses to use, when to apply bounds | 163 // VR compositor so that it knows which poses to use, when to apply bounds |
159 // updates, etc. | 164 // updates, etc. |
160 int16_t m_vrFrameId = -1; | 165 int16_t m_vrFrameId = -1; |
161 VRLayer m_layer; | 166 VRLayer m_layer; |
162 double m_depthNear = 0.01; | 167 double m_depthNear = 0.01; |
163 double m_depthFar = 10000.0; | 168 double m_depthFar = 10000.0; |
164 | 169 |
| 170 // Current dimensions of the WebVR source canvas. May be different from |
| 171 // the recommended renderWidth/Height if the client overrides dimensions. |
| 172 int m_sourceWidth = 0; |
| 173 int m_sourceHeight = 0; |
| 174 |
165 void dispose(); | 175 void dispose(); |
166 | 176 |
167 TaskRunnerTimer<VRDisplay> m_fullscreenCheckTimer; | |
168 String m_fullscreenOrigWidth; | |
169 String m_fullscreenOrigHeight; | |
170 gpu::gles2::GLES2Interface* m_contextGL = nullptr; | 177 gpu::gles2::GLES2Interface* m_contextGL = nullptr; |
171 Member<WebGLRenderingContextBase> m_renderingContext; | 178 Member<WebGLRenderingContextBase> m_renderingContext; |
172 | 179 |
| 180 // Used to keep the image alive until the next frame if using |
| 181 // waitForPreviousTransferToFinish. |
| 182 RefPtr<Image> m_previousImage; |
| 183 |
173 Member<ScriptedAnimationController> m_scriptedAnimationController; | 184 Member<ScriptedAnimationController> m_scriptedAnimationController; |
174 bool m_pendingRaf = false; | 185 bool m_pendingRaf = false; |
175 bool m_pendingVsync = false; | 186 bool m_pendingVsync = false; |
176 bool m_inAnimationFrame = false; | 187 bool m_inAnimationFrame = false; |
177 bool m_displayBlurred = false; | 188 bool m_displayBlurred = false; |
178 bool m_reenteredFullscreen = false; | |
179 double m_timebase = -1; | 189 double m_timebase = -1; |
| 190 bool m_pendingPreviousFrameRender = false; |
| 191 bool m_pendingSubmitFrame = false; |
180 | 192 |
181 device::mojom::blink::VRDisplayPtr m_display; | 193 device::mojom::blink::VRDisplayPtr m_display; |
182 | 194 |
| 195 mojo::Binding<device::mojom::blink::VRSubmitFrameClient> |
| 196 m_submit_frame_client_binding; |
183 mojo::Binding<device::mojom::blink::VRDisplayClient> m_displayClientBinding; | 197 mojo::Binding<device::mojom::blink::VRDisplayClient> m_displayClientBinding; |
184 device::mojom::blink::VRVSyncProviderPtr m_vrVSyncProvider; | 198 device::mojom::blink::VRVSyncProviderPtr m_vrVSyncProvider; |
185 | 199 |
186 HeapDeque<Member<ScriptPromiseResolver>> m_pendingPresentResolvers; | 200 HeapDeque<Member<ScriptPromiseResolver>> m_pendingPresentResolvers; |
187 }; | 201 }; |
188 | 202 |
189 using VRDisplayVector = HeapVector<Member<VRDisplay>>; | 203 using VRDisplayVector = HeapVector<Member<VRDisplay>>; |
190 | 204 |
191 enum class PresentationResult { | 205 enum class PresentationResult { |
192 Requested = 0, | 206 Requested = 0, |
(...skipping 11 matching lines...) Expand all Loading... |
204 RequestDenied = 12, | 218 RequestDenied = 12, |
205 FullscreenNotEnabled = 13, | 219 FullscreenNotEnabled = 13, |
206 PresentationResultMax, // Must be last member of enum. | 220 PresentationResultMax, // Must be last member of enum. |
207 }; | 221 }; |
208 | 222 |
209 void ReportPresentationResult(PresentationResult); | 223 void ReportPresentationResult(PresentationResult); |
210 | 224 |
211 } // namespace blink | 225 } // namespace blink |
212 | 226 |
213 #endif // VRDisplay_h | 227 #endif // VRDisplay_h |
OLD | NEW |