OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.vr_shell; | 5 package org.chromium.chrome.browser.vr_shell; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.app.PendingIntent; | 8 import android.app.PendingIntent; |
9 import android.content.ComponentName; | 9 import android.content.ComponentName; |
10 import android.content.Context; | 10 import android.content.Context; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
152 mVrDaydreamApi.createVrIntent(new ComponentName(mActivity, V R_ACTIVITY_ALIAS)); | 152 mVrDaydreamApi.createVrIntent(new ComponentName(mActivity, V R_ACTIVITY_ALIAS)); |
153 } | 153 } |
154 mVrSupportLevel = mVrDaydreamApi.isDaydreamReadyDevice() ? VR_DAYDREAM : VR_CARDBOARD; | 154 mVrSupportLevel = mVrDaydreamApi.isDaydreamReadyDevice() ? VR_DAYDREAM : VR_CARDBOARD; |
155 } | 155 } |
156 | 156 |
157 /** | 157 /** |
158 * Should be called once the native library is loaded so that the native por tion of this class | 158 * Should be called once the native library is loaded so that the native por tion of this class |
159 * can be initialized. | 159 * can be initialized. |
160 */ | 160 */ |
161 public void onNativeLibraryReady() { | 161 public void onNativeLibraryReady() { |
162 mNativeVrShellDelegate = nativeInit(); | |
162 updateVrSupportLevel(); | 163 updateVrSupportLevel(); |
163 if (mVrSupportLevel == VR_NOT_AVAILABLE) return; | 164 if (mVrSupportLevel == VR_NOT_AVAILABLE) return; |
mthiesse
2017/02/21 15:56:18
What if we added a new VrSupportLevel for VR_DAYDR
amp
2017/02/21 19:50:03
Aside from limiting the creation of thenative VrSh
mthiesse
2017/02/21 20:23:00
Well one concern with this change is that now we'r
amp
2017/02/21 22:15:09
I don't think we do, at least not that I'm aware o
ddorwin
2017/02/23 23:23:32
I think something like `VR_[SDK_]NEEDS_UPDATE` wou
amp
2017/02/24 01:20:01
I think we can update the VR_SUPPORT_LEVEL to incl
| |
164 mNativeVrShellDelegate = nativeInit(); | |
165 Choreographer choreographer = Choreographer.getInstance(); | 165 Choreographer choreographer = Choreographer.getInstance(); |
166 choreographer.postFrameCallback(new FrameCallback() { | 166 choreographer.postFrameCallback(new FrameCallback() { |
167 @Override | 167 @Override |
168 public void doFrame(long frameTimeNanos) { | 168 public void doFrame(long frameTimeNanos) { |
169 Display display = ((WindowManager) mActivity.getSystemService( | 169 Display display = ((WindowManager) mActivity.getSystemService( |
170 Context.WINDOW_SERVICE)).getDefaultDisplay(); | 170 Context.WINDOW_SERVICE)).getDefaultDisplay(); |
171 nativeUpdateVSyncInterval(mNativeVrShellDelegate, frameTimeNanos , | 171 nativeUpdateVSyncInterval(mNativeVrShellDelegate, frameTimeNanos , |
172 1.0d / display.getRefreshRate()); | 172 1.0d / display.getRefreshRate()); |
173 } | 173 } |
174 }); | 174 }); |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
525 } | 525 } |
526 if (mRestoreOrientation != null) mActivity.setRequestedOrientation(mRest oreOrientation); | 526 if (mRestoreOrientation != null) mActivity.setRequestedOrientation(mRest oreOrientation); |
527 mRestoreOrientation = null; | 527 mRestoreOrientation = null; |
528 mVrShell.pause(); | 528 mVrShell.pause(); |
529 removeVrViews(); | 529 removeVrViews(); |
530 clearVrModeWindowFlags(); | 530 clearVrModeWindowFlags(); |
531 destroyVrShell(); | 531 destroyVrShell(); |
532 mActivity.getFullscreenManager().setPositionsForTabToNonFullscreen(); | 532 mActivity.getFullscreenManager().setPositionsForTabToNonFullscreen(); |
533 } | 533 } |
534 | 534 |
535 /** | |
536 * @return Whether VrCore exists and is up to date. | |
537 */ | |
538 @CalledByNative | |
mthiesse
2017/02/21 15:56:18
I think you would want to check for the support le
amp
2017/02/21 19:50:03
I could wire it up to be a bit more specific.
I'm
mthiesse
2017/02/21 20:23:00
I don't follow what a WebVR API Observer would loo
amp
2017/02/21 22:15:09
See comment above on not initializing native vr de
ddorwin
2017/02/23 23:23:31
My understanding of https://bugs.chromium.org/p/ch
amp
2017/02/24 01:20:01
Ok. I'll wait for the underlying lazy init parts
| |
535 private boolean isVrCoreCompatible() { | 539 private boolean isVrCoreCompatible() { |
536 assert mVrClassesWrapper != null; | 540 assert mVrClassesWrapper != null; |
537 if (mVrCoreVersionChecker == null) { | 541 if (mVrCoreVersionChecker == null) { |
538 mVrCoreVersionChecker = mVrClassesWrapper.createVrCoreVersionChecker (); | 542 mVrCoreVersionChecker = mVrClassesWrapper.createVrCoreVersionChecker (); |
539 } | 543 } |
540 | 544 |
541 return verifyOrUpdateVrServices( | 545 return verifyOrUpdateVrServices( |
542 mVrCoreVersionChecker.isVrCoreCompatible(), mActivity.getActivit yTab()); | 546 mVrCoreVersionChecker.isVrCoreCompatible(), mActivity.getActivit yTab()); |
543 } | 547 } |
544 | 548 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
695 } | 699 } |
696 | 700 |
697 private native long nativeInit(); | 701 private native long nativeInit(); |
698 private native void nativeSetPresentResult(long nativeVrShellDelegate, boole an result); | 702 private native void nativeSetPresentResult(long nativeVrShellDelegate, boole an result); |
699 private native void nativeDisplayActivate(long nativeVrShellDelegate); | 703 private native void nativeDisplayActivate(long nativeVrShellDelegate); |
700 private native void nativeUpdateVSyncInterval(long nativeVrShellDelegate, lo ng timebaseNanos, | 704 private native void nativeUpdateVSyncInterval(long nativeVrShellDelegate, lo ng timebaseNanos, |
701 double intervalSeconds); | 705 double intervalSeconds); |
702 private native void nativeOnPause(long nativeVrShellDelegate); | 706 private native void nativeOnPause(long nativeVrShellDelegate); |
703 private native void nativeOnResume(long nativeVrShellDelegate); | 707 private native void nativeOnResume(long nativeVrShellDelegate); |
704 } | 708 } |
OLD | NEW |