-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Description
When performing many calls to drawPath, the performance suffers. This is especially evident on lower end devices. The attached example demonstrates:
- Looping through paths and drawing using Canvas.drawPath
- Looping through paths and drawing using Canvas.drawVertices
- One batched draw using Canvas.drawVertices
It should be noted this demonstration creates almost the maximum amount of paths that could be drawn with one batch call (max vertex index 65,535). One could expand this demonstration to perform numerous drawVertices calls when the vertex index overflows.
Another thing to keep in mind is a facility to draw many paths in one call should allow the user to provide n paints so each path can still be drawn with its own style - this may require creating a texture atlas that drawVertices can reference.
Finally, this optimization may only benefit an immutable collection of paths. For dynamically changing paths, the allocation and upload to the GPU of large vertex data each frame may become non-performant, but this could be verified through tests.