1. override
void beginFrame()

Pump the rendering pipeline to generate a frame.

This method is called by handleBeginFrame, which itself is called automatically by the engine when when it is time to lay out and paint a frame.

Each frame consists of the following phases:

  1. The animation phase: The handleBeginFrame method, which is registeredwith ui.window.onBeginFrame, invokes all the transient frame callbacksregistered with scheduleFrameCallback and addFrameCallback, inregistration order. This includes all the Ticker instances that aredriving AnimationController objects, which means all of the activeAnimation objects tick at this point.

handleBeginFrame then invokes all the persistent frame callbacks, of which the most notable is this method, beginFrame, which proceeds as follows:

  1. The layout phase: All the dirty RenderObjects in the system are laidout (see RenderObject.performLayout). See RenderObject.markNeedsLayoutfor further details on marking an object dirty for layout.

  2. The compositing bits phase: The compositing bits on any dirtyRenderObject objects are updated. SeeRenderObject.markNeedsCompositingBitsUpdate.

  3. The paint phase: All the dirty RenderObjects in the system arerepainted (see RenderObject.paint). This generates the Layer tree. SeeRenderObject.markNeedsPaint for further details on marking an objectdirty for paint.

  4. The compositing phase: The layer tree is turned into a ui.Scene andsent to the GPU.

  5. The semantics phase: All the dirty RenderObjects in the system havetheir semantics updated (see RenderObject.SemanticsAnnotator). Thisgenerates the SemanticsNode tree. SeeRenderObject.markNeedsSemanticsUpdate for further details on marking anobject dirty for semantics.

For more details on steps 2-6, see PipelineOwner.

  1. The finalization phase: After beginFrame returns, handleBeginFramethen invokes post-frame callbacks (registered with addPostFrameCallback.

Some bindings (for example, the WidgetsBinding) add extra steps to this list (for example, see WidgetsBinding.beginFrame).

Source

@override
void beginFrame() {
  assert(inTest);
  try {
    debugBuildingDirtyElements = true;
    buildOwner.buildScope(renderViewElement);
    if (_phase == EnginePhase.build)
      return;
    assert(renderView != null);
    pipelineOwner.flushLayout();
    if (_phase == EnginePhase.layout)
      return;
    pipelineOwner.flushCompositingBits();
    if (_phase == EnginePhase.compositingBits)
      return;
    pipelineOwner.flushPaint();
    if (_phase == EnginePhase.paint)
      return;
    renderView.compositeFrame(); // this sends the bits to the GPU
    if (_phase == EnginePhase.composite)
      return;
    pipelineOwner.flushSemantics();
    if (_phase == EnginePhase.flushSemantics)
      return;
  } finally {
    buildOwner.finalizeTree();
    debugBuildingDirtyElements = false;
  }
}