 Chromium Code Reviews
 Chromium Code Reviews Issue 1967633002:
  Updated VRService to match the latest Blink WebVR interface.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1967633002:
  Updated VRService to match the latest Blink WebVR interface.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| OLD | NEW | 
|---|---|
| 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) | 
| 
haraken
2016/05/18 23:50:01
Shall we:
- move this function to platform/mojo/M
 | |
| 12 { | 12 { | 
| 13 if (!vec.is_null()) { | 13 if (!vec.is_null()) { | 
| 14 DOMFloat32Array* out = DOMFloat32Array::create(4); | 14 return DOMFloat32Array::create(&(vec.front()), vec.size()); | 
| 
esprehn
2016/05/18 21:55:29
This will crash if the vector is of size 0. Should
 | |
| 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 } | 15 } | 
| 21 return nullptr; | 16 return nullptr; | 
| 22 } | 17 } | 
| 23 | |
| 24 DOMFloat32Array* vecToFloat32Array(const mojom::blink::VRVector3Ptr& vec) | |
| 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 } | |
| 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 | 
| OLD | NEW |