void pushTransform(bool needsCompositing, Offset offset, Matrix4 transform, PaintingContextCallback painter)

Transform further painting using a matrix.

  • needsCompositing is whether the child needs compositing. Typically matches the value of RenderObject.needsCompositing for the caller.
  • offset is the offset from the origin of the canvas' coordinate system to the origin of the caller's coordinate system.
  • transform is the matrix to apply to the paiting done by painter.
  • painter is a callback that will paint with the transform applied. This function calls the painter synchronously.

Source

void pushTransform(bool needsCompositing, Offset offset, Matrix4 transform, PaintingContextCallback painter) {
  final Matrix4 effectiveTransform = new Matrix4.translationValues(offset.dx, offset.dy, 0.0)
    ..multiply(transform)..translate(-offset.dx, -offset.dy);
  if (needsCompositing) {
    _stopRecordingIfNeeded();
    final TransformLayer transformLayer = new TransformLayer(transform: effectiveTransform);
    _appendLayer(transformLayer);
    final Rect transformedPaintBounds = MatrixUtils.inverseTransformRect(_paintBounds, effectiveTransform);
    final PaintingContext childContext = new PaintingContext._(transformLayer, transformedPaintBounds);
    painter(childContext, offset);
    childContext._stopRecordingIfNeeded();
  } else {
    canvas.save();
    canvas.transform(effectiveTransform.storage);
    painter(this, offset);
    canvas.restore();
  }
}