[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] using the same context with multiple canvases



On Thu, Dec 13, 2012 at 12:08 PM, Ian Hickson <ian@hixie.ch> wrote:
They don't have to be creation, right? I mean, you have multiple contexts
and you have multiple canvases, you're not going to be necessarily
creating anything after that, just binding a context to a canvas and
drawing. If the settings are specific to a particular context/canvas
binding, then setContext() seems the right place...

That would be a bad idea from a performance standpoint unless we put some fairly obscure rules in place. For instance: switching from a non-antialiased backbuffer to an antialiased one would be pretty expensive, but if canvas attributes are set in setContext then it would naturally allow the following code:

canvas1.setContext(gl, {antialias: false});
canvas2.setContext(gl, {antialias: false});
canvas1.setContext(gl, {antialias: true});

That third call would override the creation parameters declared in the first call, which would necessitate destruction and recreation of the underlying buffers to match the requested attributes. We could always say in the spec that only the first call to setContext on a given canvas is allowed creation parameters and in subsequent calls they are ignored, but that's an open invitation to confusing behavior and obscure bugs. The setDrawingBuffer() proposals handle the same scenario in a much less error-prone way that more closely mirrors the underlying code.

--Brandon