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" |
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 "mojo/public/cpp/bindings/binding.h" |
15 #include "platform/Timer.h" | 15 #include "platform/Timer.h" |
16 #include "platform/heap/Handle.h" | 16 #include "platform/heap/Handle.h" |
17 #include "platform/wtf/Forward.h" | 17 #include "platform/wtf/Forward.h" |
18 #include "platform/wtf/text/WTFString.h" | 18 #include "platform/wtf/text/WTFString.h" |
19 #include "public/platform/WebGraphicsContext3DProvider.h" | 19 #include "public/platform/WebGraphicsContext3DProvider.h" |
20 | 20 |
21 #include "core/dom/SuspendableObject.h" | |
22 | |
21 namespace gpu { | 23 namespace gpu { |
22 namespace gles2 { | 24 namespace gles2 { |
23 class GLES2Interface; | 25 class GLES2Interface; |
24 } | 26 } |
25 } | 27 } |
26 | 28 |
27 namespace blink { | 29 namespace blink { |
28 | 30 |
29 class NavigatorVR; | 31 class NavigatorVR; |
30 class ScriptedAnimationController; | 32 class ScriptedAnimationController; |
31 class VRController; | 33 class VRController; |
32 class VREyeParameters; | 34 class VREyeParameters; |
33 class VRFrameData; | 35 class VRFrameData; |
34 class VRStageParameters; | 36 class VRStageParameters; |
35 | 37 |
36 class WebGLRenderingContextBase; | 38 class WebGLRenderingContextBase; |
37 | 39 |
38 enum VREye { kVREyeNone, kVREyeLeft, kVREyeRight }; | 40 enum VREye { kVREyeNone, kVREyeLeft, kVREyeRight }; |
39 | 41 |
40 class VRDisplay final : public EventTargetWithInlineData, | 42 class VRDisplay final : public EventTargetWithInlineData, |
41 public ActiveScriptWrappable<VRDisplay>, | 43 public ActiveScriptWrappable<VRDisplay>, |
42 public ContextLifecycleObserver, | 44 public SuspendableObject, |
43 public device::mojom::blink::VRDisplayClient, | 45 public device::mojom::blink::VRDisplayClient, |
44 public device::mojom::blink::VRSubmitFrameClient { | 46 public device::mojom::blink::VRSubmitFrameClient { |
45 DEFINE_WRAPPERTYPEINFO(); | 47 DEFINE_WRAPPERTYPEINFO(); |
46 USING_GARBAGE_COLLECTED_MIXIN(VRDisplay); | 48 USING_GARBAGE_COLLECTED_MIXIN(VRDisplay); |
47 USING_PRE_FINALIZER(VRDisplay, Dispose); | 49 USING_PRE_FINALIZER(VRDisplay, Dispose); |
48 | 50 |
49 public: | 51 public: |
50 ~VRDisplay(); | 52 ~VRDisplay(); |
51 | 53 |
52 unsigned displayId() const { return display_id_; } | 54 unsigned displayId() const { return display_id_; } |
(...skipping 29 matching lines...) Expand all Loading... | |
82 // EventTarget overrides: | 84 // EventTarget overrides: |
83 ExecutionContext* GetExecutionContext() const override; | 85 ExecutionContext* GetExecutionContext() const override; |
84 const AtomicString& InterfaceName() const override; | 86 const AtomicString& InterfaceName() const override; |
85 | 87 |
86 // ContextLifecycleObserver implementation. | 88 // ContextLifecycleObserver implementation. |
87 void ContextDestroyed(ExecutionContext*) override; | 89 void ContextDestroyed(ExecutionContext*) override; |
88 | 90 |
89 // ScriptWrappable implementation. | 91 // ScriptWrappable implementation. |
90 bool HasPendingActivity() const final; | 92 bool HasPendingActivity() const final; |
91 | 93 |
94 // SuspendableObject: | |
95 void Suspend() override; | |
96 void Resume() override; | |
97 | |
92 void FocusChanged(); | 98 void FocusChanged(); |
93 | 99 |
94 DECLARE_VIRTUAL_TRACE(); | 100 DECLARE_VIRTUAL_TRACE(); |
95 | 101 |
96 protected: | 102 protected: |
97 friend class VRController; | 103 friend class VRController; |
98 | 104 |
99 VRDisplay(NavigatorVR*, | 105 VRDisplay(NavigatorVR*, |
100 device::mojom::blink::VRDisplayPtr, | 106 device::mojom::blink::VRDisplayPtr, |
101 device::mojom::blink::VRDisplayClientRequest); | 107 device::mojom::blink::VRDisplayClientRequest); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 bool pending_present_request_ = false; | 208 bool pending_present_request_ = false; |
203 | 209 |
204 device::mojom::blink::VRDisplayPtr display_; | 210 device::mojom::blink::VRDisplayPtr display_; |
205 | 211 |
206 mojo::Binding<device::mojom::blink::VRSubmitFrameClient> | 212 mojo::Binding<device::mojom::blink::VRSubmitFrameClient> |
207 submit_frame_client_binding_; | 213 submit_frame_client_binding_; |
208 mojo::Binding<device::mojom::blink::VRDisplayClient> display_client_binding_; | 214 mojo::Binding<device::mojom::blink::VRDisplayClient> display_client_binding_; |
209 device::mojom::blink::VRVSyncProviderPtr vr_v_sync_provider_; | 215 device::mojom::blink::VRVSyncProviderPtr vr_v_sync_provider_; |
210 | 216 |
211 HeapDeque<Member<ScriptPromiseResolver>> pending_present_resolvers_; | 217 HeapDeque<Member<ScriptPromiseResolver>> pending_present_resolvers_; |
218 | |
219 bool suspended_ = false; | |
haraken
2017/06/08 00:55:12
You can drop this flag and instead use executionCo
billorr
2017/06/08 04:20:21
Done.
| |
220 bool request_vsync_on_resume_ = false; | |
212 }; | 221 }; |
213 | 222 |
214 using VRDisplayVector = HeapVector<Member<VRDisplay>>; | 223 using VRDisplayVector = HeapVector<Member<VRDisplay>>; |
215 | 224 |
216 enum class PresentationResult { | 225 enum class PresentationResult { |
217 kRequested = 0, | 226 kRequested = 0, |
218 kSuccess = 1, | 227 kSuccess = 1, |
219 kSuccessAlreadyPresenting = 2, | 228 kSuccessAlreadyPresenting = 2, |
220 kVRDisplayCannotPresent = 3, | 229 kVRDisplayCannotPresent = 3, |
221 kPresentationNotSupportedByDisplay = 4, | 230 kPresentationNotSupportedByDisplay = 4, |
222 kVRDisplayNotFound = 5, | 231 kVRDisplayNotFound = 5, |
223 kNotInitiatedByUserGesture = 6, | 232 kNotInitiatedByUserGesture = 6, |
224 kInvalidNumberOfLayers = 7, | 233 kInvalidNumberOfLayers = 7, |
225 kInvalidLayerSource = 8, | 234 kInvalidLayerSource = 8, |
226 kLayerSourceMissingWebGLContext = 9, | 235 kLayerSourceMissingWebGLContext = 9, |
227 kInvalidLayerBounds = 10, | 236 kInvalidLayerBounds = 10, |
228 kServiceInactive = 11, | 237 kServiceInactive = 11, |
229 kRequestDenied = 12, | 238 kRequestDenied = 12, |
230 kFullscreenNotEnabled = 13, | 239 kFullscreenNotEnabled = 13, |
231 kPresentationResultMax, // Must be last member of enum. | 240 kPresentationResultMax, // Must be last member of enum. |
232 }; | 241 }; |
233 | 242 |
234 void ReportPresentationResult(PresentationResult); | 243 void ReportPresentationResult(PresentationResult); |
235 | 244 |
236 } // namespace blink | 245 } // namespace blink |
237 | 246 |
238 #endif // VRDisplay_h | 247 #endif // VRDisplay_h |
OLD | NEW |