forked from joejulian/gio
719278bb36
This commit unifies all widget text painting to use a single function and fixes two bugs that could result in visible glyphs failing to be painted. The first bug was that we checked whether a particular glyph's outline was visible within the viewport and terminated iteration the first time that we found a glyph that wasn't visible. If the very top of the next line of text was visible within the viewport, taller glyphs should be painted since part of them is visible. We would stop as soon as we got to a short glyph, preventing the rest of the line (and any tall glyphs it contained) from being painted. I fixed this first problem by using the ascent/descent of the line containing a glyph to determine whether it's "visible". While this will conclude that a small glyph is visible when it may be entirely off-screen, the net result will be that we will paint the entire line containing the glyph rather than constructing a special version of the line with only the tall glyphs. This has better path caching performance, as we don't need a bespoke path for when the line is partially visible. The second bug was that when the glyph iterator concluded that the current glyph was out of the viewport, we would immediately terminate the loop for painting glyphs without painting any buffered glyphs that had been determined to be visible. This second bug was easily fixed by ensuring that we always paint all buffered glyphs when terminating iteration. As part of this work, I pulled the (fairly complex) logic of buffering and painting glyphs into the glyph iterator so that label and editor can share a single implementation. I was unable to completely encapsulate the array storing buffered glyphs within the iterator without it being moved to the heap, so the current glyph iteration API requires the caller to juggle a slice of glyphs. Hopefully someone in the future can find a structure that the compiler's escape analysis understands. Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>