当前位置: 首页>>代码示例>>Java>>正文


Java Choreographer类代码示例

本文整理汇总了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();
}
 
开发者ID:zkwlx,项目名称:DroidTelescope,代码行数:18,代码来源:ChoreographerMonitor.java

示例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;
    }
}
 
开发者ID:zkwlx,项目名称:DroidTelescope,代码行数:18,代码来源:LooperMonitor.java

示例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);
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:19,代码来源:ChorTestActivity.java

示例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);
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:21,代码来源:ScheduledSwapActivity.java

示例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);
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:22,代码来源:RecordFBOActivity.java

示例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();
}
 
开发者ID:john1jan,项目名称:ReactNativeSignatureExample,代码行数:18,代码来源:AnimationsDebugModule.java

示例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);
            }
        });
    }
}
 
开发者ID:dodola,项目名称:blockindigo,代码行数:20,代码来源:ChoreographerAnalysis.java

示例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));
}
 
开发者ID:devilWwj,项目名称:Android-Tech,代码行数:19,代码来源:MainActivity.java

示例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);
    }
 
开发者ID:devilWwj,项目名称:Android-Tech,代码行数:19,代码来源:MainActivity.java

示例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());
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:9,代码来源:WallpaperOffsetInterpolator.java

示例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);
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:11,代码来源:HardwareScalerActivity.java

示例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);
    }
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:11,代码来源:HardwareScalerActivity.java

示例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);
    }
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:9,代码来源:HardwareScalerActivity.java

示例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);
    }
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:14,代码来源:ScheduledSwapActivity.java

示例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);
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:15,代码来源:RecordFBOActivity.java


注:本文中的android.view.Choreographer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。