Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(448)

Unified Diff: third_party/WebKit/Source/modules/vr/VRDisplay.cpp

Issue 2488273002: Revert of mojo VR interface simplified (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/vr/VRDisplay.cpp
diff --git a/third_party/WebKit/Source/modules/vr/VRDisplay.cpp b/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
index 0a7c745bccb97f49c4f4e7b84c101dfb1faaa588..1480df6785b9b4e392e0ccdfd209e937ac9dddc1 100644
--- a/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
+++ b/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
@@ -57,10 +57,9 @@
} // namespace
-VRDisplay::VRDisplay(NavigatorVR* navigatorVR,
- device::mojom::blink::VRDisplayPtr display,
- device::mojom::blink::VRDisplayClientRequest request)
+VRDisplay::VRDisplay(NavigatorVR* navigatorVR)
: m_navigatorVR(navigatorVR),
+ m_displayId(0),
m_isConnected(false),
m_isPresenting(false),
m_canUpdateFramePose(true),
@@ -71,11 +70,7 @@
m_depthFar(10000.0),
m_fullscreenCheckTimer(this, &VRDisplay::onFullscreenCheck),
m_animationCallbackRequested(false),
- m_inAnimationFrame(false),
- m_display(std::move(display)),
- m_binding(this, std::move(request)) {
- ThreadState::current()->registerPreFinalizer(this);
-}
+ m_inAnimationFrame(false) {}
VRDisplay::~VRDisplay() {}
@@ -83,7 +78,7 @@
return m_navigatorVR->controller();
}
-void VRDisplay::update(const device::mojom::blink::VRDisplayInfoPtr& display) {
+void VRDisplay::update(const device::blink::VRDisplayPtr& display) {
m_displayId = display->index;
m_displayName = display->displayName;
m_isConnected = true;
@@ -138,21 +133,14 @@
void VRDisplay::updatePose() {
if (m_canUpdateFramePose) {
- if (!m_display)
- return;
- device::mojom::blink::VRPosePtr pose;
- m_display->GetPose(&pose);
- m_framePose = std::move(pose);
+ m_framePose = controller()->getPose(m_displayId);
if (m_isPresenting)
m_canUpdateFramePose = false;
}
}
void VRDisplay::resetPose() {
- if (!m_display)
- return;
-
- m_display->ResetPose();
+ controller()->resetPose(m_displayId);
}
VREyeParameters* VRDisplay::getEyeParameters(const String& whichEye) {
@@ -311,16 +299,7 @@
if (firstPresent) {
bool secureContext = scriptState->getExecutionContext()->isSecureContext();
- if (!m_display) {
- DOMException* exception = DOMException::create(
- InvalidStateError, "The service is no longer active.");
- resolver->reject(exception);
- return promise;
- }
- m_display->RequestPresent(
- secureContext, convertToBaseCallback(WTF::bind(
- &VRDisplay::onPresentComplete, wrapPersistent(this),
- wrapPersistent(resolver))));
+ controller()->requestPresent(resolver, m_displayId, secureContext);
} else {
updateLayerBounds();
resolver->resolve();
@@ -330,18 +309,6 @@
return promise;
}
-void VRDisplay::onPresentComplete(ScriptPromiseResolver* resolver,
- bool success) {
- if (success) {
- this->beginPresent(resolver);
- } else {
- this->forceExitPresent();
- DOMException* exception = DOMException::create(
- NotAllowedError, "Presentation request was denied.");
- resolver->reject(exception);
- }
-}
-
ScriptPromise VRDisplay::exitPresent(ScriptState* scriptState) {
ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
ScriptPromise promise = resolver->promise();
@@ -354,13 +321,7 @@
return promise;
}
- if (!m_display) {
- DOMException* exception =
- DOMException::create(InvalidStateError, "VRService is not available.");
- resolver->reject(exception);
- return promise;
- }
- m_display->ExitPresent();
+ controller()->exitPresent(m_displayId);
resolver->resolve();
@@ -407,14 +368,11 @@
}
void VRDisplay::updateLayerBounds() {
- if (!m_display)
- return;
-
// Set up the texture bounds for the provided layer
- device::mojom::blink::VRLayerBoundsPtr leftBounds =
- device::mojom::blink::VRLayerBounds::New();
- device::mojom::blink::VRLayerBoundsPtr rightBounds =
- device::mojom::blink::VRLayerBounds::New();
+ device::blink::VRLayerBoundsPtr leftBounds =
+ device::blink::VRLayerBounds::New();
+ device::blink::VRLayerBoundsPtr rightBounds =
+ device::blink::VRLayerBounds::New();
if (m_layer.leftBounds().size() == 4) {
leftBounds->left = m_layer.leftBounds()[0];
@@ -442,7 +400,8 @@
rightBounds->height = 1.0f;
}
- m_display->UpdateLayerBounds(std::move(leftBounds), std::move(rightBounds));
+ controller()->updateLayerBounds(m_displayId, std::move(leftBounds),
+ std::move(rightBounds));
}
HeapVector<VRLayer> VRDisplay::getLayers() {
@@ -456,9 +415,6 @@
}
void VRDisplay::submitFrame() {
- if (!m_display)
- return;
-
Document* doc = m_navigatorVR->document();
if (!m_isPresenting) {
if (doc) {
@@ -512,27 +468,8 @@
m_renderingContext->restoreColorMask();
m_renderingContext->restoreClearColor();
- m_display->SubmitFrame(m_framePose.Clone());
+ controller()->submitFrame(m_displayId, m_framePose.Clone());
m_canUpdateFramePose = true;
-}
-
-void VRDisplay::OnDisplayChanged(
- device::mojom::blink::VRDisplayInfoPtr display) {
- update(display);
-}
-
-void VRDisplay::OnExitPresent() {
- forceExitPresent();
-}
-
-void VRDisplay::onDisplayConnected() {
- m_navigatorVR->fireVREvent(VRDisplayEvent::create(
- EventTypeNames::vrdisplayconnect, true, false, this, "connect"));
-}
-
-void VRDisplay::onDisplayDisconnected() {
- m_navigatorVR->fireVREvent(VRDisplayEvent::create(
- EventTypeNames::vrdisplaydisconnect, true, false, this, "disconnect"));
}
void VRDisplay::onFullscreenCheck(TimerBase*) {
@@ -545,9 +482,7 @@
m_isPresenting = false;
m_navigatorVR->fireVRDisplayPresentChange(this);
m_fullscreenCheckTimer.stop();
- if (!m_display)
- return;
- m_display->ExitPresent();
+ controller()->exitPresent(m_displayId);
}
}
@@ -557,10 +492,6 @@
m_scriptedAnimationController = ScriptedAnimationController::create(doc);
return *m_scriptedAnimationController;
-}
-
-void VRDisplay::dispose() {
- m_binding.Close();
}
DEFINE_TRACE(VRDisplay) {
« no previous file with comments | « third_party/WebKit/Source/modules/vr/VRDisplay.h ('k') | third_party/WebKit/Source/modules/vr/VREyeParameters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698