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

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

Issue 1967633002: Updated VRService to match the latest Blink WebVR interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: And we're back to removing all the array size checks Created 4 years, 7 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: third_party/WebKit/Source/modules/vr/VRPose.cpp
diff --git a/third_party/WebKit/Source/modules/vr/VRPose.cpp b/third_party/WebKit/Source/modules/vr/VRPose.cpp
index 91d71199d57e6693a9f760f9def7fff139012aae..b68db6a001e4720008a4f7182b74c6ab13468ee2 100644
--- a/third_party/WebKit/Source/modules/vr/VRPose.cpp
+++ b/third_party/WebKit/Source/modules/vr/VRPose.cpp
@@ -8,29 +8,12 @@ namespace blink {
namespace {
-DOMFloat32Array* vecToFloat32Array(const mojom::blink::VRVector4Ptr& vec)
+DOMFloat32Array* mojoArrayToFloat32Array(const mojo::WTFArray<float>& vec)
{
- if (!vec.is_null()) {
- DOMFloat32Array* out = DOMFloat32Array::create(4);
- out->data()[0] = vec->x;
- out->data()[1] = vec->y;
- out->data()[2] = vec->z;
- out->data()[3] = vec->w;
- return out;
- }
- return nullptr;
-}
+ if (vec.is_null())
+ return nullptr;
-DOMFloat32Array* vecToFloat32Array(const mojom::blink::VRVector3Ptr& vec)
-{
- if (!vec.is_null()) {
- DOMFloat32Array* out = DOMFloat32Array::create(3);
- out->data()[0] = vec->x;
- out->data()[1] = vec->y;
- out->data()[2] = vec->z;
- return out;
- }
- return nullptr;
+ return DOMFloat32Array::create(&(vec.front()), vec.size());
}
} // namespace
@@ -40,18 +23,18 @@ VRPose::VRPose()
{
}
-void VRPose::setPose(const mojom::blink::VRSensorStatePtr& state)
+void VRPose::setPose(const mojom::blink::VRPosePtr& state)
{
if (state.is_null())
return;
m_timeStamp = state->timestamp;
- m_orientation = vecToFloat32Array(state->orientation);
- m_position = vecToFloat32Array(state->position);
- m_angularVelocity = vecToFloat32Array(state->angularVelocity);
- m_linearVelocity = vecToFloat32Array(state->linearVelocity);
- m_angularAcceleration = vecToFloat32Array(state->angularAcceleration);
- m_linearAcceleration = vecToFloat32Array(state->linearAcceleration);
+ m_orientation = mojoArrayToFloat32Array(state->orientation);
+ m_position = mojoArrayToFloat32Array(state->position);
+ m_angularVelocity = mojoArrayToFloat32Array(state->angularVelocity);
+ m_linearVelocity = mojoArrayToFloat32Array(state->linearVelocity);
+ m_angularAcceleration = mojoArrayToFloat32Array(state->angularAcceleration);
+ m_linearAcceleration = mojoArrayToFloat32Array(state->linearAcceleration);
}
DEFINE_TRACE(VRPose)
« no previous file with comments | « third_party/WebKit/Source/modules/vr/VRPose.h ('k') | third_party/WebKit/Source/modules/vr/VRStageParameters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698