pushTransform method
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 painting done bypainter
.painter
is a callback that will paint with thetransform
applied. This function calls thepainter
synchronously.
Implementation
void pushTransform(bool needsCompositing, Offset offset, Matrix4 transform, PaintingContextCallback painter) {
final Matrix4 effectiveTransform = Matrix4.translationValues(offset.dx, offset.dy, 0.0)
..multiply(transform)..translate(-offset.dx, -offset.dy);
if (needsCompositing) {
pushLayer(
TransformLayer(transform: effectiveTransform),
painter,
offset,
childPaintBounds: MatrixUtils.inverseTransformRect(effectiveTransform, estimatedBounds),
);
} else {
canvas
..save()
..transform(effectiveTransform.storage);
painter(this, offset);
canvas
..restore();
}
}