protected stopRecordingIfNeeded()

in packages/core/src/rendering/painting-context.ts [127:157]


  protected stopRecordingIfNeeded() {
    if (!this.isRecording) {
      return
    }

    const picture = this.recorder!.end()
    assert(() => {
      if (DebugFlags.paintLayerBounds) {
        const paint: Paint = {
          style: PaintStyle.stroke,
          strokeWidth: 1,
          color: '#FF9800',
        }

        // 如果没有提供预估边界,则使用 picture 的边界
        const estimatedBounds = Rect.isEmpty(this.estimatedBounds) ? picture.cullRect : this.estimatedBounds
        this.canvas.drawRect(
          estimatedBounds.left,
          estimatedBounds.top,
          estimatedBounds.width,
          estimatedBounds.height,
          paint,
        )
      }
    })

    this.pictureLayer!.picture = picture
    this.pictureLayer = undefined
    this.recorder = undefined
    this._canvas = undefined
  }