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/android/cardboard/cardboard_vr_device.h" | 5 #include "device/vr/android/cardboard/cardboard_vr_device.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 | 9 |
10 #include "base/android/context_utils.h" | 10 #include "base/android/context_utils.h" |
11 #include "base/android/jni_android.h" | 11 #include "base/android/jni_android.h" |
12 #include "base/android/jni_array.h" | 12 #include "base/android/jni_array.h" |
13 #include "base/android/jni_string.h" | 13 #include "base/android/jni_string.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
18 #include "jni/CardboardVRDevice_jni.h" | 18 #include "jni/CardboardVRDevice_jni.h" |
19 #include "ui/gfx/transform.h" | 19 #include "ui/gfx/transform.h" |
20 #include "ui/gfx/transform_util.h" | 20 #include "ui/gfx/transform_util.h" |
21 | 21 |
22 using base::android::AttachCurrentThread; | 22 using base::android::AttachCurrentThread; |
23 | 23 |
24 namespace device { | 24 namespace device { |
25 | 25 |
26 bool CardboardVRDevice::RegisterCardboardVRDevice(JNIEnv* env) { | |
27 return RegisterNativesImpl(env); | |
28 } | |
29 | |
30 CardboardVRDevice::CardboardVRDevice(VRDeviceProvider* provider) | 26 CardboardVRDevice::CardboardVRDevice(VRDeviceProvider* provider) |
31 : VRDevice(provider) { | 27 : VRDevice(provider) { |
32 JNIEnv* env = AttachCurrentThread(); | 28 JNIEnv* env = AttachCurrentThread(); |
33 j_cardboard_device_.Reset(Java_CardboardVRDevice_create( | 29 j_cardboard_device_.Reset(Java_CardboardVRDevice_create( |
34 env, base::android::GetApplicationContext())); | 30 env, base::android::GetApplicationContext())); |
35 j_head_matrix_.Reset(env, env->NewFloatArray(16)); | 31 j_head_matrix_.Reset(env, env->NewFloatArray(16)); |
36 } | 32 } |
37 | 33 |
38 CardboardVRDevice::~CardboardVRDevice() { | 34 CardboardVRDevice::~CardboardVRDevice() { |
39 Java_CardboardVRDevice_stopTracking(AttachCurrentThread(), | 35 Java_CardboardVRDevice_stopTracking(AttachCurrentThread(), |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 144 |
149 return pose; | 145 return pose; |
150 } | 146 } |
151 | 147 |
152 void CardboardVRDevice::ResetPose() { | 148 void CardboardVRDevice::ResetPose() { |
153 Java_CardboardVRDevice_resetSensor(AttachCurrentThread(), | 149 Java_CardboardVRDevice_resetSensor(AttachCurrentThread(), |
154 j_cardboard_device_.obj()); | 150 j_cardboard_device_.obj()); |
155 } | 151 } |
156 | 152 |
157 } // namespace device | 153 } // namespace device |
OLD | NEW |