Skip to content

Canvas.drawPoints can be faster #10087

@abarth

Description

@abarth

Canvas.drawPoints takes a List<Offset>, which isn't the most efficient way to pack the data for the points. We already convert the List<Offset> to a Float32List before sending the data over to C++. We can make drawPoints faster by letting the caller supply the Float32List directly. The other advantage of this approach is that the caller can use the view feature of Float32List to draw subsets of the points without needing to reallocate the storage.

We have a couple options:

  1. Add a new drawPointsFoo method that takes a Float32List and keep the older, slower drawPoints that takes a List<Offset>.
  2. Break the API and change drawPoints to take a drawPoints.

In the future, we might be able to add back support for List<Offset> if Dart adds support for method overloading.

The purpose of this bug is to gather community feedback on these options. I believe this API is not widely used yet, which makes me think that option (2) is better, but I'm interested in your thoughts. Hopefully we'll be able to make a decision in about a week. Thanks!

Metadata

Metadata

Assignees

Labels

c: API breakBackwards-incompatible API changesc: performanceRelates to speed or footprint issues (see "perf:" labels)frameworkflutter/packages/flutter repository. See also f: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions