Closed MamiyaOtaru closed 4 years ago
I tried using cached brushes for the radar too, and it made no discernible difference. Using them for the font is likewise a tiny tiny difference if it makes one at all. The real savings is caching the layouts. So omitting the last commit should bring all of the performance improvements, while being a smaller change. On the other hand, the last one (caching the brushes) doesn't really hurt anything.
Hello, Thanks for the idea.
I've run a benchmark to compare the performance. I use the text in the Pilot Proving Ground for the test. Original method takes around 20.7597 ms to render. Layout caching takes around 7.1108 ms to render.
When there are a lot of text, there is a FPS drop with the DrawText
method, and there is a FPS gain with the DrawTextLayout
method.
instead of having drawText compute a layout for each and every char every frame, cache layouts for each char and use them in calling drawTextLayout. This doubles my FPS in text heavy views.