當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。