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/VRPositionState.cpp

Issue 1918143007: Updated Blink WebVR interfaces to WebVR v1 spec (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webvr_mojo
Patch Set: Fixed layout test 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "modules/vr/VRPositionState.h"
6
7 namespace blink {
8
9 namespace {
10
11 DOMPoint* vecToDomPoint(const WebVRVector4& vec, bool valid)
12 {
13 if (valid)
14 return DOMPoint::create(vec.x, vec.y, vec.z, vec.w);
15 return nullptr;
16 }
17 DOMPoint* vecToDomPoint(const WebVRVector3& vec, bool valid)
18 {
19 if (valid)
20 return DOMPoint::create(vec.x, vec.y, vec.z, 1.0);
21 return nullptr;
22 }
23
24 } // namespace
25
26 VRPositionState::VRPositionState()
27 : m_timeStamp(0.0)
28 {
29 }
30
31 void VRPositionState::setState(const WebHMDSensorState &state)
32 {
33 m_timeStamp = state.timestamp;
34 m_orientation = vecToDomPoint(state.orientation, state.flags & WebVRSensorSt ateOrientation);
35 m_position = vecToDomPoint(state.position, state.flags & WebVRSensorStatePos ition);
36 m_angularVelocity = vecToDomPoint(state.angularVelocity, state.flags & WebVR SensorStateAngularVelocity);
37 m_linearVelocity = vecToDomPoint(state.linearVelocity, state.flags & WebVRSe nsorStateLinearVelocity);
38 m_angularAcceleration = vecToDomPoint(state.angularAcceleration, state.flags & WebVRSensorStateAngularAcceleration);
39 m_linearAcceleration = vecToDomPoint(state.linearAcceleration, state.flags & WebVRSensorStateLinearAcceleration);
40 }
41
42 DEFINE_TRACE(VRPositionState)
43 {
44 visitor->trace(m_orientation);
45 visitor->trace(m_position);
46 visitor->trace(m_angularVelocity);
47 visitor->trace(m_linearVelocity);
48 visitor->trace(m_angularAcceleration);
49 visitor->trace(m_linearAcceleration);
50 }
51
52 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/vr/VRPositionState.h ('k') | third_party/WebKit/Source/modules/vr/VRPositionState.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698