- From: Rik Cabanier <cabanier@gmail.com>
- Date: Mon, 30 Nov 2015 16:34:37 -0800
- To: Ian Kilpatrick <ikilpatrick@chromium.org>
- Cc: public-houdini@w3.org
- Message-ID: <CAGN7qDCc4PvwQ6p1KcQJW3Gd5h0LzoOsA1vm41JEL--=+UU47w@mail.gmail.com>
On Mon, Nov 30, 2015 at 3:40 PM, Ian Kilpatrick <ikilpatrick@chromium.org> wrote: > Hi whatwg, > > (public-houdini@w3.org cc'd) > > For the CSS Paint API[1] work in Houdini we would like to split up the > current CanvasRenderingContext2D to remove references to the DOM and pixel > readback. > Why are you disallowing pixel readback? Is this an optimization so you don't have to create an image unless needed? > Additionally OffscreenCanvas[2] needs a similar reduced subset of the > CanvasRenderingContext2D api (remove references to the DOM on Workers). > > There are a couple of ways to split up the CanvasRenderingContext2D API, > namely adding inheritance + [NoInterfaceObject] to superclasses (as to not > change prototype chain, maybe not a large web compat concern), or to create > additional interfaces and get *RenderingContext2D to implement. > > The following gist has a "split into interfaces" version: > https://gist.github.com/bfgeek/72c2b26c2ccc8f728daf [see below for TL;DR > version] > > Thoughts on this as a PR to the HTML spec? > If so any preferences for how this is done? > > Additionally, if this is too premature to add to the HTML spec people have > suggested moving this to the WICG. > > Thanks, > Ian > > [1] https://drafts.css-houdini.org/css-paint-api/ > [2] https://wiki.whatwg.org/wiki/OffscreenCanvas > > TL;DR version (could be made more granular): > interface CanvasRenderingContext2D { > > // back-reference to the canvas > readonly attribute HTMLCanvasElement canvas; > > void drawFocusIfNeeded(Element element); > > // hit regions > void addHitRegion(HitRegionOptions options); > void removeHitRegion(DOMString id); > void clearHitRegions(); > }; > CanvasRenderingContext2D implements CanvasDrawingStyles; > CanvasRenderingContext2D implements CanvasImageDataMethods; > CanvasRenderingContext2D implements CanvasMethods; > CanvasRenderingContext2D implements CanvasPathMethods; > > // TODO bikeshed name. > interface OffscreenCanvasRenderingContext2D { > }; > OffscreenCanvasRenderingContext2D implements CanvasDrawingStyles; > OffscreenCanvasRenderingContext2D implements CanvasImageDataMethods; > OffscreenCanvasRenderingContext2D implements CanvasMethods; > OffscreenCanvasRenderingContext2D implements CanvasPathMethods; > > // TODO bikeshed name (would go in CSS Paint API spec). > interface HoudiniCanvasRenderingContext2D { > }; > HoudiniCanvasRenderingContext2D implements CanvasDrawingStyles; > HoudiniCanvasRenderingContext2D implements CanvasMethods; > HoudiniCanvasRenderingContext2D implements CanvasPathMethods; > > [NoInterfaceObject] > interface CanvasImageDataMethods { > ImageData createImageData(unrestricted double sw, unrestricted double > sh); > ImageData createImageData(ImageData imagedata); > ImageData getImageData(double sx, double sy, double sw, double sh); // > NOTE arguably only getImageData should be here. > void putImageData(ImageData imagedata, double dx, double dy); > void putImageData(ImageData imagedata, double dx, double dy, double > dirtyX, double dirtyY, double dirtyWidth, double dirtyHeight); > }; > > // "write-only" methods should go here, i.e. no methods which would force a > raster. > [NoInterfaceObject] > interface CanvasMethods { > // etc; > }; >
Received on Tuesday, 1 December 2015 00:35:13 UTC