Re: [css-houdini-drafts] [css-paint-api] Consider making Path2D the only way to render paths with PaintRenderingContext2D.

We'll talk about this at the upcoming F2F in Tokyo.

My personal opinion here is that we shouldn't do this. When creating the PaintRC2D we tried to keep most of the APIs so that existing canvas rendering libraries can be dropped in and work by default. Almost all of these libraries use the CanvasPath api subset.

There are other ways to solve this:
1) Provide tooling to encourage authors to re-use Path2D objects.
2) Internally you could keep a "path operation list" which keeps a cache of paths and their operations. If the exact same operations are listed, you could re-use this path.

Additionally we've said previously that we would love a proposal which has a more display-list style API for canvas-2d rendering more generally for the platform :).

If we have a DisplayListCR2D at some point we could add this to the paint api via:
```js
registerPaint('foo', class {
  static contextType = 'display-list';
  paint(ctx, size, styleMap, args) {
    ctx instanceof DisplayListCanvasRenderingContext2D; // true. :)
  }
});
``` 

-- 
GitHub Notification of comment by bfgeek
Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/348#issuecomment-292315542 using your GitHub account

Received on Thursday, 6 April 2017 20:51:31 UTC