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/VREyeParameters.h" | 5 #include "modules/vr/VREyeParameters.h" |
| 6 #include "public/platform/modules/vr/WebVR.h" |
6 | 7 |
7 namespace blink { | 8 namespace blink { |
8 | 9 |
9 namespace { | 10 namespace { |
10 | 11 |
11 void setDomPoint(DOMPoint* point, const WebVRVector3& vec) | 12 void setVecToFloat32Array(DOMFloat32Array* out, const WebVRVector3& vec) |
12 { | 13 { |
13 point->setX(vec.x); | 14 out->data()[0] = vec.x; |
14 point->setY(vec.y); | 15 out->data()[1] = vec.y; |
15 point->setZ(vec.z); | 16 out->data()[2] = vec.z; |
16 point->setW(1.0); | |
17 } | 17 } |
18 | 18 |
19 } // namespace | 19 } // namespace |
20 | 20 |
21 VREyeParameters::VREyeParameters() | 21 VREyeParameters::VREyeParameters() |
22 { | 22 { |
23 m_minimumFieldOfView = new VRFieldOfView(); | 23 m_offset = DOMFloat32Array::create(3); |
24 m_maximumFieldOfView = new VRFieldOfView(); | 24 m_fieldOfView = new VRFieldOfView(); |
25 m_recommendedFieldOfView = new VRFieldOfView(); | 25 m_renderWidth = 0; |
26 m_eyeTranslation = DOMPoint::create(0, 0, 0, 0); | 26 m_renderHeight = 0; |
27 | |
28 m_currentFieldOfView = new VRFieldOfView(); | |
29 m_renderRect = DOMRect::create(0, 0, 0, 0); | |
30 } | 27 } |
31 | 28 |
32 void VREyeParameters::setFromWebVREyeParameters(const WebVREyeParameters &state) | 29 void VREyeParameters::update(const WebVREyeParameters &eye_parameters) |
33 { | 30 { |
34 // FIXME: We should expose proper min/max FOV eventually but for now set the | 31 setVecToFloat32Array(m_offset.get(), eye_parameters.eyeTranslation); |
35 // min/max equal to the recommended FOV to reduce need for synchronous | 32 m_fieldOfView->setFromWebVRFieldOfView(eye_parameters.recommendedFieldOfView
); |
36 // queries and reduce rendering complexity. | 33 m_renderWidth = eye_parameters.renderRect.width; |
37 m_minimumFieldOfView->setFromWebVRFieldOfView(state.recommendedFieldOfView); | 34 m_renderHeight = eye_parameters.renderRect.height; |
38 m_maximumFieldOfView->setFromWebVRFieldOfView(state.recommendedFieldOfView); | |
39 m_recommendedFieldOfView->setFromWebVRFieldOfView(state.recommendedFieldOfVi
ew); | |
40 setDomPoint(m_eyeTranslation, state.eyeTranslation); | |
41 | |
42 m_currentFieldOfView->setFromWebVRFieldOfView(state.recommendedFieldOfView); | |
43 m_renderRect = DOMRect::create(state.renderRect.x, state.renderRect.y, state
.renderRect.width, state.renderRect.height); | |
44 } | 35 } |
45 | 36 |
46 DEFINE_TRACE(VREyeParameters) | 37 DEFINE_TRACE(VREyeParameters) |
47 { | 38 { |
48 visitor->trace(m_minimumFieldOfView); | 39 visitor->trace(m_offset); |
49 visitor->trace(m_maximumFieldOfView); | 40 visitor->trace(m_fieldOfView); |
50 visitor->trace(m_recommendedFieldOfView); | |
51 visitor->trace(m_eyeTranslation); | |
52 visitor->trace(m_currentFieldOfView); | |
53 visitor->trace(m_renderRect); | |
54 } | 41 } |
55 | 42 |
56 } // namespace blink | 43 } // namespace blink |
OLD | NEW |