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 "device/vr/test/fake_vr_device.h" | 5 #include "device/vr/test/fake_vr_device.h" |
6 | 6 |
7 namespace device { | 7 namespace device { |
8 | 8 |
9 FakeVRDevice::FakeVRDevice(VRDeviceProvider* provider) : VRDevice(provider) { | 9 FakeVRDevice::FakeVRDevice(VRDeviceProvider* provider) : VRDevice(provider) { |
10 device_ = VRDisplay::New(); | 10 device_ = VRDisplay::New(); |
11 pose_ = VRPose::New(); | 11 pose_ = VRPose::New(); |
| 12 |
| 13 InitBasicDevice(); |
12 } | 14 } |
13 | 15 |
14 FakeVRDevice::~FakeVRDevice() {} | 16 FakeVRDevice::~FakeVRDevice() {} |
15 | 17 |
| 18 void FakeVRDevice::InitBasicDevice() { |
| 19 device_->displayName = "FakeVRDevice"; |
| 20 |
| 21 device_->capabilities = VRDisplayCapabilities::New(); |
| 22 device_->capabilities->hasOrientation = true; |
| 23 device_->capabilities->hasPosition = false; |
| 24 device_->capabilities->hasExternalDisplay = false; |
| 25 device_->capabilities->canPresent = false; |
| 26 |
| 27 device_->leftEye = InitEye(45, -0.03f, 1024); |
| 28 device_->rightEye = InitEye(45, 0.03f, 1024); |
| 29 } |
| 30 |
| 31 VREyeParametersPtr FakeVRDevice::InitEye(float fov, |
| 32 float offset, |
| 33 uint32_t size) { |
| 34 VREyeParametersPtr eye = VREyeParameters::New(); |
| 35 |
| 36 eye->fieldOfView = VRFieldOfView::New(); |
| 37 eye->fieldOfView->upDegrees = fov; |
| 38 eye->fieldOfView->downDegrees = fov; |
| 39 eye->fieldOfView->leftDegrees = fov; |
| 40 eye->fieldOfView->rightDegrees = fov; |
| 41 |
| 42 eye->offset = mojo::Array<float>::New(3); |
| 43 eye->offset[0] = offset; |
| 44 eye->offset[1] = 0.0f; |
| 45 eye->offset[2] = 0.0f; |
| 46 |
| 47 eye->renderWidth = size; |
| 48 eye->renderHeight = size; |
| 49 |
| 50 return eye; |
| 51 } |
| 52 |
16 void FakeVRDevice::SetVRDevice(const VRDisplayPtr& device) { | 53 void FakeVRDevice::SetVRDevice(const VRDisplayPtr& device) { |
17 device_ = device.Clone(); | 54 device_ = device.Clone(); |
18 } | 55 } |
19 | 56 |
20 void FakeVRDevice::SetPose(const VRPosePtr& pose) { | 57 void FakeVRDevice::SetPose(const VRPosePtr& pose) { |
21 pose_ = pose.Clone(); | 58 pose_ = pose.Clone(); |
22 } | 59 } |
23 | 60 |
24 VRDisplayPtr FakeVRDevice::GetVRDevice() { | 61 VRDisplayPtr FakeVRDevice::GetVRDevice() { |
25 return device_.Clone(); | 62 VRDisplayPtr display = device_.Clone(); |
| 63 display->index = id(); |
| 64 return display.Clone(); |
26 } | 65 } |
27 | 66 |
28 VRPosePtr FakeVRDevice::GetPose() { | 67 VRPosePtr FakeVRDevice::GetPose() { |
29 return pose_.Clone(); | 68 return pose_.Clone(); |
30 } | 69 } |
31 | 70 |
32 void FakeVRDevice::ResetPose() {} | 71 void FakeVRDevice::ResetPose() {} |
33 | 72 |
34 } // namespace device | 73 } // namespace device |
OLD | NEW |