beginFrame method

void beginFrame()

Call this at the start of each frame (before render).

Implementation

void beginFrame() {
  final nowMicros = _clock.elapsedMicroseconds;
  final lastFrame = _lastFrameElapsedMicros;
  if (!metricsOnlyFrame && lastFrame != null) {
    _frameTimesMicros[_frameTimeIndex] = nowMicros - lastFrame;
    _frameTimeIndex = (_frameTimeIndex + 1) % _sampleSize;
    _frameTimeCount++;
  }
  // Only update the baseline timestamp for real frames so that the next
  // real frame measures the gap from the previous real frame, not from
  // the metrics-only render.
  if (!metricsOnlyFrame) {
    _lastFrameElapsedMicros = nowMicros;
  }

  _renderStopwatch
    ..reset()
    ..start();
}