[whatwg] [canvas] getContext & multiple contexts

Ian Hickson ian at hixie.ch
Mon Aug 2 15:16:54 PDT 2010


On Thu, 29 Apr 2010, Vladimir Vukicevic wrote:
> 
> A while ago questions came up in the WebGL WG about using a canvas with 
> multiple rendering contexts, and synchronization issues that arise 
> there. Here's our suggested change to getContext.

This seems overly complex. I've gone for a somewhat simpler approach, 
which basically makes <canvas> fail getContext() if you call it with a 
context that isn't "compatible" with the last one that was used, as 
defined by a registry of contexts types. Currently, only '2d' and '3d' are 
defined in this registry, and they are not defined as compatible.


> It essentially allows for multiple contexts but adds no synchronization 
> primitives other than the requirement that rendering must be visible to 
> all contexts (that is, that they're rendered to the same destination 
> space).

Having 3D and 2D contexts rendering to the same space -- especially given 
getImageData() and the like -- seems like an interoperability nightmare.


> This also adds the 'attributes' parameter which can customize the 
> context that's created, as defined by the context itself.  WebGL has its 
> own context attributes object, and I'd suggest that the 2D context gain 
> at least an attribute to specify whether the context should be opaque or 
> not; but that's a separate suggestion from the below text.

I haven't added this. Could you elaborate on why this is needed? What 
happens if the method is invoked agains with different parameters?

It seems far preferable to have this on the API rather than as part of the 
getContext() method.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'



More information about the whatwg mailing list