Fast text for immediate mode GUI

26 views
Skip to first unread message

ピックスフォルジュ

unread,
Jul 10, 2022, 7:04:43 AMJul 10
to skia-discuss
Currently I'm writing an immediate mode GUI for personal projects that need a GUI, and it draws everything, including hinted glyphs from FreeType for text, using Skia. (I'm not using Skia's actual text features because I do not wish to use HarfBuzz and I want to access FreeType directly anyways)

I currently redraw every glyph as an SkPath every frame, and so far with any non-unreasonable amount of text on the screen, I don't encounter any performance issues (nvidia-smi reports very low utilization) even when I'm rendering CJK text at large sizes. I assume that's the case because Skia is internally using a signed distance field representation for small enough paths to cope for repetitive drawing (some people have mentioned it in a few other Google Groups conversations.)

I have tried writing my own texture atlas of some kind that would store all the glyphs I would use at 4x scale in the X axis (for good horizontal anti-aliasing), and when drawing each glyph I would use a shader that downsampled the overscale glyph back to normal. The results looked very good and was close enough to just drawing the path normally, but it also had bugs and couldn't dynamically cope with different text sizes.

I have a few questions to ask, since I'm not aware of how Skia internally handles repetitive drawing of paths:
- How far can I go by just relying on how Skia caches and uses signed distance fields internally? How large of a bounding box can a SkPath have, and how much larger/smaller can I scale it before Skia starts refusing to cache it for rendering?
- Can these caching limits be configured if I wanted to?
- If I ultimately had to write my own atlas, or somehow need to quickly render a small number of larger glyphs in the run, is there a way for me to access Skia's internal signed distance field rendering routines for my own use?
- What is a good way to actually profile GPU usage for Skia? (I'm using Linux if that matters)

Much thanks in advance.
Reply all
Reply to author
Forward
0 new messages