Why is Canvas.drawPath () so slow?

I argued that using Canvas.drawPath (path, paint) is much slower than Canvas.drawLine () in a line or instead of Canvas.drawLines (). I cannot give exact performance data, but I noticed on Nexus 10 that the drawing was very slow (<10 FPS) using the path, while using drawLines was much smoother. Is there some kind of implementation that is wrong or perhaps a parameter to speed up the execution of this? At the moment, I can not use drawPath () at all, since the performance is so poor.

+4
source share
2 answers

Sorry, I can’t leave a comment. drawPath () makes a lot more extra calls. A path is an object, not an array. You can even imagine all the extra calls that are made. This is a necessary Paint method. This is not good for fast multi-line drawing. It is more suitable for painting.

0
source

I had a problem with drawPath (especially on my Nexus 10). My problem was that I installed

strokePaint.setMaskFilter(new BlurMaskFilter(16f, BlurMaskFilter.Blur.NORMAL)); 

what made the job terrible. Running 45 milliseconds for Canvas.drawPath. As soon as I deleted it, I got a runtime between 2-4 milliseconds

+1
source

Source: https://habr.com/ru/post/1482997/


All Articles