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

Side by Side Diff: device/vr/android/gvr/gvr_device.cc

Issue 2317483002: Add support of vrdisplayconnect and vrdisplaydisconnect event (Closed)
Patch Set: Fix typo of Event reason Created 4 years, 3 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/android/gvr/gvr_device.h" 5 #include "device/vr/android/gvr/gvr_device.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <algorithm> 8 #include <algorithm>
9 9
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "base/trace_event/trace_event.h" 11 #include "base/trace_event/trace_event.h"
12 #include "third_party/gvr-android-sdk/src/ndk-beta/include/vr/gvr/capi/include/g vr.h" 12 #include "third_party/gvr-android-sdk/src/ndk-beta/include/vr/gvr/capi/include/g vr.h"
13 #include "third_party/gvr-android-sdk/src/ndk-beta/include/vr/gvr/capi/include/g vr_types.h" 13 #include "third_party/gvr-android-sdk/src/ndk-beta/include/vr/gvr/capi/include/g vr_types.h"
14 #include "ui/gfx/transform.h" 14 #include "ui/gfx/transform.h"
15 #include "ui/gfx/transform_util.h" 15 #include "ui/gfx/transform_util.h"
16 16
17 namespace device { 17 namespace device {
18 18
19 namespace { 19 namespace {
20 20
21 static const uint64_t kPredictionTimeWithoutVsyncNanos = 50000000; 21 static const uint64_t kPredictionTimeWithoutVsyncNanos = 50000000;
22 22
23 } // namespace 23 } // namespace
24 24
25 GvrDevice::GvrDevice(VRDeviceProvider* provider, gvr::GvrApi* gvr_api) 25 GvrDevice::GvrDevice(VRDeviceProvider* provider, gvr::GvrApi* gvr_api)
26 : VRDevice(provider), gvr_api_(gvr_api) {} 26 : VRDevice(provider), gvr_api_(gvr_api) {
27 isConnected = false;
28 }
27 29
28 GvrDevice::~GvrDevice() {} 30 GvrDevice::~GvrDevice() {}
29 31
30 VRDisplayPtr GvrDevice::GetVRDevice() { 32 VRDisplayPtr GvrDevice::GetVRDevice() {
31 TRACE_EVENT0("input", "GvrDevice::GetVRDevice"); 33 TRACE_EVENT0("input", "GvrDevice::GetVRDevice");
32 34
33 VRDisplayPtr device = VRDisplay::New(); 35 VRDisplayPtr device = VRDisplay::New();
34 36
35 device->capabilities = VRDisplayCapabilities::New(); 37 device->capabilities = VRDisplayCapabilities::New();
36 device->capabilities->hasOrientation = true; 38 device->capabilities->hasOrientation = true;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 pose->position[2] = decomposed_transform.translate[2]; 128 pose->position[2] = decomposed_transform.translate[2];
127 } 129 }
128 130
129 return pose; 131 return pose;
130 } 132 }
131 133
132 void GvrDevice::ResetPose() { 134 void GvrDevice::ResetPose() {
133 gvr_api_->ResetTracking(); 135 gvr_api_->ResetTracking();
134 } 136 }
135 137
138 // There are two conditions which hint that connection status has been changed.
139 // First, if the GvrApi pointer is valid and nativeContext could be acquired,
140 // the
mthiesse 2016/09/06 23:39:24 nit: fix comment formatting.
141 // connection may be built.
142 // Second, if the GvrApi pointer is invalid or nativeContext couldn't be
143 // acquired, the
144 // connection may be lost.
145 void GvrDevice::PollEvents() {
bajones 2016/09/06 23:57:26 Sorry, I'm also realizing that this is a signal th
shaobo.yan 2016/09/07 00:49:19 Hi, brandon, thx for reviewing! I agree that OnGvr
146 if (!client())
147 return;
148
149 if ((!isConnected && gvr_api_ && gvr_api_->GetContext()) ||
150 (isConnected && (!gvr_api_ || (gvr_api_ && !gvr_api_->GetContext())))) {
151 isConnected = !isConnected;
152 client()->OnDeviceConnectionStatusChanged(this, isConnected);
153 }
154 }
155
136 } // namespace device 156 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698