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

Side by Side Diff: third_party/WebKit/Source/modules/vr/VRPose.cpp

Issue 2494983003: Mojo C++ bindings: switch device/vr mojom target to use STL/WTF types. (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 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* mojoArrayToFloat32Array(const mojo::WTFArray<float>& vec) { 11 DOMFloat32Array* mojoArrayToFloat32Array(
12 if (vec.is_null()) 12 const WTF::Optional<WTF::Vector<float>>& vec) {
13 if (!vec)
13 return nullptr; 14 return nullptr;
14 15
15 return DOMFloat32Array::create(&(vec.front()), vec.size()); 16 return DOMFloat32Array::create(&(vec.value().first()), vec.value().size());
16 } 17 }
17 18
18 } // namespace 19 } // namespace
19 20
20 VRPose::VRPose() {} 21 VRPose::VRPose() {}
21 22
22 void VRPose::setPose(const device::mojom::blink::VRPosePtr& state) { 23 void VRPose::setPose(const device::mojom::blink::VRPosePtr& state) {
23 if (state.is_null()) 24 if (state.is_null())
24 return; 25 return;
25 26
26 m_orientation = mojoArrayToFloat32Array(state->orientation); 27 m_orientation = mojoArrayToFloat32Array(state->orientation);
27 m_position = mojoArrayToFloat32Array(state->position); 28 m_position = mojoArrayToFloat32Array(state->position);
28 m_angularVelocity = mojoArrayToFloat32Array(state->angularVelocity); 29 m_angularVelocity = mojoArrayToFloat32Array(state->angularVelocity);
29 m_linearVelocity = mojoArrayToFloat32Array(state->linearVelocity); 30 m_linearVelocity = mojoArrayToFloat32Array(state->linearVelocity);
30 m_angularAcceleration = mojoArrayToFloat32Array(state->angularAcceleration); 31 m_angularAcceleration = mojoArrayToFloat32Array(state->angularAcceleration);
31 m_linearAcceleration = mojoArrayToFloat32Array(state->linearAcceleration); 32 m_linearAcceleration = mojoArrayToFloat32Array(state->linearAcceleration);
32 } 33 }
33 34
34 DEFINE_TRACE(VRPose) { 35 DEFINE_TRACE(VRPose) {
35 visitor->trace(m_orientation); 36 visitor->trace(m_orientation);
36 visitor->trace(m_position); 37 visitor->trace(m_position);
37 visitor->trace(m_angularVelocity); 38 visitor->trace(m_angularVelocity);
38 visitor->trace(m_linearVelocity); 39 visitor->trace(m_linearVelocity);
39 visitor->trace(m_angularAcceleration); 40 visitor->trace(m_angularAcceleration);
40 visitor->trace(m_linearAcceleration); 41 visitor->trace(m_linearAcceleration);
41 } 42 }
42 43
43 } // namespace blink 44 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/vr/VRFrameData.cpp ('k') | third_party/WebKit/Source/modules/vr/VRStageParameters.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698