mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
719278bb36d46f2759e6db148559b6e4c11b7d10
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>
Gio - https://gioui.org
Immediate mode GUI programs in Go for Android, iOS, macOS, Linux, FreeBSD, OpenBSD, Windows, and WebAssembly (experimental).
Installation, examples, documentation
Go to gioui.org.
Issues
File bugs and TODOs through the issue tracker or send an email to ~eliasnaur/gio@todo.sr.ht. For general discussion, use the mailing list: ~eliasnaur/gio@lists.sr.ht.
Contributing
Post discussion to the mailing list and patches to gio-patches. No Sourcehut account is required and you can post without being subscribed.
See the contribution guide for more details.
An official GitHub mirror is available.
Description
Languages
Go
89.6%
C
7%
Java
1.7%
Objective-C
1.6%