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

Unified Diff: Source/modules/vr/VRPositionState.cpp

Issue 848053002: Adding WebVR interface to Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed compiler warning treated as an error on Windows Created 5 years, 9 months 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: Source/modules/vr/VRPositionState.cpp
diff --git a/Source/modules/vr/VRPositionState.cpp b/Source/modules/vr/VRPositionState.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..47a9869d6e02b472f77275b3f7d7cf9cdc86b248
--- /dev/null
+++ b/Source/modules/vr/VRPositionState.cpp
@@ -0,0 +1,53 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "modules/vr/VRPositionState.h"
+
+namespace blink {
+
+namespace {
+
+DOMPoint* VecToDomPoint(const blink::WebVRVector4& vec, bool valid)
esprehn 2015/06/22 22:05:27 lowerCaseNames.
+{
+ if (valid)
+ return DOMPoint::create(vec.x, vec.y, vec.z, vec.w);
+ return nullptr;
+}
+DOMPoint* VecToDomPoint(const blink::WebVRVector3& vec, bool valid)
esprehn 2015/06/22 22:05:27 ditto
+{
+ if (valid)
+ return DOMPoint::create(vec.x, vec.y, vec.z, 0.0);
+ return nullptr;
+}
+
+} // namespace
+
+VRPositionState::VRPositionState()
+ : m_timeStamp(0.0)
+{
+}
+
+void VRPositionState::setState(const blink::WebHMDSensorState &state)
+{
+ m_timeStamp = state.timestamp;
+ m_orientation = VecToDomPoint(state.orientation, state.flags & WebVRSensorStateOrientation);
+ m_position = VecToDomPoint(state.position, state.flags & WebVRSensorStatePosition);
+ m_angularVelocity = VecToDomPoint(state.angularVelocity, state.flags & WebVRSensorStateAngularVelocity);
+ m_linearVelocity = VecToDomPoint(state.linearVelocity, state.flags & WebVRSensorStateLinearVelocity);
+ m_angularAcceleration = VecToDomPoint(state.angularAcceleration, state.flags & WebVRSensorStateAngularAcceleration);
+ m_linearAcceleration = VecToDomPoint(state.linearAcceleration, state.flags & WebVRSensorStateLinearAcceleration);
+}
+
+void VRPositionState::trace(Visitor* visitor)
+{
+ visitor->trace(m_orientation);
+ visitor->trace(m_position);
+ visitor->trace(m_angularVelocity);
+ visitor->trace(m_linearVelocity);
+ visitor->trace(m_angularAcceleration);
+ visitor->trace(m_linearAcceleration);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698