[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Public WebGL] using the same context with multiple canvases
On Sat, 10 Nov 2012, Boris Zbarsky wrote:
> On 11/10/12 9:26 AM, Gregg Tavares (社用) wrote:
> > No, the parameters are for the canvas's backing store, not the context
> Ah, hmm. So an interesting question is whether the backing store is
> associtated with the _canvas_ or with the _context_. I believe in Gecko
> it's the latter at the moment, for both 2d and webgl contexts.
In the current model, there's a one-to-one relationship, so the question
With the model I'm currently writing up, they can both have some.
For the 2D context, my plan is as follows:
If you create and bind a context via getContext(), then the context and
the canvas are forever bound and share a backing store.
If you create a context using the constructor, you get a context and it
gets a backing store. If you then bind it to a canvas, the canvas gets a
separate backing store, and there's a method you invoke that pushes the
bits from the context to the canvas (this also happens implicitly whenever
the event loop spins). One way to distinguish the two is to compare the
results of drawImage() when passed a context vs when passed a canvas. You
can also see the difference between this model and the shared bitmap model
by drawing on the main thread and then calling alert(); in the shared
bitmap model the canvas will show the drawing but in the split context
model it will not.
This split bitmap thing is needed because otherwise there's no way to know
when to actually update the screen bitmap in the case of the context being
on a different thread. It's going to be exposed in the main thread also
just for consistency (so that code doesn't change behaviour just because
it's implemented in a worker rather than in the main thread).
I don't know what model is needed for WebGL contexts.
Ian Hickson U+1047E )\._.,--....,'``. fL
http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'