Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "device/vr/android/gvr/gvr_delegate.h" | 12 #include "device/vr/android/gvr/gvr_delegate.h" |
| 13 #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.h" |
| 14 #include "third_party/gvr-android-sdk/src/ndk-beta/include/vr/gvr/capi/include/g vr_types.h" | 14 #include "third_party/gvr-android-sdk/src/ndk-beta/include/vr/gvr/capi/include/g vr_types.h" |
| 15 #include "ui/gfx/transform.h" | 15 #include "ui/gfx/transform.h" |
| 16 #include "ui/gfx/transform_util.h" | 16 #include "ui/gfx/transform_util.h" |
| 17 | 17 |
| 18 namespace device { | 18 namespace device { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 static const uint64_t kPredictionTimeWithoutVsyncNanos = 50000000; | 22 static const uint64_t kPredictionTimeWithoutVsyncNanos = 50000000; |
| 23 | 23 |
| 24 } // namespace | 24 } // namespace |
| 25 | 25 |
| 26 GvrDevice::GvrDevice(VRDeviceProvider* provider, GvrDelegate* delegate) | 26 GvrDevice::GvrDevice(VRDeviceProvider* provider, GvrDelegate* delegate) |
| 27 : VRDevice(provider), delegate_(delegate) {} | 27 : VRDevice(provider), |
| 28 delegate_(delegate), | |
| 29 isConnected_(false), | |
| 30 isConnectionStatusChanged_(false) {} | |
| 28 | 31 |
| 29 GvrDevice::~GvrDevice() {} | 32 GvrDevice::~GvrDevice() {} |
| 30 | 33 |
| 31 VRDisplayPtr GvrDevice::GetVRDevice() { | 34 VRDisplayPtr GvrDevice::GetVRDevice() { |
| 32 TRACE_EVENT0("input", "GvrDevice::GetVRDevice"); | 35 TRACE_EVENT0("input", "GvrDevice::GetVRDevice"); |
| 33 | 36 |
| 34 gvr::GvrApi* gvr_api = delegate_->gvr_api(); | 37 gvr::GvrApi* gvr_api = delegate_->gvr_api(); |
| 35 | 38 |
| 36 VRDisplayPtr device = VRDisplay::New(); | 39 VRDisplayPtr device = VRDisplay::New(); |
| 37 | 40 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 void GvrDevice::UpdateLayerBounds(VRLayerBoundsPtr leftBounds, | 159 void GvrDevice::UpdateLayerBounds(VRLayerBoundsPtr leftBounds, |
| 157 VRLayerBoundsPtr rightBounds) { | 160 VRLayerBoundsPtr rightBounds) { |
| 158 delegate_->UpdateWebVRTextureBounds(0, // Left eye | 161 delegate_->UpdateWebVRTextureBounds(0, // Left eye |
| 159 leftBounds->left, leftBounds->top, | 162 leftBounds->left, leftBounds->top, |
| 160 leftBounds->width, leftBounds->height); | 163 leftBounds->width, leftBounds->height); |
| 161 delegate_->UpdateWebVRTextureBounds(1, // Right eye | 164 delegate_->UpdateWebVRTextureBounds(1, // Right eye |
| 162 rightBounds->left, rightBounds->top, | 165 rightBounds->left, rightBounds->top, |
| 163 rightBounds->width, rightBounds->height); | 166 rightBounds->width, rightBounds->height); |
| 164 } | 167 } |
| 165 | 168 |
| 169 // It will poll status from device and resolve it. | |
| 170 void GvrDevice::PollEvents(VRClientDispatcher* client) { | |
| 171 if (isConnectionStatusChanged_) { | |
| 172 client->OnDeviceConnectionStatusChanged(this, isConnected_); | |
|
bajones
2016/09/09 05:53:00
Let's call this in UpdateConnectionStatus and avoi
| |
| 173 isConnectionStatusChanged_ = false; | |
| 174 } | |
| 175 } | |
| 176 | |
| 177 void GvrDevice::UpdateConnectionStatus(bool isConnected) { | |
| 178 if (isConnected_ != isConnected) { | |
| 179 isConnected_ = isConnected; | |
| 180 isConnectionStatusChanged_ = true; | |
| 181 } | |
| 182 } | |
| 183 | |
| 166 } // namespace device | 184 } // namespace device |
| OLD | NEW |