Jonah Williams 709848e589 [Impeller] grow glyph atlas instead of resizing when rect packer is full. (flutter/engine#52849)
Fixes https://github.com/flutter/flutter/issues/138798

As far as I can tell, this gets us about as good as Skia, modulo the actual cost of rasterizing one of these glyphs is much more expensive for us.

The basic strategy is:

1. If the existing atlas texture has room (defined by the rect packer addRect call succeeding) append as many glyphs as we can to the old texture.
2. Check if there were any remaining glyphs. If not return.
3. Otherwise, double the size of the texture and create a new rect packer that represents only the increased area. So for example if you doubled a 100x100 texture to 100x200, then you'd create another 100x100 rect packer, assuming the old one is full.
4. Grow this size until all remaining glyphs fit. Store the new rect packer and the "height adjustment", which basically tells you where along the y-axis the rect packer offset starts.
5. Allocate this new texture, clear it, and then blit the contents of the old texture into the top left corner. Append all additional glyphs. The allows us to recycle all previously rendered glyphs and keep them in the texture, reducing the amount of software rasterization per frame.
6. Note; if the max atlas size would be exceeded, throw it away and start again.
2024-05-17 02:20:21 +00:00
..