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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "modules/vr/VRPose.h" 5 #include "modules/vr/VRPose.h"
6 6
7 namespace blink { 7 namespace blink {
8 8
9 namespace { 9 namespace {
10 10
11 DOMFloat32Array* vecToFloat32Array(const mojom::blink::VRVector4Ptr& vec) 11 DOMFloat32Array* mojoArrayToFloat32Array(const mojo::WTFArray<float>& vec)
12 { 12 {
13 if (!vec.is_null()) { 13 if (vec.is_null())
14 DOMFloat32Array* out = DOMFloat32Array::create(4); 14 return nullptr;
15 out->data()[0] = vec->x;
16 out->data()[1] = vec->y;
17 out->data()[2] = vec->z;
18 out->data()[3] = vec->w;
19 return out;
20 }
21 return nullptr;
22 }
23 15
24 DOMFloat32Array* vecToFloat32Array(const mojom::blink::VRVector3Ptr& vec) 16 return DOMFloat32Array::create(&(vec.front()), vec.size());
25 {
26 if (!vec.is_null()) {
27 DOMFloat32Array* out = DOMFloat32Array::create(3);
28 out->data()[0] = vec->x;
29 out->data()[1] = vec->y;
30 out->data()[2] = vec->z;
31 return out;
32 }
33 return nullptr;
34 } 17 }
35 18
36 } // namespace 19 } // namespace
37 20
38 VRPose::VRPose() 21 VRPose::VRPose()
39 : m_timeStamp(0.0) 22 : m_timeStamp(0.0)
40 { 23 {
41 } 24 }
42 25
43 void VRPose::setPose(const mojom::blink::VRSensorStatePtr& state) 26 void VRPose::setPose(const mojom::blink::VRPosePtr& state)
44 { 27 {
45 if (state.is_null()) 28 if (state.is_null())
46 return; 29 return;
47 30
48 m_timeStamp = state->timestamp; 31 m_timeStamp = state->timestamp;
49 m_orientation = vecToFloat32Array(state->orientation); 32 m_orientation = mojoArrayToFloat32Array(state->orientation);
50 m_position = vecToFloat32Array(state->position); 33 m_position = mojoArrayToFloat32Array(state->position);
51 m_angularVelocity = vecToFloat32Array(state->angularVelocity); 34 m_angularVelocity = mojoArrayToFloat32Array(state->angularVelocity);
52 m_linearVelocity = vecToFloat32Array(state->linearVelocity); 35 m_linearVelocity = mojoArrayToFloat32Array(state->linearVelocity);
53 m_angularAcceleration = vecToFloat32Array(state->angularAcceleration); 36 m_angularAcceleration = mojoArrayToFloat32Array(state->angularAcceleration);
54 m_linearAcceleration = vecToFloat32Array(state->linearAcceleration); 37 m_linearAcceleration = mojoArrayToFloat32Array(state->linearAcceleration);
55 } 38 }
56 39
57 DEFINE_TRACE(VRPose) 40 DEFINE_TRACE(VRPose)
58 { 41 {
59 visitor->trace(m_orientation); 42 visitor->trace(m_orientation);
60 visitor->trace(m_position); 43 visitor->trace(m_position);
61 visitor->trace(m_angularVelocity); 44 visitor->trace(m_angularVelocity);
62 visitor->trace(m_linearVelocity); 45 visitor->trace(m_linearVelocity);
63 visitor->trace(m_angularAcceleration); 46 visitor->trace(m_angularAcceleration);
64 visitor->trace(m_linearAcceleration); 47 visitor->trace(m_linearAcceleration);
65 } 48 }
66 49
67 } // namespace blink 50 } // namespace blink
OLDNEW
« 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