android.view.Choreographer#FrameCallback ( )源码实例Demo

下面列出了android.view.Choreographer#FrameCallback ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: libcommon   文件: GLManager.java
/**
 * GLコンテキスト上で実行されるChoreographer.FrameCallbackをpostする
 * @param callback
 * @param delayMs
 * @throws IllegalStateException
 */
public synchronized void postFrameCallbackDelayed(
	@NonNull final Choreographer.FrameCallback callback,
	final long delayMs) throws IllegalStateException {

	if (DEBUG) Log.v(TAG, "postFrameCallbackDelayed:");
	checkValid();
	if (isGLThread()) {
		// すでにGLスレッド上であれば直接実行
		Choreographer.getInstance().postFrameCallbackDelayed(callback, delayMs);
	} else {
		// 別スレッド上にいるならGLスレッド上へ投げる
		mGLHandler.post(new Runnable() {
			@Override
			public void run() {
				Choreographer.getInstance().postFrameCallbackDelayed(callback, delayMs);
			}
		});
	}
}
 
源代码2 项目: libcommon   文件: GLManager.java
/**
 * 未実行のChoreographer.FrameCallbackがあれば取り除く
 * @param callback
 * @throws IllegalStateException
 */
public synchronized void removeFrameCallback(
	@NonNull final Choreographer.FrameCallback callback)
		throws IllegalStateException {

	if (DEBUG) Log.v(TAG, "removeFrameCallback:");
	checkValid();
	if (isGLThread()) {
		// すでにGLスレッド上であれば直接実行
		Choreographer.getInstance().removeFrameCallback(callback);
	} else {
		// 別スレッド上にいるならGLスレッド上へ投げる
		mGLHandler.post(new Runnable() {
			@Override
			public void run() {
				Choreographer.getInstance().removeFrameCallback(callback);
			}
		});
	}
}
 
源代码3 项目: 365browser   文件: VSyncMonitor.java
/**
 * Constructs a VSyncMonitor
 * @param context The application context.
 * @param listener The listener receiving VSync notifications.
 */
public VSyncMonitor(Context context, VSyncMonitor.Listener listener) {
    mListener = listener;
    float refreshRate = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE))
            .getDefaultDisplay().getRefreshRate();
    final boolean useEstimatedRefreshPeriod = refreshRate < 30;

    if (refreshRate <= 0) refreshRate = 60;
    mRefreshPeriodNano = (long) (NANOSECONDS_PER_SECOND / refreshRate);

    mChoreographer = Choreographer.getInstance();
    mVSyncFrameCallback = new Choreographer.FrameCallback() {
        @Override
        public void doFrame(long frameTimeNanos) {
            TraceEvent.begin("VSync");
            if (useEstimatedRefreshPeriod && mConsecutiveVSync) {
                // Display.getRefreshRate() is unreliable on some platforms.
                // Adjust refresh period- initial value is based on Display.getRefreshRate()
                // after that it asymptotically approaches the real value.
                long lastRefreshDurationNano = frameTimeNanos - mGoodStartingPointNano;
                float lastRefreshDurationWeight = 0.1f;
                mRefreshPeriodNano += (long) (lastRefreshDurationWeight
                        * (lastRefreshDurationNano - mRefreshPeriodNano));
            }
            mGoodStartingPointNano = frameTimeNanos;
            onVSyncCallback(frameTimeNanos, getCurrentNanoTime());
            TraceEvent.end("VSync");
        }
    };
    mGoodStartingPointNano = getCurrentNanoTime();
}
 
源代码4 项目: react-native-GPay   文件: ChoreographerCompat.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
Choreographer.FrameCallback getFrameCallback() {
  if (mFrameCallback == null) {
    mFrameCallback = new Choreographer.FrameCallback() {
      @Override
      public void doFrame(long frameTimeNanos) {
        FrameCallback.this.doFrame(frameTimeNanos);
      }
    };
  }
  return mFrameCallback;
}
 
源代码5 项目: litho   文件: ChoreographerCompat.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
Choreographer.FrameCallback getFrameCallback() {
  if (mFrameCallback == null) {
    mFrameCallback =
        new Choreographer.FrameCallback() {
          @Override
          public void doFrame(long frameTimeNanos) {
            ChoreographerCompat.FrameCallback.this.doFrameInternal(frameTimeNanos);
          }
        };
  }
  return mFrameCallback;
}
 
public ChoreographerAndroidSpringLooper(Choreographer choreographer) {
  mChoreographer = choreographer;
  mFrameCallback = new Choreographer.FrameCallback() {
    @Override
    public void doFrame(long frameTimeNanos) {
      if (!mStarted || mSpringSystem == null) {
        return;
      }
      long currentTime = SystemClock.uptimeMillis();
      mSpringSystem.loop(currentTime - mLastTime);
      mLastTime = currentTime;
      mChoreographer.postFrameCallback(mFrameCallback);
    }
  };
}
 
