rasterizeSubtree method

  1. @nonVirtual
  2. @protected
Image rasterizeSubtree()

One of the two methods that subclasses should invoke to render the what is considered the "subtree" of the post process.

Differently from renderSubtree, this method will rasterize the subtree to an image, which can be used as a texture in a shader. This is an expensive operation, so it should be used sparingly.

This method will set the context of the post process, so that components can know they are being rendered within a post process.

Implementation

@nonVirtual
@protected
ui.Image rasterizeSubtree() {
  final recorder = PictureRecorder();
  final innerCanvas = Canvas(recorder);

  renderSubtree(innerCanvas);

  final picture = recorder.endRecording();
  return picture.toImageSync(
    (pixelRatio * _size!.x).ceil(),
    (pixelRatio * _size!.y).ceil(),
  );
}