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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/vr_shell/NonPresentingGvrContext.java

Issue 2398103002: Enable magic window mode with new Gvr (Closed)
Patch Set: reviews Created 4 years, 2 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: chrome/android/java/src/org/chromium/chrome/browser/vr_shell/NonPresentingGvrContext.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/NonPresentingGvrContext.java b/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/NonPresentingGvrContext.java
new file mode 100644
index 0000000000000000000000000000000000000000..99f30f2f4319158454164eab9493e699b596329c
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/NonPresentingGvrContext.java
@@ -0,0 +1,57 @@
+// Copyright 2016 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.
+
+package org.chromium.chrome.browser.vr_shell;
+
+import android.app.Activity;
+import android.os.StrictMode;
+
+import com.google.vr.ndk.base.GvrLayout;
+
+import org.chromium.base.Log;
+import org.chromium.base.annotations.UsedByReflection;
+
+/**
+ * Creates an active GvrContext from a detached GvrLayout. This is used by magic window mode.
+ */
+@UsedByReflection("VrShellDelegate.java")
+public class NonPresentingGvrContext implements NonPresentingGvrContextInterface {
+ private static final String TAG = "NPGvrContext";
+ private GvrLayout mGvrLayout;
+
+ @UsedByReflection("VrShellDelegate.java")
+ public NonPresentingGvrContext(Activity activity) {
+ mGvrLayout = new GvrLayout(activity);
+ }
+
+ @Override
+ public long getNativeGvrContext() {
+ long nativeGvrContext = 0;
+ StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
+ try {
+ nativeGvrContext = mGvrLayout.getGvrApi().getNativeGvrContext();
+ } catch (Exception ex) {
+ Log.e(TAG, "Unable to instantiate GvrApi", ex);
+ return 0;
+ } finally {
+ StrictMode.setThreadPolicy(oldPolicy);
+ }
+ return nativeGvrContext;
+ }
+
+ @Override
+ public void resume() {
+ mGvrLayout.onResume();
+ }
+
+ @Override
+ public void pause() {
+ mGvrLayout.onPause();
+ }
+
+ @Override
+ public void shutdown() {
+ mGvrLayout.shutdown();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698