Bug 28786
Summary: | Canvas needs a well defined model for what happens when you change contexts | ||
---|---|---|---|
Product: | WebKit | Reporter: | Chris Marrin <cmarrin> |
Component: | WebGL | Assignee: | Chris Marrin <cmarrin> |
Status: | RESOLVED CONFIGURATION CHANGED | ||
Severity: | Normal | CC: | enne, kbr, kkinnunen, simon.fraser |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | PC | ||
OS: | OS X 10.5 | ||
See Also: | https://bugs.webkit.org/show_bug.cgi?id=222758 |
Chris Marrin
When Canvas had only a 2D context, the model was simple. That 2D context lived for as long as the Canvas element. But now that you can have a 3D context, what happens when you switch between 2D and 3D? The old context can't get destroyed because there is possibly still a reference to it in JavaScript. So what happens when you call one of its rendering functions? Mixing 2D and 3D is hard, and maybe even impossible on some hardware.
We have to decide on what the model is. Who owns the bitmap being rendered into? If it's owned by the context, how does that bitmap get associated with a Canvas? If it's the canvas, how do you know which context it is attached to? There are many ways to do it, we just need to decide which one to use. This is a discussion that has to be in the HTML5 group.
For now, the model I have implemented is that, once you have done a getContext for a 2D or 3D context, you can only use that context. Trying a getContext with any other string will return null. This is not a great solution, but it is safe and sufficient for any existing content.
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Kimmo Kinnunen
As per https://html.spec.whatwg.org/multipage/canvas.html#dom-canvas-getcontext maybe the model originally selected was good.