源代码7 项目: Conquer   文件: AndroidSpringLooperFactory.java
public ChoreographerAndroidSpringLooper(Choreographer choreographer) {
	mChoreographer = choreographer;
	mFrameCallback = new Choreographer.FrameCallback() {
		@Override
		public void doFrame(long frameTimeNanos) {
			if (!mStarted || mSpringSystem == null) {
				return;
			}
			long currentTime = SystemClock.uptimeMillis();
			mSpringSystem.loop(currentTime - mLastTime);
			mLastTime = currentTime;
			mChoreographer.postFrameCallback(mFrameCallback);
		}
	};
}
 
public ChoreographerAndroidSpringLooper(Choreographer choreographer) {
  mChoreographer = choreographer;
  mFrameCallback = new Choreographer.FrameCallback() {
    @Override
    public void doFrame(long frameTimeNanos) {
      if (!mStarted || mSpringSystem == null) {
        return;
      }
      mSpringSystem.loop();
      mChoreographer.postFrameCallback(mFrameCallback);
    }
  };
}
 
public ChoreographerAndroidSpringLooper(Choreographer choreographer) {
  mChoreographer = choreographer;
  mFrameCallback = new Choreographer.FrameCallback() {
    @Override
    public void doFrame(long frameTimeNanos) {
      if (!mStarted || mSpringSystem == null) {
        return;
      }
      mSpringSystem.loop();
      mChoreographer.postFrameCallback(mFrameCallback);
    }
  };
}
 
源代码10 项目: Viewer   文件: AndroidSpringLooperFactory.java
public ChoreographerAndroidSpringLooper(Choreographer choreographer) {
  mChoreographer = choreographer;
  mFrameCallback = new Choreographer.FrameCallback() {
    @Override
    public void doFrame(long frameTimeNanos) {
      if (!mStarted || mSpringSystem == null) {
        return;
      }
      long currentTime = SystemClock.uptimeMillis();
      mSpringSystem.loop(currentTime - mLastTime);
      mLastTime = currentTime;
      mChoreographer.postFrameCallback(mFrameCallback);
    }
  };
}
 
源代码11 项目: android_9.0.0_r45   文件: AnimationHandler.java
@Override
public void postFrameCallback(Choreographer.FrameCallback callback) {
    mChoreographer.postFrameCallback(callback);
}
 
源代码12 项目: react-native-GPay   文件: ChoreographerCompat.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void choreographerPostFrameCallback(Choreographer.FrameCallback frameCallback) {
  mChoreographer.postFrameCallback(frameCallback);
}
 
源代码13 项目: react-native-GPay   文件: ChoreographerCompat.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void choreographerPostFrameCallbackDelayed(
  Choreographer.FrameCallback frameCallback,
  long delayMillis) {
  mChoreographer.postFrameCallbackDelayed(frameCallback, delayMillis);
}
 
源代码14 项目: litho   文件: ChoreographerCompatImpl.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void choreographerPostFrameCallback(Choreographer.FrameCallback frameCallback) {
  mChoreographer.postFrameCallback(frameCallback);
}
 
源代码15 项目: litho   文件: ChoreographerCompatImpl.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void choreographerPostFrameCallbackDelayed(
    Choreographer.FrameCallback frameCallback, long delayMillis) {
  mChoreographer.postFrameCallbackDelayed(frameCallback, delayMillis);
}
 
源代码16 项目: litho   文件: ChoreographerCompatImpl.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void choreographerRemoveFrameCallback(Choreographer.FrameCallback frameCallback) {
  mChoreographer.removeFrameCallback(frameCallback);
}
 
源代码17 项目: StackCardsView   文件: ChoreographerCompat.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void choreographerPostFrameCallback(Choreographer.FrameCallback frameCallback) {
  mChoreographer.postFrameCallback(frameCallback);
}
 
源代码18 项目: StackCardsView   文件: ChoreographerCompat.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void choreographerRemoveFrameCallback(Choreographer.FrameCallback frameCallback) {
  mChoreographer.removeFrameCallback(frameCallback);
}
 
源代码19 项目: CircularReveal   文件: AnimationHandler.java
@Override
public void postFrameCallback(Choreographer.FrameCallback callback) {
  mChoreographer.postFrameCallback(callback);
}
 
源代码20 项目: CircularReveal   文件: AnimationHandler.java
void postFrameCallback(Choreographer.FrameCallback callback);