- From: Nicolas Silva via GitHub <sysbot+gh@w3.org>
- Date: Tue, 17 Jan 2017 02:29:19 +0000
- To: public-houdini-archive@w3.org
nical has just created a new issue for https://github.com/w3c/css-houdini-drafts: == [css-paint-api] Consider making Path2D the only way to render paths with PaintRenderingContext2D. == I am proposing that PaintRenderingContext[1] do not implement CanvasPath[2] (calling moveTo/lineTo/etc. directly on the context). The reason is that there is opportunity for optimization when retaining and reusing path objects that is lost with this CanvasPath API. Rendering paths on the GPU can be done in several ways, all of them involve at some point transferring potentially large amounts of data to the GPU (if path contains a lot of segments), and potentially requires some non-trivial computation to take place (for example when using tessellation like Direc2D and Skia[3]). I believe that Chrome now records drawing commands and replays them outside of the content process, and Firefox is moving towards an architecture where the path data will have to be transferred to another process. So there is some copying that can be saved here as well if path objects are retained. Moving painting to the GPU is a trend that browser implementors are all following at the moment. My examples focused on it in part because Canvas2D exposes a drawing model that works well on the CPU but is quite challenging to do efficiently on the GPU. There are probably other venues for optimizations when reusing path objects. On the other hand I can't think of a reason for Path2D to be less efficient than calling lineTo and friends directly on the context. We should encourage practices that give the browser a better chance to optimize, and as a new API, houdini paint has the opportunity to do that for paths. This would not prevent web authors from re-creating and throwing away the same path objects every time the element is invalidated, but it would still be a step in the right direction, in my opinion. [1] https://drafts.css-houdini.org/css-paint-api/#2d-rendering-context [2] https://html.spec.whatwg.org/multipage/scripting.html#canvaspath [3] Skia seems to implement several ways to render paths on the GPU, tessellation being one of them. Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/348 using your GitHub account
Received on Tuesday, 17 January 2017 02:29:25 UTC