Index: content/browser/vr/android/cardboard/cardboard_vr_device.cc |
diff --git a/content/browser/vr/android/cardboard/cardboard_vr_device.cc b/content/browser/vr/android/cardboard/cardboard_vr_device.cc |
deleted file mode 100644 |
index 28661ea730ce9a4c7ab689512d1cbc430a6e294a..0000000000000000000000000000000000000000 |
--- a/content/browser/vr/android/cardboard/cardboard_vr_device.cc |
+++ /dev/null |
@@ -1,153 +0,0 @@ |
-// Copyright 2015 The Chromium Authors. All rights reserved. |
-// Use of this source code is governed by a BSD-style license that can be |
-// found in the LICENSE file. |
- |
-#include "content/browser/vr/android/cardboard/cardboard_vr_device.h" |
- |
-#include <math.h> |
-#include <algorithm> |
- |
-#include "base/android/jni_android.h" |
-#include "base/android/jni_array.h" |
-#include "base/android/jni_string.h" |
-#include "base/strings/string_util.h" |
-#include "base/strings/utf_string_conversions.h" |
-#include "base/time/time.h" |
-#include "base/trace_event/trace_event.h" |
-#include "content/browser/vr/vr_transform_util.h" |
-#include "jni/CardboardVRDevice_jni.h" |
- |
-using base::android::AttachCurrentThread; |
- |
-namespace content { |
- |
-bool CardboardVRDevice::RegisterCardboardVRDevice(JNIEnv* env) { |
- return RegisterNativesImpl(env); |
-} |
- |
-CardboardVRDevice::CardboardVRDevice(VRDeviceProvider* provider) |
- : VRDevice(provider), frame_index_(0) { |
- JNIEnv* env = AttachCurrentThread(); |
- j_cardboard_device_.Reset(Java_CardboardVRDevice_create( |
- env, base::android::GetApplicationContext())); |
- j_head_matrix_.Reset(env, env->NewFloatArray(16)); |
-} |
- |
-CardboardVRDevice::~CardboardVRDevice() { |
- Java_CardboardVRDevice_stopTracking(AttachCurrentThread(), |
- j_cardboard_device_.obj()); |
-} |
- |
-VRDeviceInfoPtr CardboardVRDevice::GetVRDevice() { |
- TRACE_EVENT0("input", "CardboardVRDevice::GetVRDevice"); |
- VRDeviceInfoPtr device = VRDeviceInfo::New(); |
- |
- JNIEnv* env = AttachCurrentThread(); |
- |
- ScopedJavaLocalRef<jstring> j_device_name = |
- Java_CardboardVRDevice_getDeviceName(env, j_cardboard_device_.obj()); |
- device->deviceName = |
- base::android::ConvertJavaStringToUTF8(env, j_device_name.obj()); |
- |
- ScopedJavaLocalRef<jfloatArray> j_fov(env, env->NewFloatArray(4)); |
- Java_CardboardVRDevice_getFieldOfView(env, j_cardboard_device_.obj(), |
- j_fov.obj()); |
- |
- std::vector<float> fov; |
- base::android::JavaFloatArrayToFloatVector(env, j_fov.obj(), &fov); |
- |
- device->hmdInfo = VRHMDInfo::New(); |
- VRHMDInfoPtr& hmdInfo = device->hmdInfo; |
- |
- hmdInfo->leftEye = VREyeParameters::New(); |
- hmdInfo->rightEye = VREyeParameters::New(); |
- VREyeParametersPtr& left_eye = hmdInfo->leftEye; |
- VREyeParametersPtr& right_eye = hmdInfo->rightEye; |
- |
- left_eye->recommendedFieldOfView = VRFieldOfView::New(); |
- left_eye->recommendedFieldOfView->upDegrees = fov[0]; |
- left_eye->recommendedFieldOfView->downDegrees = fov[1]; |
- left_eye->recommendedFieldOfView->leftDegrees = fov[2]; |
- left_eye->recommendedFieldOfView->rightDegrees = fov[3]; |
- |
- // Cardboard devices always assume a mirrored FOV, so this is just the left |
- // eye FOV with the left and right degrees swapped. |
- right_eye->recommendedFieldOfView = VRFieldOfView::New(); |
- right_eye->recommendedFieldOfView->upDegrees = fov[0]; |
- right_eye->recommendedFieldOfView->downDegrees = fov[1]; |
- right_eye->recommendedFieldOfView->leftDegrees = fov[3]; |
- right_eye->recommendedFieldOfView->rightDegrees = fov[2]; |
- |
- // Cardboard does not support configurable FOV. |
- left_eye->maximumFieldOfView = left_eye->recommendedFieldOfView.Clone(); |
- right_eye->maximumFieldOfView = right_eye->recommendedFieldOfView.Clone(); |
- left_eye->minimumFieldOfView = left_eye->recommendedFieldOfView.Clone(); |
- right_eye->minimumFieldOfView = right_eye->recommendedFieldOfView.Clone(); |
- |
- float ipd = Java_CardboardVRDevice_getIpd(env, j_cardboard_device_.obj()); |
- |
- left_eye->eyeTranslation = VRVector3::New(); |
- left_eye->eyeTranslation->x = ipd * -0.5f; |
- left_eye->eyeTranslation->y = 0.0f; |
- left_eye->eyeTranslation->z = 0.0f; |
- |
- right_eye->eyeTranslation = VRVector3::New(); |
- right_eye->eyeTranslation->x = ipd * 0.5f; |
- right_eye->eyeTranslation->y = 0.0f; |
- right_eye->eyeTranslation->z = 0.0f; |
- |
- ScopedJavaLocalRef<jintArray> j_screen_size(env, env->NewIntArray(2)); |
- Java_CardboardVRDevice_getScreenSize(env, j_cardboard_device_.obj(), |
- j_screen_size.obj()); |
- |
- std::vector<int> screen_size; |
- base::android::JavaIntArrayToIntVector(env, j_screen_size.obj(), |
- &screen_size); |
- |
- left_eye->renderRect = VRRect::New(); |
- left_eye->renderRect->x = 0; |
- left_eye->renderRect->y = 0; |
- left_eye->renderRect->width = screen_size[0] / 2.0; |
- left_eye->renderRect->height = screen_size[1]; |
- |
- right_eye->renderRect = VRRect::New(); |
- right_eye->renderRect->x = screen_size[0] / 2.0; |
- right_eye->renderRect->y = 0; |
- right_eye->renderRect->width = screen_size[0] / 2.0; |
- right_eye->renderRect->height = screen_size[1]; |
- |
- return device.Pass(); |
-} |
- |
-VRSensorStatePtr CardboardVRDevice::GetSensorState() { |
- TRACE_EVENT0("input", "CardboardVRDevice::GetSensorState"); |
- VRSensorStatePtr state = VRSensorState::New(); |
- |
- state->timestamp = base::Time::Now().ToJsTime(); |
- state->frameIndex = frame_index_++; |
- |
- JNIEnv* env = AttachCurrentThread(); |
- Java_CardboardVRDevice_getSensorState(env, j_cardboard_device_.obj(), |
- j_head_matrix_.obj()); |
- |
- std::vector<float> head_matrix; |
- base::android::JavaFloatArrayToFloatVector(env, j_head_matrix_.obj(), |
- &head_matrix); |
- |
- state->orientation = MatrixToOrientationQuaternion( |
- &head_matrix[0], &head_matrix[4], &head_matrix[8]); |
- |
- state->position = VRVector3::New(); |
- state->position->x = -head_matrix[12]; |
- state->position->y = head_matrix[13]; |
- state->position->z = head_matrix[14]; |
- |
- return state.Pass(); |
-} |
- |
-void CardboardVRDevice::ResetSensor() { |
- Java_CardboardVRDevice_resetSensor(AttachCurrentThread(), |
- j_cardboard_device_.obj()); |
-} |
- |
-} // namespace content |