Drawing paths and hardware acceleration

前端 未结 3 814
孤城傲影
孤城傲影 2020-12-07 11:12

I\'m drawing a rather large path in my view and I\'m running into some performance problems. The path is currently 32,000 points long, but my application should scale to at

3条回答
  •  借酒劲吻你
    2020-12-07 11:54

    Is drawing lines/paths just something the GPU is bad at and that one should not try to hardware accelerate, or am I likely doing something wrong that causes the bad performance?

    Paths are always rendered using the CPU. When the app is hardware accelerated this means the renderer will first draw your path using the CPU into a bitmap, then upload that bitmap as a texture to the GPU and finally draw the texture on screen.

    Lines are entirely hardware accelerated. Instead of using a Path I recommend you use Canvas.drawLines() in this case.

    Is there anything I can do to draw such huge paths with acceptable performance?

    You should either use Canvas.drawLines() or render the path yourself into a Bitmap that you manage.

提交回复
热议问题