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

Side by Side Diff: content/browser/vr/vr_test_helpers.cc

Issue 829803003: Adding Chrome-side WebVR interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updates/cleanups before pulling in reviewers. Created 5 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
(Empty)
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/vr/vr_test_helpers.h"
6
7 namespace content {
8
9 MockVRDevice::MockVRDevice(VRDeviceProvider* provider)
10 : VRDevice(provider) {
11 }
12
13 MockVRDevice::~MockVRDevice() {
14
15 }
16
17 void MockVRDevice::SetVRDevice(const blink::WebVRDevice& device) {
18 device_ = device;
19 }
20
21 void MockVRDevice::SetHMDSensorState(const blink::WebHMDSensorState& state) {
22 state_ = state;
23 }
24
25 void MockVRDevice::SetRenderTargetSize(
26 unsigned int width,
27 unsigned int height) {
28 width_ = width;
29 height_ = height;
30 }
31
32 void MockVRDevice::GetVRDevice(blink::WebVRDevice* device) {
33 *device = device_;
34 }
35
36 void MockVRDevice::GetHMDSensorState(blink::WebHMDSensorState* state) {
37 *state = state_;
38 }
39 void MockVRDevice::GetRenderTargetRects(
40 blink::WebVRFieldOfView leftFov,
41 blink::WebVRFieldOfView rightFov,
42 blink::WebVRVector4* leftRect,
43 blink::WebVRVector4* rightRect) {
44 leftRect->x = 0;
45 leftRect->y = 0;
46 leftRect->z = width_ / 2.0;
47 leftRect->w = height_;
48
49 rightRect->x = width_ / 2.0;
50 rightRect->y = 0;
51 rightRect->z = width_ / 2.0;
52 rightRect->w = height_;
53 }
54
55 MockVRDeviceProvider::MockVRDeviceProvider() : VRDeviceProvider() {
56 initialized_ = false;
57 }
58
59 MockVRDeviceProvider::~MockVRDeviceProvider() {
60 }
61
62 void MockVRDeviceProvider::AddDevice(VRDevice* device) {
63 devices_.push_back(device);
64 }
65
66 void MockVRDeviceProvider::RemoveDevice(VRDevice* device) {
67 std::vector<VRDevice*>::iterator iter = devices_.begin();
68 while (iter != devices_.end()) {
69 if (device == *iter) {
70 iter = devices_.erase(iter);
71 } else {
72 ++iter;
73 }
74 }
75 }
76
77 void MockVRDeviceProvider::GetDevices(std::vector<VRDevice*>& devices) {
78 std::vector<VRDevice*>::iterator iter;
79
80 for(iter = devices_.begin(); iter != devices_.end(); ++iter) {
81 devices.push_back(*iter);
82 }
83 }
84
85 void MockVRDeviceProvider::Initialize() {
86 initialized_ = true;
87 }
88
89 void MockVRDeviceProvider::Shutdown() {
90 initialized_ = false;
91 }
92
93 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698