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

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




On 11/10/12 11:12 AM, Ian Hickson wrote:
In the current model, there's a one-to-one relationship, so the question
is moot.

In the current model there is a one-to-many relationship between a canvas and canvas contexts. In particular, it's possible to grab both a 2d context and a webgl context for the same canvas. This happens to change which backing store the canvas is using, though, so conceptually the backing store is tied to the context, not the canvas...


If you create and bind a context via getContext(), then the context and
the canvas are forever bound and share a backing store.

This isn't even true today, really; see above.

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.

That seems like a possible way to do it, yes. It does involve twice the memory usage, right?


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.

Hmm. Why not? The other thread could send a message, in general, right?

-Boris

-----------------------------------------------------------
You are currently subscribed to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email:
unsubscribe public_webgl
-----------------------------------------------------------