Index: third_party/WebKit/Source/modules/vr/VRDisplay.h |
diff --git a/third_party/WebKit/Source/modules/vr/VRDisplay.h b/third_party/WebKit/Source/modules/vr/VRDisplay.h |
index 4927e6190e2b0ea2a6d756562d7cd094d803e1cc..82fb7a2d5938297b43156eab3ef51fc2282550a5 100644 |
--- a/third_party/WebKit/Source/modules/vr/VRDisplay.h |
+++ b/third_party/WebKit/Source/modules/vr/VRDisplay.h |
@@ -12,7 +12,6 @@ |
#include "modules/vr/VRDisplayCapabilities.h" |
#include "modules/vr/VRLayer.h" |
#include "mojo/public/cpp/bindings/binding.h" |
-#include "platform/Timer.h" |
#include "platform/heap/Handle.h" |
#include "public/platform/WebGraphicsContext3DProvider.h" |
#include "wtf/Forward.h" |
@@ -38,10 +37,24 @@ class WebGLRenderingContextBase; |
enum VREye { VREyeNone, VREyeLeft, VREyeRight }; |
+class StatTracker final { |
+ public: |
+ StatTracker(unsigned int capacity); |
+ ~StatTracker(); |
+ bool hasPrediction(); |
+ double getPrediction(); |
+ void add(double value); |
+ void clear(); |
+ private: |
+ unsigned int m_capacity; |
+ std::list<double> m_items; |
+}; |
+ |
class VRDisplay final : public EventTargetWithInlineData, |
public ActiveScriptWrappable<VRDisplay>, |
public ContextLifecycleObserver, |
- public device::mojom::blink::VRDisplayClient { |
+ public device::mojom::blink::VRDisplayClient, |
+ public NON_EXPORTED_BASE(device::mojom::blink::VRPoseClient) { |
DEFINE_WRAPPERTYPEINFO(); |
USING_GARBAGE_COLLECTED_MIXIN(VRDisplay); |
USING_PRE_FINALIZER(VRDisplay, dispose); |
@@ -72,7 +85,9 @@ class VRDisplay final : public EventTargetWithInlineData, |
int requestAnimationFrame(FrameRequestCallback*); |
void cancelAnimationFrame(int id); |
- void serviceScriptedAnimations(double monotonicAnimationStartTime); |
+ void frameTick(double highResTimeMs); |
+ void serviceScriptedAnimations(); |
+ void rescheduleAtNextTick(); |
ScriptPromise requestPresent(ScriptState*, const HeapVector<VRLayer>& layers); |
ScriptPromise exitPresent(ScriptState*); |
@@ -112,17 +127,28 @@ class VRDisplay final : public EventTargetWithInlineData, |
void updateLayerBounds(); |
void disconnected(); |
+ gpu::gles2::GLES2Interface* getCompositingContext(); |
+ |
VRController* controller(); |
private: |
- void onFullscreenCheck(TimerBase*); |
+ void submitFrameAnyContext(); |
+ |
void onPresentComplete(bool); |
+ void onSubmitFrameComplete(int32_t surfaceHandle, uint32_t poseIndex, double renderMs); |
+ void onGetSurfaceHandleComplete(int32_t surfaceHandle); |
+ |
+ void requestPose(); |
+ void onPoseReceived(device::mojom::blink::VRPosePtr); |
void onConnected(); |
void onDisconnected(); |
void OnPresentChange(); |
+ // VRPoseClient |
+ void OnPoseReceived(device::mojom::blink::VRPosePtr pose) override; |
+ |
// VRDisplayClient |
void OnChanged(device::mojom::blink::VRDisplayInfoPtr) override; |
void OnExitPresent() override; |
@@ -139,21 +165,41 @@ class VRDisplay final : public EventTargetWithInlineData, |
bool m_isConnected; |
bool m_isPresenting; |
bool m_isValidDeviceForPresenting; |
+ |
+ double m_highResTimeMsAtLastFrameTick; |
+ double m_frameTickStartMs; |
+ double m_serviceStartMs; |
+ double m_submitExecuteMs; |
+ bool m_tickIsScheduled = false; |
+ |
+ // Track "pending submitted frames" counter for the current output |
+ // surface. Always zero while not submitting frames. Must only be |
+ // changed when submitting frames to a valid surface and on its |
+ // return callback if it still matches the current surface. We allow |
+ // rAF processing to start if one frame is pending in post-submit, |
+ // but if it's still nonzero when trying to submit a frame we defer |
+ // that until the previous in-flight frame is done. |
+ int m_framesPending; |
+ bool m_frameWaitingToSubmit = false; |
+ StatTracker m_historyPreSubmitTimeMs{7}; |
+ StatTracker m_historyPostSubmitTimeMs{7}; |
+ |
+ bool m_poseCallbackPending = false; |
bool m_canUpdateFramePose; |
+ bool m_canSubmitFramePose; |
Member<VRDisplayCapabilities> m_capabilities; |
Member<VRStageParameters> m_stageParameters; |
Member<VREyeParameters> m_eyeParametersLeft; |
Member<VREyeParameters> m_eyeParametersRight; |
device::mojom::blink::VRPosePtr m_framePose; |
VRLayer m_layer; |
+ int m_sourceWidth; |
+ int m_sourceHeight; |
double m_depthNear; |
double m_depthFar; |
void dispose(); |
- Timer<VRDisplay> m_fullscreenCheckTimer; |
- String m_fullscreenOrigWidth; |
- String m_fullscreenOrigHeight; |
gpu::gles2::GLES2Interface* m_contextGL; |
Member<WebGLRenderingContextBase> m_renderingContext; |
@@ -163,11 +209,17 @@ class VRDisplay final : public EventTargetWithInlineData, |
bool m_displayBlurred; |
bool m_reenteredFullscreen; |
+ int32_t m_surfaceHandle; |
+ bool m_surfaceHandleRequested = false; |
+ |
device::mojom::blink::VRDisplayPtr m_display; |
mojo::Binding<device::mojom::blink::VRDisplayClient> m_binding; |
+ mojo::Binding<device::mojom::blink::VRPoseClient> m_pose_client_binding; |
HeapDeque<Member<ScriptPromiseResolver>> m_pendingPresentResolvers; |
+ |
+ std::unique_ptr<WebGraphicsContext3DProvider> m_contextProvider; |
}; |
using VRDisplayVector = HeapVector<Member<VRDisplay>>; |