Apply a mask derived from a shader to further painting.
offset
is the offset from the origin of the canvas' coordinate system to the origin of the caller's coordinate system.shader
is the shader that will generate the mask. The shader operates in the coordinate system of the caller.maskRect
is the region of the canvas (in the coodinate system of the caller) in which to apply the mask.transferMode
is the TransferMode to use when applying the shader to the painting done bypainter
.painter
is a callback that will paint with the mask applied. This function calls thepainter
synchronously.
A RenderObject that uses this function is very likely to require its RenderObject.alwaysNeedsCompositing property to return true. That informs ancestor render objects that this render object will include a composited layer, which causes them to use composited clips, for example.
Source
void pushShaderMask(Offset offset, Shader shader, Rect maskRect, TransferMode transferMode, PaintingContextCallback painter) { _stopRecordingIfNeeded(); final ShaderMaskLayer shaderLayer = new ShaderMaskLayer( shader: shader, maskRect: maskRect, transferMode: transferMode ); _appendLayer(shaderLayer); final PaintingContext childContext = new PaintingContext._(shaderLayer, _paintBounds); painter(childContext, offset); childContext._stopRecordingIfNeeded(); }