-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Description
When we run out of room in an existing glyph cache atlas, as determined by the rectangle packing algorithm, we need to grow the atlas to continue accumulating glyphs. We do this by allocating a taller atlas and then copying the existing glyphs into the top part of the newly allocated cache texture. We then update our rectangle packing mechanism to fill glyphs into the newly allocated space here:
flutter/engine/src/flutter/impeller/typographer/backends/skia/typographer_context_skia.cc
Line 187 in f88f18c
| rect_packer = RectanglePacker::Factory( |
The issue seems to be that we create a brand new empty packer that only allocates glyphs into the newly allocated space. While we don't lose any glyphs in the existing part of the atlas, it may not have been full and so it has empty space we might still be able to use. But, by replacing the rectangle packer with a brand new one that only sees the new space, we never look back at the old space to see if we can continue to use it.
The comments suggest that there is no way to add width to the packer which is why it only grows the cache vertically. It also doesn't seem to be able to grow the rectangle arena vertically, which is probably why we replace it and only allocate in the new space. But, since the algorithm is in our own source tree and we control it, we can fix either problem and potentially make better use of our glyph cache space, reducing the number of times we grow or replace our glyph cache.