-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Currently Flutter has Picture.toImage returning Future<Image> (api docs). The API docs say "Although the image is returned synchronously, the picture is actually rasterized the first time the image is drawn and then cached". This makes me think that wrapping the result in a Future is redundant. Can we have a Picture.toImageSync that returns the image truly synchronously?
The use-case is procedurally generated atlasses that can be rendered using Canvas.drawAtlas. For example, to render particle effects, such as those generated by https://felixblaschke.github.io/liquid-studio, it is more efficient to use an atlas rather than many drawCircles with blurring mask filter. However, to generate the atlas one needs to call Picture.toImage and miss at least one frame. Picture.toImageSync would allow us to generate an atlas synchronously (and cheaply, since the atlas contains just one particle) and in the same frame render thousands of particles using drawAtlas.