OLD | NEW |
(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 public long getNativeGvrContext() { |
| 29 long nativeGvrContext = 0; |
| 30 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); |
| 31 try { |
| 32 nativeGvrContext = mGvrLayout.getGvrApi().getNativeGvrContext(); |
| 33 } catch (Exception ex) { |
| 34 Log.e(TAG, "Unable to instantiate GvrApi", ex); |
| 35 return 0; |
| 36 } finally { |
| 37 StrictMode.setThreadPolicy(oldPolicy); |
| 38 } |
| 39 return nativeGvrContext; |
| 40 } |
| 41 |
| 42 public void resume() { |
| 43 mGvrLayout.onResume(); |
| 44 } |
| 45 |
| 46 public void pause() { |
| 47 mGvrLayout.onPause(); |
| 48 } |
| 49 |
| 50 public void shutdown() { |
| 51 mGvrLayout.shutdown(); |
| 52 } |
| 53 } |
OLD | NEW |