paintExportOf method

void paintExportOf(
  1. Canvas canvas,
  2. Size size,
  3. Image source
)

Apply this layer's crop transform to a different source image (instead of this.image). Used by ComposeEntry._composeLayers to compose tools as a pipeline: the source is first painted with strokes from the draw layer (in source-space), then THAT result is fed here for the geometric clip / rotate / flip. Matches telegram's pipeline (source → paint → crop) — strokes survive re-cropping because they're in source-space.

source must share dims with this.image so imageTransform and crop (both in image-space) map correctly.

Implementation

void paintExportOf(Canvas canvas, Size size, ui.Image source) {
  assert(
    source.width == image.width && source.height == image.height,
    'paintExportOf input must share dims with the layer source image',
  );
  canvas.save();
  canvas.translate(-crop.left, -crop.top);
  _paintCroppedImageWith(canvas, source, Paint(), imageTransform, 0);
  canvas.restore();
}