render method

void render(
  1. Canvas canvas, {
  2. BlendMode? blendMode,
  3. Rect? cullRect,
  4. Paint? paint,
})

Implementation

void render(
  Canvas canvas, {
  BlendMode? blendMode,
  Rect? cullRect,
  Paint? paint,
}) {
  if (isEmpty) {
    return;
  }

  final renderPaint = paint ?? _emptyPaint;

  if (useAtlas && !_flippedAtlasStatus.isGenerating) {
    canvas.drawAtlas(
      atlas,
      _transforms,
      _sources,
      _colors.isEmpty ? null : _colors,
      blendMode ?? defaultBlendMode,
      cullRect,
      renderPaint,
    );
  } else {
    for (final batchItem in _batchItems) {
      renderPaint.blendMode = blendMode ?? renderPaint.blendMode;

      canvas
        ..save()
        ..transform(batchItem.matrix.storage)
        ..drawRect(batchItem.destination, batchItem.paint)
        ..drawImageRect(
          atlas,
          batchItem.source,
          batchItem.destination,
          renderPaint,
        )
        ..restore();
    }
  }
}