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

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

Issue 1709003002: Geometry: Reimplement DOMPoint using V8 extras. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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/VRPositionState.h" 5 #include "modules/vr/VRPositionState.h"
6 6
7 #include "bindings/core/v8/GeometryInterfaces.h"
8
7 namespace blink { 9 namespace blink {
8 10
9 namespace { 11 namespace {
10 12
11 DOMPoint* vecToDomPoint(const WebVRVector4& vec, bool valid) 13 void vecToDomPoint(ScriptValue& value, const WebVRVector4& vec, bool valid)
12 { 14 {
13 if (valid) 15 if (valid)
14 return DOMPoint::create(vec.x, vec.y, vec.z, vec.w); 16 value = GeometryInterfaces::createDOMPoint(vec.x, vec.y, vec.z, vec.w);
15 return nullptr; 17 value = ScriptValue::createNull(ScriptState::current(v8::Isolate::GetCurrent ()));
haraken 2016/02/25 11:21:11 Please don't use ScriptState::current without unde
16 } 18 }
17 DOMPoint* vecToDomPoint(const WebVRVector3& vec, bool valid) 19
20 void vecToDomPoint(ScriptValue& value, const WebVRVector3& vec, bool valid)
18 { 21 {
19 if (valid) 22 if (valid)
20 return DOMPoint::create(vec.x, vec.y, vec.z, 1.0); 23 value = GeometryInterfaces::createDOMPoint(vec.x, vec.y, vec.z, 1.0);
21 return nullptr; 24 value = ScriptValue::createNull(ScriptState::current(v8::Isolate::GetCurrent ()));
22 } 25 }
23 26
24 } // namespace 27 } // namespace
25 28
26 VRPositionState::VRPositionState() 29 VRPositionState::VRPositionState()
27 : m_timeStamp(0.0) 30 : m_timeStamp(0.0)
28 { 31 {
29 } 32 }
30 33
31 void VRPositionState::setState(const WebHMDSensorState &state) 34 void VRPositionState::setState(const WebHMDSensorState &state)
32 { 35 {
33 m_timeStamp = state.timestamp; 36 m_timeStamp = state.timestamp;
34 m_orientation = vecToDomPoint(state.orientation, state.flags & WebVRSensorSt ateOrientation); 37 vecToDomPoint(m_orientation, state.orientation, state.flags & WebVRSensorSta teOrientation);
domenic 2016/02/24 21:23:04 Is using references in this way OK according to Bl
35 m_position = vecToDomPoint(state.position, state.flags & WebVRSensorStatePos ition); 38 vecToDomPoint(m_position, state.position, state.flags & WebVRSensorStatePosi tion);
36 m_angularVelocity = vecToDomPoint(state.angularVelocity, state.flags & WebVR SensorStateAngularVelocity); 39 vecToDomPoint(m_angularVelocity, state.angularVelocity, state.flags & WebVRS ensorStateAngularVelocity);
37 m_linearVelocity = vecToDomPoint(state.linearVelocity, state.flags & WebVRSe nsorStateLinearVelocity); 40 vecToDomPoint(m_linearVelocity, state.linearVelocity, state.flags & WebVRSen sorStateLinearVelocity);
38 m_angularAcceleration = vecToDomPoint(state.angularAcceleration, state.flags & WebVRSensorStateAngularAcceleration); 41 vecToDomPoint(m_angularAcceleration, state.angularAcceleration, state.flags & WebVRSensorStateAngularAcceleration);
39 m_linearAcceleration = vecToDomPoint(state.linearAcceleration, state.flags & WebVRSensorStateLinearAcceleration); 42 vecToDomPoint(m_linearAcceleration, state.linearAcceleration, state.flags & WebVRSensorStateLinearAcceleration);
40 } 43 }
41 44
42 DEFINE_TRACE(VRPositionState) 45 DEFINE_TRACE(VRPositionState)
43 { 46 {
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 } 47 }
51 48
52 } // namespace blink 49 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698