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

Side by Side Diff: device/vr/android/java/src/org/chromium/device/vr/GvrDeviceProvider.java

Issue 2219203002: Migrate WebVR Cardboard implementation to GVR (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gvr_third_party
Patch Set: Disabling WebVR on non-component builds Created 4 years, 4 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.device.vr;
6
7 import android.content.Context;
8
9 import com.google.vr.ndk.base.GvrLayout;
10
11 import org.chromium.base.annotations.CalledByNative;
12 import org.chromium.base.annotations.JNINamespace;
13
14 /**
15 * This is the implementation of the C++ counterpart GvrDeviceProvider.
16 */
17 @JNINamespace("device")
18 class GvrDeviceProvider {
19 private static final String TAG = "GvrDeviceProvider";
20 private final GvrLayout mLayout;
21 private Thread mGvrInitThread;
22
23 private GvrDeviceProvider(Context context) {
24 mLayout = new GvrLayout(context);
25
26 // Initialize the GVR API on a separate thread to avoid strict mode
27 // violations. Note that this doesn't fix the underlying issue of
28 // blocking on disk reads here.
29 mGvrInitThread = new Thread(new Runnable() {
30 @Override
31 public void run() {
32 mLayout.getGvrApi();
33 }
34 });
35 mGvrInitThread.start();
36 }
37
38 @CalledByNative
39 private static GvrDeviceProvider create(Context context) {
40 return new GvrDeviceProvider(context);
41 }
42
43 @CalledByNative
44 private long getNativeContext() {
45 try {
46 mGvrInitThread.join();
47 } catch (Exception ex) {
48 }
49 return mLayout.getGvrApi().getNativeGvrContext();
50 }
51
52 @CalledByNative
53 private void shutdown() {
54 mLayout.shutdown();
55 }
56 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698