Java Code Examples for android.view.Choreographer

The following are top voted examples for showing how to use android.view.Choreographer. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: DroidTelescope   File: ChoreographerMonitor.java   View source code 6 votes vote down vote up
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();
}
 
Example 2
Project: DroidTelescope   File: LooperMonitor.java   View source code 6 votes vote down vote up
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;
    }
}
 
Example 3
Project: grafika   File: ChorTestActivity.java   View source code 6 votes vote down vote up
@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);
}
 
Example 4
Project: grafika   File: ScheduledSwapActivity.java   View source code 6 votes vote down vote up
@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);
}
 
Example 5
Project: grafika   File: RecordFBOActivity.java   View source code 6 votes vote down vote up
@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);
}
 
Example 6
Project: ReactNativeSignatureExample   File: AnimationsDebugModule.java   View source code 6 votes vote down vote up
@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();
}
 
Example 7
Project: blockindigo   File: ChoreographerAnalysis.java   View source code 6 votes vote down vote up
@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);
            }
        });
    }
}
 
Example 8
Project: react-native-ibeacon-android   File: AnimationsDebugModule.java   View source code 6 votes vote down vote up
@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();
}
 
Example 9
Project: Android-Tech   File: MainActivity.java   View source code 6 votes vote down vote up
@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));
}
 
Example 10
Project: Android-Tech   File: MainActivity.java   View source code 6 votes vote down vote up
@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);
    }
 
Example 11
Project: react-native-box-loaders   File: AnimationsDebugModule.java   View source code 6 votes vote down vote up
@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();
}
 
Example 12
Project: mediacodec   File: ChorTestActivity.java   View source code 6 votes vote down vote up
@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);
}
 
Example 13
Project: mediacodec   File: ScheduledSwapActivity.java   View source code 6 votes vote down vote up
@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);
}
 
Example 14
Project: mediacodec   File: RecordFBOActivity.java   View source code 6 votes vote down vote up
@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);
}
 
Example 15
Project: Ironman   File: AnimationsDebugModule.java   View source code 6 votes vote down vote up
@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();
}
 
Example 16
Project: LaunchEnr   File: WallpaperOffsetInterpolator.java   View source code 5 votes vote down vote up
public WallpaperOffsetInterpolator(Workspace workspace) {
    mChoreographer = Choreographer.getInstance();
    mInterpolator = new DecelerateInterpolator(1.5f);

    mWorkspace = workspace;
    mWallpaperManager = WallpaperManager.getInstance(workspace.getContext());
    mIsRtl = Utilities.isRtl(workspace.getResources());
}
 
Example 17
Project: grafika   File: HardwareScalerActivity.java   View source code 5 votes vote down vote up
@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);
}
 
Example 18
Project: grafika   File: HardwareScalerActivity.java   View source code 5 votes vote down vote up
@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);
    }
}
 
Example 19
Project: grafika   File: HardwareScalerActivity.java   View source code 5 votes vote down vote up
@Override
public void doFrame(long frameTimeNanos) {
    RenderHandler rh = mRenderThread.getHandler();
    if (rh != null) {
        Choreographer.getInstance().postFrameCallback(this);
        rh.sendDoFrame(frameTimeNanos);
    }
}
 
Example 20
Project: grafika   File: ScheduledSwapActivity.java   View source code 5 votes vote down vote up
@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);
}
 
Example 21
Project: grafika   File: ScheduledSwapActivity.java   View source code 5 votes vote down vote up
@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);
    }
}
 
Example 22
Project: grafika   File: ScheduledSwapActivity.java   View source code 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 23
Project: grafika   File: RecordFBOActivity.java   View source code 5 votes vote down vote up
@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);
}
 
Example 24
Project: grafika   File: RecordFBOActivity.java   View source code 5 votes vote down vote up
@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);
    }

    updateControls();
}
 
Example 25
Project: grafika   File: RecordFBOActivity.java   View source code 5 votes vote down vote up
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
    Log.d(TAG, "surfaceDestroyed holder=" + holder);

    // We need to wait for the render thread to shut down before continuing because we
    // don't want the Surface to disappear out from under it mid-render.  The frame
    // notifications will have been stopped back in onPause(), but there might have
    // been one in progress.
    //
    // TODO: the RenderThread doesn't currently wait for the encoder / muxer to stop,
    //       so we can't use this as an indication that the .mp4 file is complete.

    RenderHandler rh = mRenderThread.getHandler();
    if (rh != null) {
        rh.sendShutdown();
        try {
            mRenderThread.join();
        } catch (InterruptedException ie) {
            // not expected
            throw new RuntimeException("join was interrupted", ie);
        }
    }
    mRenderThread = null;
    mRecordingEnabled = false;

    // If the callback was posted, remove it.  Without this, we could get one more
    // call on doFrame().
    Choreographer.getInstance().removeFrameCallback(this);
    Log.d(TAG, "surfaceDestroyed complete");
}
 
Example 26
Project: grafika   File: RecordFBOActivity.java   View source code 5 votes vote down vote up
@Override
public void doFrame(long frameTimeNanos) {
    RenderHandler rh = mRenderThread.getHandler();
    if (rh != null) {
        Choreographer.getInstance().postFrameCallback(this);
        rh.sendDoFrame(frameTimeNanos);
    }
}
 
Example 27
Project: EditorImageAndText   File: AndroidSpringLooperFactory.java   View source code 5 votes vote down vote up
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);
    }
  };
}
 
Example 28
Project: FastTextView   File: FpsCalculator.java   View source code 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public void doFrame(long frameTimeNanos) {
	
	if (!mRunning) {
		return;
	}
          
          Choreographer.getInstance().postFrameCallback(frameCallback);

	atom.incrementAndGet();
}
 
