| 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 16 matching lines...) Expand all Loading... |
| 155 device::mojom::blink::VRPosePtr m_framePose; | 159 device::mojom::blink::VRPosePtr m_framePose; |
| 156 | 160 |
| 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 |
| 169 // Current dimensions of the WebVR source canvas. May be different from |
| 170 // the recommended renderWidth/Height if the client overrides dimensions. |
| 171 int m_sourceWidth = 0; |
| 172 int m_sourceHeight = 0; |
| 173 |
| 165 void dispose(); | 174 void dispose(); |
| 166 | 175 |
| 167 TaskRunnerTimer<VRDisplay> m_fullscreenCheckTimer; | |
| 168 String m_fullscreenOrigWidth; | |
| 169 String m_fullscreenOrigHeight; | |
| 170 gpu::gles2::GLES2Interface* m_contextGL = nullptr; | 176 gpu::gles2::GLES2Interface* m_contextGL = nullptr; |
| 171 Member<WebGLRenderingContextBase> m_renderingContext; | 177 Member<WebGLRenderingContextBase> m_renderingContext; |
| 172 | 178 |
| 179 // Used to keep the image alive until the next frame if using |
| 180 // waitForPreviousTransferToFinish. |
| 181 RefPtr<Image> m_previousImage; |
| 182 |
| 173 Member<ScriptedAnimationController> m_scriptedAnimationController; | 183 Member<ScriptedAnimationController> m_scriptedAnimationController; |
| 174 bool m_pendingRaf = false; | 184 bool m_pendingRaf = false; |
| 175 bool m_pendingVsync = false; | 185 bool m_pendingVsync = false; |
| 176 bool m_inAnimationFrame = false; | 186 bool m_inAnimationFrame = false; |
| 177 bool m_displayBlurred = false; | 187 bool m_displayBlurred = false; |
| 178 bool m_reenteredFullscreen = false; | |
| 179 double m_timebase = -1; | 188 double m_timebase = -1; |
| 189 bool m_pendingPreviousFrameRender = false; |
| 190 bool m_pendingSubmitFrame = false; |
| 180 | 191 |
| 181 device::mojom::blink::VRDisplayPtr m_display; | 192 device::mojom::blink::VRDisplayPtr m_display; |
| 182 | 193 |
| 194 mojo::Binding<device::mojom::blink::VRSubmitFrameClient> |
| 195 m_submit_frame_client_binding; |
| 183 mojo::Binding<device::mojom::blink::VRDisplayClient> m_displayClientBinding; | 196 mojo::Binding<device::mojom::blink::VRDisplayClient> m_displayClientBinding; |
| 184 device::mojom::blink::VRVSyncProviderPtr m_vrVSyncProvider; | 197 device::mojom::blink::VRVSyncProviderPtr m_vrVSyncProvider; |
| 185 | 198 |
| 186 HeapDeque<Member<ScriptPromiseResolver>> m_pendingPresentResolvers; | 199 HeapDeque<Member<ScriptPromiseResolver>> m_pendingPresentResolvers; |
| 187 }; | 200 }; |
| 188 | 201 |
| 189 using VRDisplayVector = HeapVector<Member<VRDisplay>>; | 202 using VRDisplayVector = HeapVector<Member<VRDisplay>>; |
| 190 | 203 |
| 191 enum class PresentationResult { | 204 enum class PresentationResult { |
| 192 Requested = 0, | 205 Requested = 0, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 204 RequestDenied = 12, | 217 RequestDenied = 12, |
| 205 FullscreenNotEnabled = 13, | 218 FullscreenNotEnabled = 13, |
| 206 PresentationResultMax, // Must be last member of enum. | 219 PresentationResultMax, // Must be last member of enum. |
| 207 }; | 220 }; |
| 208 | 221 |
| 209 void ReportPresentationResult(PresentationResult); | 222 void ReportPresentationResult(PresentationResult); |
| 210 | 223 |
| 211 } // namespace blink | 224 } // namespace blink |
| 212 | 225 |
| 213 #endif // VRDisplay_h | 226 #endif // VRDisplay_h |
| OLD | NEW |