W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2014

[whatwg] new constructor method for Path2D

From: Rik Cabanier <cabanier@gmail.com>
Date: Wed, 5 Mar 2014 13:46:40 -0800
Message-ID: <CAGN7qDAGUVf5HxtnfYvdcuKtyw+-E+qLspJWtABzCU0RHDiy_Q@mail.gmail.com>
To: "whatwg@whatwg.org" <whatwg@whatwg.org>
While implementing the Path2D object in mozilla, we ran into a performance
issue.

The mozilla implementation uses different "backends" for the canvas 2D
context.
Even within the same document, different canvas objects can be on top of
different graphics libraries. For best performance, the Path2D object
should use the same graphics interface as the canvas context you're
applying it to. If this is not the case, the path segments have to be
walked and converted which is a costly operation.

To work around this, we could add a couple of constructor methods to the 2D
context:

Path2D createPath();

Creates a new empty Path object.

Path2D createPath(path);

Creates a new Path object that is a copy of the argument.

Path2D createPath(d);

Creates a new path with the path described by the argument, interpreted as
SVG path data. [SVG]

This way, we can guarantee that they use the same underlying technology and
performance won't be impacted.
You could still pass these objects to other canvas contexts but performance
might be impacted.
Received on Wednesday, 5 March 2014 21:47:07 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:17 UTC