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, |
(...skipping 18 matching lines...) Expand all Loading... |
157 // This frame ID is vr-specific and is used to track when frames arrive at the | 161 // 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 | 162 // VR compositor so that it knows which poses to use, when to apply bounds |
159 // updates, etc. | 163 // updates, etc. |
160 int16_t m_vrFrameId = -1; | 164 int16_t m_vrFrameId = -1; |
161 VRLayer m_layer; | 165 VRLayer m_layer; |
162 double m_depthNear = 0.01; | 166 double m_depthNear = 0.01; |
163 double m_depthFar = 10000.0; | 167 double m_depthFar = 10000.0; |
164 | 168 |
165 void dispose(); | 169 void dispose(); |
166 | 170 |
167 TaskRunnerTimer<VRDisplay> m_fullscreenCheckTimer; | |
168 String m_fullscreenOrigWidth; | |
169 String m_fullscreenOrigHeight; | |
170 gpu::gles2::GLES2Interface* m_contextGL = nullptr; | 171 gpu::gles2::GLES2Interface* m_contextGL = nullptr; |
171 Member<WebGLRenderingContextBase> m_renderingContext; | 172 Member<WebGLRenderingContextBase> m_renderingContext; |
172 | 173 |
173 Member<ScriptedAnimationController> m_scriptedAnimationController; | 174 Member<ScriptedAnimationController> m_scriptedAnimationController; |
174 bool m_pendingRaf = false; | 175 bool m_pendingRaf = false; |
175 bool m_pendingVsync = false; | 176 bool m_pendingVsync = false; |
176 bool m_inAnimationFrame = false; | 177 bool m_inAnimationFrame = false; |
177 bool m_displayBlurred = false; | 178 bool m_displayBlurred = false; |
178 bool m_reenteredFullscreen = false; | |
179 double m_timebase = -1; | 179 double m_timebase = -1; |
| 180 bool m_pendingPreviousFrameRender = false; |
| 181 bool m_pendingSubmitFrame = false; |
180 | 182 |
181 device::mojom::blink::VRDisplayPtr m_display; | 183 device::mojom::blink::VRDisplayPtr m_display; |
182 | 184 |
| 185 mojo::Binding<device::mojom::blink::VRSubmitFrameClient> |
| 186 m_submit_frame_client_binding; |
183 mojo::Binding<device::mojom::blink::VRDisplayClient> m_displayClientBinding; | 187 mojo::Binding<device::mojom::blink::VRDisplayClient> m_displayClientBinding; |
184 device::mojom::blink::VRVSyncProviderPtr m_vrVSyncProvider; | 188 device::mojom::blink::VRVSyncProviderPtr m_vrVSyncProvider; |
185 | 189 |
186 HeapDeque<Member<ScriptPromiseResolver>> m_pendingPresentResolvers; | 190 HeapDeque<Member<ScriptPromiseResolver>> m_pendingPresentResolvers; |
187 }; | 191 }; |
188 | 192 |
189 using VRDisplayVector = HeapVector<Member<VRDisplay>>; | 193 using VRDisplayVector = HeapVector<Member<VRDisplay>>; |
190 | 194 |
191 enum class PresentationResult { | 195 enum class PresentationResult { |
192 Requested = 0, | 196 Requested = 0, |
(...skipping 11 matching lines...) Expand all Loading... |
204 RequestDenied = 12, | 208 RequestDenied = 12, |
205 FullscreenNotEnabled = 13, | 209 FullscreenNotEnabled = 13, |
206 PresentationResultMax, // Must be last member of enum. | 210 PresentationResultMax, // Must be last member of enum. |
207 }; | 211 }; |
208 | 212 |
209 void ReportPresentationResult(PresentationResult); | 213 void ReportPresentationResult(PresentationResult); |
210 | 214 |
211 } // namespace blink | 215 } // namespace blink |
212 | 216 |
213 #endif // VRDisplay_h | 217 #endif // VRDisplay_h |
OLD | NEW |