Drawing paths and hardware acceleration

前端 未结 3 819
孤城傲影
孤城傲影 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 12:04

    Drawing a path will involve more than just "telling" the GPU to draw lines. A path has many characteristics, for example how ends of lines are treated or that a line is dotted, something that is not GPU accelerated. There is probably then another hickup when you encounter that many lines that makes the combination of CPU and GPU acceleration go slower. The suggested solution above to move to canvas.drawLines instead of canvs.drawPath and try to not use a fancy Paint method might help.

    If that does not help you can try to use a GLSurfaceView and render lines directly into that instead. That will involve some OpenGL ES knowledge, but should not be incredibly hard to do and might be a lot more effective.

提交回复
热议问题