| 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_ = mojom::VRDisplayInfo::New(); | 10 device_ = VRDisplay::New(); |
| 11 pose_ = mojom::VRPose::New(); | 11 pose_ = VRPose::New(); |
| 12 | 12 |
| 13 InitBasicDevice(); | 13 InitBasicDevice(); |
| 14 } | 14 } |
| 15 | 15 |
| 16 FakeVRDevice::~FakeVRDevice() {} | 16 FakeVRDevice::~FakeVRDevice() {} |
| 17 | 17 |
| 18 void FakeVRDevice::InitBasicDevice() { | 18 void FakeVRDevice::InitBasicDevice() { |
| 19 device_->displayName = "FakeVRDevice"; | 19 device_->displayName = "FakeVRDevice"; |
| 20 | 20 |
| 21 device_->capabilities = mojom::VRDisplayCapabilities::New(); | 21 device_->capabilities = VRDisplayCapabilities::New(); |
| 22 device_->capabilities->hasOrientation = true; | 22 device_->capabilities->hasOrientation = true; |
| 23 device_->capabilities->hasPosition = false; | 23 device_->capabilities->hasPosition = false; |
| 24 device_->capabilities->hasExternalDisplay = false; | 24 device_->capabilities->hasExternalDisplay = false; |
| 25 device_->capabilities->canPresent = false; | 25 device_->capabilities->canPresent = false; |
| 26 | 26 |
| 27 device_->leftEye = InitEye(45, -0.03f, 1024); | 27 device_->leftEye = InitEye(45, -0.03f, 1024); |
| 28 device_->rightEye = InitEye(45, 0.03f, 1024); | 28 device_->rightEye = InitEye(45, 0.03f, 1024); |
| 29 } | 29 } |
| 30 | 30 |
| 31 mojom::VREyeParametersPtr FakeVRDevice::InitEye(float fov, | 31 VREyeParametersPtr FakeVRDevice::InitEye(float fov, |
| 32 float offset, | 32 float offset, |
| 33 uint32_t size) { | 33 uint32_t size) { |
| 34 mojom::VREyeParametersPtr eye = mojom::VREyeParameters::New(); | 34 VREyeParametersPtr eye = VREyeParameters::New(); |
| 35 | 35 |
| 36 eye->fieldOfView = mojom::VRFieldOfView::New(); | 36 eye->fieldOfView = VRFieldOfView::New(); |
| 37 eye->fieldOfView->upDegrees = fov; | 37 eye->fieldOfView->upDegrees = fov; |
| 38 eye->fieldOfView->downDegrees = fov; | 38 eye->fieldOfView->downDegrees = fov; |
| 39 eye->fieldOfView->leftDegrees = fov; | 39 eye->fieldOfView->leftDegrees = fov; |
| 40 eye->fieldOfView->rightDegrees = fov; | 40 eye->fieldOfView->rightDegrees = fov; |
| 41 | 41 |
| 42 eye->offset = mojo::Array<float>::New(3); | 42 eye->offset = mojo::Array<float>::New(3); |
| 43 eye->offset[0] = offset; | 43 eye->offset[0] = offset; |
| 44 eye->offset[1] = 0.0f; | 44 eye->offset[1] = 0.0f; |
| 45 eye->offset[2] = 0.0f; | 45 eye->offset[2] = 0.0f; |
| 46 | 46 |
| 47 eye->renderWidth = size; | 47 eye->renderWidth = size; |
| 48 eye->renderHeight = size; | 48 eye->renderHeight = size; |
| 49 | 49 |
| 50 return eye; | 50 return eye; |
| 51 } | 51 } |
| 52 | 52 |
| 53 void FakeVRDevice::SetVRDevice(const mojom::VRDisplayInfoPtr& device) { | 53 void FakeVRDevice::SetVRDevice(const VRDisplayPtr& device) { |
| 54 device_ = device.Clone(); | 54 device_ = device.Clone(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void FakeVRDevice::SetPose(const mojom::VRPosePtr& pose) { | 57 void FakeVRDevice::SetPose(const VRPosePtr& pose) { |
| 58 pose_ = pose.Clone(); | 58 pose_ = pose.Clone(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 mojom::VRDisplayInfoPtr FakeVRDevice::GetVRDevice() { | 61 VRDisplayPtr FakeVRDevice::GetVRDevice() { |
| 62 mojom::VRDisplayInfoPtr display = device_.Clone(); | 62 VRDisplayPtr display = device_.Clone(); |
| 63 display->index = id(); |
| 63 return display.Clone(); | 64 return display.Clone(); |
| 64 } | 65 } |
| 65 | 66 |
| 66 mojom::VRPosePtr FakeVRDevice::GetPose(VRServiceImpl* service) { | 67 VRPosePtr FakeVRDevice::GetPose() { |
| 67 return pose_.Clone(); | 68 return pose_.Clone(); |
| 68 } | 69 } |
| 69 | 70 |
| 70 void FakeVRDevice::ResetPose(VRServiceImpl* service) {} | 71 void FakeVRDevice::ResetPose() {} |
| 71 | |
| 72 // TODO(shaobo.yan@intel.com): Will implemenate for VRDeviceServiceImpl tests. | |
| 73 bool FakeVRDevice::RequestPresent(VRServiceImpl* service, bool secure_origin) { | |
| 74 return true; | |
| 75 } | |
| 76 | |
| 77 void FakeVRDevice::ExitPresent(VRServiceImpl* service) {} | |
| 78 | |
| 79 void FakeVRDevice::SubmitFrame(VRServiceImpl* service, mojom::VRPosePtr pose) {} | |
| 80 | |
| 81 void FakeVRDevice::UpdateLayerBounds(VRServiceImpl* service, | |
| 82 mojom::VRLayerBoundsPtr leftBounds, | |
| 83 mojom::VRLayerBoundsPtr rightBounds) {} | |
| 84 | 72 |
| 85 } // namespace device | 73 } // namespace device |
| OLD | NEW |