Java 类android.view.Choreographer.FrameCallback 实例源码

项目:365browser    文件:VrShellDelegate.java   
private VrShellDelegate(ChromeActivity activity, VrClassesWrapper wrapper) {
    mActivity = activity;
    mVrClassesWrapper = wrapper;
    // If an activity isn't resumed at the point, it must have been paused.
    mPaused = ApplicationStatus.getStateForActivity(activity) != ActivityState.RESUMED;
    updateVrSupportLevel();
    mNativeVrShellDelegate = nativeInit();
    mFeedbackFrequency = VrFeedbackStatus.getFeedbackFrequency();
    mEnterVrHandler = new Handler();
    Choreographer.getInstance().postFrameCallback(new FrameCallback() {
        @Override
        public void doFrame(long frameTimeNanos) {
            if (mNativeVrShellDelegate == 0) return;
            Display display =
                    ((WindowManager) mActivity.getSystemService(Context.WINDOW_SERVICE))
                            .getDefaultDisplay();
            nativeUpdateVSyncInterval(
                    mNativeVrShellDelegate, frameTimeNanos, 1.0d / display.getRefreshRate());
        }
    });
    ApplicationStatus.registerStateListenerForAllActivities(this);
}