Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Canvas.drawPath() so slow?

I encoutered that using Canvas.drawPath(path,paint) is significantly slower than Canvas.drawLine() in a row or using Canvas.drawLines() instead. I can't give exact performance data, but I noticed on a Nexus 10 that the drawing was really slow (<10 FPS) by using path, while using drawLines was much smoother. Is there some implementation wrong or maybe a parameter to speed up the performance of this? As of now, I can't use drawPath() at all since the performance is such weak.

like image 314
TSGames Avatar asked May 27 '13 16:05

TSGames


1 Answers

I was having an issue with drawPath as well (especially on my Nexus 10). My issue came down to I was setting a

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

which made the performance horrible. 45 milliseconds execution to for Canvas.drawPath. Once I removed it I was getting execution times between 2-4 milliseconds

like image 139
whizzle Avatar answered Nov 07 '22 23:11

whizzle