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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/input/CardboardVRDevice.java

Issue 829803003: Adding Chrome-side WebVR interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed the rest of sievers@ input 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 side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/browser/input/CardboardVRDevice.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/CardboardVRDevice.java b/content/public/android/java/src/org/chromium/content/browser/input/CardboardVRDevice.java
new file mode 100644
index 0000000000000000000000000000000000000000..a15f05b385a177098c085d4d5ac0bc7dee700017
--- /dev/null
+++ b/content/public/android/java/src/org/chromium/content/browser/input/CardboardVRDevice.java
@@ -0,0 +1,91 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
no sievers 2015/03/26 19:55:15 nit: 2015
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.content.browser.input;
+
+import android.content.Context;
+
+import com.google.vrtoolkit.cardboard.CardboardDeviceParams;
+import com.google.vrtoolkit.cardboard.FieldOfView;
+import com.google.vrtoolkit.cardboard.HeadMountedDisplay;
+import com.google.vrtoolkit.cardboard.HeadMountedDisplayManager;
+import com.google.vrtoolkit.cardboard.ScreenParams;
+import com.google.vrtoolkit.cardboard.sensors.HeadTracker;
+
+import org.chromium.base.CalledByNative;
+import org.chromium.base.JNINamespace;
+
+/**
+ * This is the implementation of the C++ counterpart CardboardVRDevice.
+ */
+@JNINamespace("content")
+class CardboardVRDevice {
+ private static final String TAG = "CardboardVRDevice";
+ private HeadMountedDisplayManager mHMDManager;
+ private HeadTracker mHeadTracker;
+ private long mVrDevicePtr;
+
+ @CalledByNative
+ private static CardboardVRDevice create(Context context, long vrDevicePtr) {
+ return new CardboardVRDevice(context, vrDevicePtr);
+ }
+
+ private CardboardVRDevice(Context context, long vrDevicePtr) {
+ mVrDevicePtr = vrDevicePtr;
+
+ mHMDManager = new HeadMountedDisplayManager(context);
+
+ mHeadTracker = HeadTracker.createFromContext(context);
+ mHeadTracker.setNeckModelEnabled(true);
+ mHeadTracker.startTracking();
+ }
+
+ @CalledByNative
+ private void getFieldOfView(float[] outFov) {
+ HeadMountedDisplay hmd = mHMDManager.getHeadMountedDisplay();
+ CardboardDeviceParams deviceParams = hmd.getCardboardDeviceParams();
+ FieldOfView fov = deviceParams.getLeftEyeMaxFov();
+ outFov[0] = fov.getTop();
+ outFov[1] = fov.getBottom();
+ outFov[2] = fov.getLeft();
+ outFov[3] = fov.getRight();
+ }
+
+ @CalledByNative
+ private float getIPD() {
+ HeadMountedDisplay hmd = mHMDManager.getHeadMountedDisplay();
+ CardboardDeviceParams deviceParams = hmd.getCardboardDeviceParams();
+ return deviceParams.getInterLensDistance();
+ }
+
+ @CalledByNative
+ private String getDeviceName() {
+ HeadMountedDisplay hmd = mHMDManager.getHeadMountedDisplay();
+ CardboardDeviceParams deviceParams = hmd.getCardboardDeviceParams();
+ return deviceParams.getVendor() + " " + deviceParams.getModel();
+ }
+
+ @CalledByNative
+ private void getScreenSize(int[] outSize) {
+ HeadMountedDisplay hmd = mHMDManager.getHeadMountedDisplay();
+ ScreenParams screenParams = hmd.getScreenParams();
+ outSize[0] = screenParams.getWidth();
+ outSize[1] = screenParams.getHeight();
+ }
+
+ @CalledByNative
+ private void getSensorState(float[] outMatrix) {
+ mHeadTracker.getLastHeadView(outMatrix, 0);
+ }
+
+ @CalledByNative
+ private void stopTracking() {
+ mHeadTracker.stopTracking();
+ }
+
+ @CalledByNative
+ private void resetSensor() {
+ mHeadTracker.resetTracker();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698