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

Side by Side Diff: third_party/WebKit/Source/modules/gamepad/GamepadPose.cpp

Issue 2808093006: [Device Service] Move Gamepad Blink headers to be part of the Gamepad client library (Closed)
Patch Set: rebase and address comments Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/gamepad/GamepadPose.h" 5 #include "modules/gamepad/GamepadPose.h"
6 6
7 namespace blink { 7 namespace blink {
8 8
9 namespace { 9 namespace {
10 10
11 DOMFloat32Array* VecToFloat32Array(const WebGamepadVector& vec) { 11 DOMFloat32Array* VecToFloat32Array(const device::GamepadVector& vec) {
12 if (vec.not_null) { 12 if (vec.not_null) {
13 DOMFloat32Array* out = DOMFloat32Array::Create(3); 13 DOMFloat32Array* out = DOMFloat32Array::Create(3);
14 out->Data()[0] = vec.x; 14 out->Data()[0] = vec.x;
15 out->Data()[1] = vec.y; 15 out->Data()[1] = vec.y;
16 out->Data()[2] = vec.z; 16 out->Data()[2] = vec.z;
17 return out; 17 return out;
18 } 18 }
19 return nullptr; 19 return nullptr;
20 } 20 }
21 21
22 DOMFloat32Array* QuatToFloat32Array(const WebGamepadQuaternion& quat) { 22 DOMFloat32Array* QuatToFloat32Array(const device::GamepadQuaternion& quat) {
23 if (quat.not_null) { 23 if (quat.not_null) {
24 DOMFloat32Array* out = DOMFloat32Array::Create(4); 24 DOMFloat32Array* out = DOMFloat32Array::Create(4);
25 out->Data()[0] = quat.x; 25 out->Data()[0] = quat.x;
26 out->Data()[1] = quat.y; 26 out->Data()[1] = quat.y;
27 out->Data()[2] = quat.z; 27 out->Data()[2] = quat.z;
28 out->Data()[3] = quat.w; 28 out->Data()[3] = quat.w;
29 return out; 29 return out;
30 } 30 }
31 return nullptr; 31 return nullptr;
32 } 32 }
33 33
34 } // namespace 34 } // namespace
35 35
36 GamepadPose::GamepadPose() {} 36 GamepadPose::GamepadPose() {}
37 37
38 void GamepadPose::SetPose(const WebGamepadPose& state) { 38 void GamepadPose::SetPose(const device::GamepadPose& state) {
39 if (state.not_null) { 39 if (state.not_null) {
40 has_orientation_ = state.has_orientation; 40 has_orientation_ = state.has_orientation;
41 has_position_ = state.has_position; 41 has_position_ = state.has_position;
42 42
43 orientation_ = QuatToFloat32Array(state.orientation); 43 orientation_ = QuatToFloat32Array(state.orientation);
44 position_ = VecToFloat32Array(state.position); 44 position_ = VecToFloat32Array(state.position);
45 angular_velocity_ = VecToFloat32Array(state.angular_velocity); 45 angular_velocity_ = VecToFloat32Array(state.angular_velocity);
46 linear_velocity_ = VecToFloat32Array(state.linear_velocity); 46 linear_velocity_ = VecToFloat32Array(state.linear_velocity);
47 angular_acceleration_ = VecToFloat32Array(state.angular_acceleration); 47 angular_acceleration_ = VecToFloat32Array(state.angular_acceleration);
48 linear_acceleration_ = VecToFloat32Array(state.linear_acceleration); 48 linear_acceleration_ = VecToFloat32Array(state.linear_acceleration);
49 } 49 }
50 } 50 }
51 51
52 DEFINE_TRACE(GamepadPose) { 52 DEFINE_TRACE(GamepadPose) {
53 visitor->Trace(orientation_); 53 visitor->Trace(orientation_);
54 visitor->Trace(position_); 54 visitor->Trace(position_);
55 visitor->Trace(angular_velocity_); 55 visitor->Trace(angular_velocity_);
56 visitor->Trace(linear_velocity_); 56 visitor->Trace(linear_velocity_);
57 visitor->Trace(angular_acceleration_); 57 visitor->Trace(angular_acceleration_);
58 visitor->Trace(linear_acceleration_); 58 visitor->Trace(linear_acceleration_);
59 } 59 }
60 60
61 } // namespace blink 61 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/gamepad/GamepadPose.h ('k') | third_party/WebKit/Source/modules/gamepad/NavigatorGamepad.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698