本文整理汇总了Java中android.view.Choreographer类的典型用法代码示例。如果您正苦于以下问题:Java Choreographer类的具体用法?Java Choreographer怎么用?Java Choreographer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Choreographer类属于android.view包,在下文中一共展示了Choreographer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BlockFrameCallback
import android.view.Choreographer; //导入依赖的package包/类
BlockFrameCallback() {
try {
//获取系统属性:丢失的帧数阈值
int skipFrame = (int) MethodUtils
.invokeStaticMethod(Class.forName("android.os.SystemProperties"), "getInt",
"debug.choreographer.skipwarning", DEFAULT_FRAME_SKIP_WARNING);
//获取设备每帧的时间间隔,单位ns
long frameIntervalNs =
(long) FieldUtils.readField(Choreographer.getInstance(), "mFrameIntervalNanos");
warningFrameMs = (int) (frameIntervalNs * skipFrame) / 1000000;
} catch (NoSuchMethodException | IllegalAccessException | ClassNotFoundException | InvocationTargetException e) {
e.printStackTrace();
warningFrameMs = 17 * DEFAULT_FRAME_SKIP_WARNING;
}
startWallClockTimeMs = System.currentTimeMillis();
startCpuTimeMs = SystemClock.currentThreadTimeMillis();
}
示例2: installLooperListener
import android.view.Choreographer; //导入依赖的package包/类
private void installLooperListener() {
//TODO 注意Looper的选择,是否考虑其他线程的looper
Looper.getMainLooper().setMessageLogging(looperListener);
try {
//获取系统属性:丢失的帧数阈值
int skipFrame = (int) MethodUtils
.invokeStaticMethod(Class.forName("android.os.SystemProperties"), "getInt",
"debug.choreographer.skipwarning", DEFAULT_FRAME_SKIP_WARNING);
//获取设备每帧的时间间隔,单位ns
long frameIntervalNs =
(long) FieldUtils.readField(Choreographer.getInstance(), "mFrameIntervalNanos");
warningFrameMs = (int) (frameIntervalNs * skipFrame / 1000000);
} catch (NoSuchMethodException | IllegalAccessException | ClassNotFoundException | InvocationTargetException e) {
e.printStackTrace();
warningFrameMs = 16 * DEFAULT_FRAME_SKIP_WARNING;
}
}
示例3: run
import android.view.Choreographer; //导入依赖的package包/类
@Override
public void run() {
setName("ChorRenderThread");
Looper.prepare();
mHandler = new Handler() {
public void handleMessage(Message msg) {
Log.d(TAG, "got message, quitting");
Looper.myLooper().quit();
}
};
Choreographer.getInstance().postFrameCallback(this);
Looper.loop();
Log.d(TAG, "looper quit");
Choreographer.getInstance().removeFrameCallback(this);
}
示例4: surfaceCreated
import android.view.Choreographer; //导入依赖的package包/类
@Override
public void surfaceCreated(SurfaceHolder holder) {
Log.d(TAG, "surfaceCreated holder=" + holder);
// If we already have a Surface, we just need to resume the frame notifications.
SurfaceView sv = (SurfaceView) findViewById(R.id.scheduledSwap_surfaceView);
mRenderThread = new RenderThread(sv.getHolder(), this);
mRenderThread.setName("ScheduledSwap GL render");
mRenderThread.start();
mRenderThread.waitUntilReady();
RenderHandler rh = mRenderThread.getHandler();
if (rh != null) {
rh.sendSetParameters(mUpdatePatternIndex, mFramesAheadIndex);
rh.sendSurfaceCreated();
}
// start the draw events
Choreographer.getInstance().postFrameCallback(this);
}
示例5: surfaceCreated
import android.view.Choreographer; //导入依赖的package包/类
@Override
public void surfaceCreated(SurfaceHolder holder) {
Log.d(TAG, "surfaceCreated holder=" + holder);
File outputFile = new File(getFilesDir(), "fbo-gl-recording.mp4");
SurfaceView sv = (SurfaceView) findViewById(R.id.fboActivity_surfaceView);
mRenderThread = new RenderThread(sv.getHolder(), new ActivityHandler(this), outputFile,
MiscUtils.getDisplayRefreshNsec(this));
mRenderThread.setName("RecordFBO GL render");
mRenderThread.start();
mRenderThread.waitUntilReady();
mRenderThread.setRecordMethod(mSelectedRecordMethod);
RenderHandler rh = mRenderThread.getHandler();
if (rh != null) {
rh.sendSurfaceCreated();
}
// start the draw events
Choreographer.getInstance().postFrameCallback(this);
}
示例6: startRecordingFps
import android.view.Choreographer; //导入依赖的package包/类
@ReactMethod
public void startRecordingFps() {
if (mCatalystSettings == null ||
!mCatalystSettings.isAnimationFpsDebugEnabled()) {
return;
}
if (mFrameCallback != null) {
throw new JSApplicationCausedNativeException("Already recording FPS!");
}
checkAPILevel();
mFrameCallback = new FpsDebugFrameCallback(
Choreographer.getInstance(),
getReactApplicationContext());
mFrameCallback.startAndRecordFpsAtEachFrame();
}
示例7: start
import android.view.Choreographer; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public void start(Activity activity) {
this.mActivity = activity;
threadStackSampler.start();
cpuSampler.start();
float refreshRate = mActivity.getWindowManager().getDefaultDisplay().getRefreshRate();
mFrameIntervalNanos = (long) (1000000000 / refreshRate);
if (this.monitor == null) {
this.monitor = new FrameMonitor();
}
isStop = false;
if (this.mActivity != null) {
this.mActivity.runOnUiThread(new Runnable() {
public void run() {
Choreographer.getInstance().postFrameCallback(ChoreographerAnalysis.this.monitor);
}
});
}
}
示例8: onCreate
import android.view.Choreographer; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button1 = (Button) findViewById(R.id.button1);
Button button2 = (Button) findViewById(R.id.button2);
Button button3 = (Button) findViewById(R.id.button3);
button1.setOnClickListener(this);
button2.setOnClickListener(this);
button3.setOnClickListener(this);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
Choreographer.getInstance().postFrameCallback(this);
}
startActivity(new Intent(this, SecondActivity.class));
}
示例9: doFrame
import android.view.Choreographer; //导入依赖的package包/类
@Override
public void doFrame(long frameTimeNanos) {
// Log.d(TAG, "frameTimeNanos = " + frameTimeNanos);
if (lastFrameTimeNanos == 0) {
lastFrameTimeNanos = frameTimeNanos;
Choreographer.getInstance().postFrameCallback(this);
return;
}
currentFrameTimeNanos = frameTimeNanos;
long value = (currentFrameTimeNanos - lastFrameTimeNanos) / 1000000;
// 大于16ms表示发生卡顿
if (value > 16) {
Log.d(TAG, "currentFrameTimeNanos - lastFrameTimeNanos = " + (currentFrameTimeNanos - lastFrameTimeNanos) / 1000000);
}
lastFrameTimeNanos = currentFrameTimeNanos;
Choreographer.getInstance().postFrameCallback(this);
}
示例10: WallpaperOffsetInterpolator
import android.view.Choreographer; //导入依赖的package包/类
public WallpaperOffsetInterpolator(Workspace workspace) {
mChoreographer = Choreographer.getInstance();
mInterpolator = new DecelerateInterpolator(1.5f);
mWorkspace = workspace;
mWallpaperManager = WallpaperManager.getInstance(workspace.getContext());
mIsRtl = Utilities.isRtl(workspace.getResources());
}
示例11: onPause
import android.view.Choreographer; //导入依赖的package包/类
@Override
protected void onPause() {
super.onPause();
// If the callback was posted, remove it. This stops the notifications. Ideally we
// would send a message to the thread letting it know, so when it wakes up it can
// reset its notion of when the previous Choreographer event arrived.
Log.d(TAG, "onPause unhooking choreographer");
Choreographer.getInstance().removeFrameCallback(this);
}
示例12: onResume
import android.view.Choreographer; //导入依赖的package包/类
@Override
protected void onResume() {
super.onResume();
// If we already have a Surface, we just need to resume the frame notifications.
if (mRenderThread != null) {
Log.d(TAG, "onResume re-hooking choreographer");
Choreographer.getInstance().postFrameCallback(this);
}
}
示例13: doFrame
import android.view.Choreographer; //导入依赖的package包/类
@Override
public void doFrame(long frameTimeNanos) {
RenderHandler rh = mRenderThread.getHandler();
if (rh != null) {
Choreographer.getInstance().postFrameCallback(this);
rh.sendDoFrame(frameTimeNanos);
}
}
示例14: doFrame
import android.view.Choreographer; //导入依赖的package包/类
/**
* Choreographer callback, called near vsync.
*/
@Override
public void doFrame(long frameTimeNanos) {
// The events should not start until the RenderThread is created, and should stop
// before it's nulled out.
RenderHandler rh = mRenderThread.getHandler();
if (rh != null) {
Choreographer.getInstance().postFrameCallback(this);
rh.sendDoFrame(frameTimeNanos);
}
}
示例15: onPause
import android.view.Choreographer; //导入依赖的package包/类
@Override
protected void onPause() {
super.onPause();
// TODO: we might want to stop recording here. As it is, we continue "recording",
// which is pretty boring since we're not outputting any frames (test this
// by blanking the screen with the power button).
// If the callback was posted, remove it. This stops the notifications. Ideally we
// would send a message to the thread letting it know, so when it wakes up it can
// reset its notion of when the previous Choreographer event arrived.
Log.d(TAG, "onPause unhooking choreographer");
Choreographer.getInstance().removeFrameCallback(this);
}