Example 29
Project: FastTextView   File: FpsCalculator.java   View source code 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public void start() {
	Log.d(TAG, "start vsync detect");
	if (mRunning) {
		return;
	}
	
	mRunning = true;

	syncCheckThread = new Thread(new Runnable() {
		@Override
		public void run() {
			for (;;) {
				if (!mRunning) {
					break;
				}
				syncCheckThread();
			}
		}
	});
	syncCheckThread.start();
	
	Choreographer chor = Choreographer.getInstance();
	Field field;
	try {
		field = chor.getClass().getDeclaredField("mFrameIntervalNanos");
		field.setAccessible(true);
		mFrameIntervalNanos = field.getLong(chor);
		Log.d(TAG, "mFrameIntervalNanos " + mFrameIntervalNanos);
	} catch (Exception e) {
		Log.e(TAG, "error: " + e.getMessage());
	}
	chor.postFrameCallback(frameCallback);

}
 
Example 30
Project: StackCardsView   File: AndroidSpringLooperFactory.java   View source code 5 votes vote down vote up
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);
    }
  };
}
 
Example 31
Project: StackCardsView   File: ChoreographerCompat.java   View source code 5 votes vote down vote up
@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;
}
 
Example 32
Project: boohee_v5.6   File: ChoreographerCompat.java   View source code 5 votes vote down vote up
@TargetApi(16)
android.view.Choreographer.FrameCallback getFrameCallback() {
    if (this.mFrameCallback == null) {
        this.mFrameCallback = new android.view.Choreographer.FrameCallback() {
            public void doFrame(long frameTimeNanos) {
                FrameCallback.this.doFrame(frameTimeNanos);
            }
        };
    }
    return this.mFrameCallback;
}
 
Example 33
Project: Winter   File: Monitor.java   View source code 5 votes vote down vote up
@Override
        protected void onLooperPrepared() {
            mSampleChoreographer = Choreographer.getInstance();
            mSampleCallback = new Choreographer.FrameCallback() {
                @Override
                public void doFrame(final long frameTimeNanos) {
                    final long delta = (frameTimeNanos - lastSampleTime) / 1000000;
                    if (lastSampleTime != 0 && delta > delay) {
                        //采样周期不准了,目前丢弃吧
                        //LogUtils.w("monitor", "sample doFrame " + delta);
//                        mCheckerHandler.post(new Runnable() {
//                            @Override
//                            public void run() {
//                                processInfo(lastSampleTime / 1000000,frameTimeNanos / 1000000);
//                            }
//                        });
                    } else {
                        mCheckerHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                statisticsStack(frameTimeNanos / 1000000, delta, StackInfo.TYPE_SAMPLE);
                            }
                        });
                    }
                    lastSampleTime = frameTimeNanos;
                    if (mLoopFlag) {
                        mSampleChoreographer.postFrameCallback(mSampleCallback);
                    }
                }
            };

            lock[0] = true;

        }
 
Example 34
Project: FlickLauncher   File: WallpaperOffsetInterpolator.java   View source code 5 votes vote down vote up
public WallpaperOffsetInterpolator(Workspace workspace) {
    mChoreographer = Choreographer.getInstance();
    mInterpolator = new DecelerateInterpolator(1.5f);

    mWorkspace = workspace;
    mWallpaperManager = WallpaperManager.getInstance(workspace.getContext());
    mIsRtl = Utilities.isRtl(workspace.getResources());
}
 
Example 35
Project: RNLearn_Project1   File: ChoreographerCompat.java   View source code 5 votes vote down vote up
@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;
}
 
Example 36
Project: RNLearn_Project1   File: ChoreographerCompat.java   View source code 5 votes vote down vote up
@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;
}
 
Example 37
Project: SimpleUILauncher   File: WallpaperOffsetInterpolator.java   View source code 5 votes vote down vote up
public WallpaperOffsetInterpolator(Workspace workspace) {
    mChoreographer = Choreographer.getInstance();
    mInterpolator = new DecelerateInterpolator(1.5f);

    mWorkspace = workspace;
    mWallpaperManager = WallpaperManager.getInstance(workspace.getContext());
    mIsRtl = Utilities.isRtl(workspace.getResources());
}
 
Example 38
Project: android-openGL-canvas   File: GLThread.java   View source code 5 votes vote down vote up
@Override
public void doFrame(long frameTimeNanos) {
    if (glThread.getRenderMode() == RENDERMODE_CONTINUOUSLY) {
        canSwap = true;
        glThread.requestRender(frameTimeNanos);
        Choreographer.getInstance().postFrameCallback(this);
    }
}
 
Example 39
Project: ReactNativeSignatureExample   File: FpsView.java   View source code 5 votes vote down vote up
public FpsView(ReactContext reactContext) {
  super(reactContext);
  inflate(reactContext, R.layout.fps_view, this);
  mTextView = (TextView) findViewById(R.id.fps_text);
  mFrameCallback = new FpsDebugFrameCallback(Choreographer.getInstance(), reactContext);
  mFPSMonitorRunnable = new FPSMonitorRunnable();
  setCurrentFPS(0, 0, 0, 0);
}
 
Example 40
Project: ReactNativeSignatureExample   File: ReactChoreographer.java   View source code 5 votes vote down vote up
private ReactChoreographer() {
  mChoreographer = Choreographer.getInstance();
  mReactChoreographerDispatcher = new ReactChoreographerDispatcher();
  mCallbackQueues = new ArrayDeque[CallbackType.values().length];
  for (int i = 0; i < mCallbackQueues.length; i++) {
    mCallbackQueues[i] = new ArrayDeque<>();
  }
}