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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.vr_shell;
6
7 import android.app.Activity;
8 import android.os.StrictMode;
9
10 import com.google.vr.ndk.base.GvrLayout;
11
12 import org.chromium.base.Log;
13 import org.chromium.base.annotations.UsedByReflection;
14
15 /**
16 * Creates an active GvrContext from a detached GvrLayout. This is used by magic window mode.
17 */
18 @UsedByReflection("VrShellDelegate.java")
19 public class NonPresentingGvrContext implements NonPresentingGvrContextInterface {
20 private static final String TAG = "NPGvrContext";
21 private GvrLayout mGvrLayout;
22
23 @UsedByReflection("VrShellDelegate.java")
24 public NonPresentingGvrContext(Activity activity) {
25 mGvrLayout = new GvrLayout(activity);
26 }
27
28 @Override
29 public long getNativeGvrContext() {
30 long nativeGvrContext = 0;
31 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
32 try {
33 nativeGvrContext = mGvrLayout.getGvrApi().getNativeGvrContext();
34 } catch (Exception ex) {
35 Log.e(TAG, "Unable to instantiate GvrApi", ex);
36 return 0;
37 } finally {
38 StrictMode.setThreadPolicy(oldPolicy);
39 }
40 return nativeGvrContext;
41 }
42
43 @Override
44 public void resume() {
45 mGvrLayout.onResume();
46 }
47
48 @Override
49 public void pause() {
50 mGvrLayout.onPause();
51 }
52
53 @Override
54 public void shutdown() {
55 mGvrLayout.shutdown();
56 }
57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698