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

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



On Tue, 18 Dec 2012, Florian Bsch wrote:
> On Tue, Dec 18, 2012 at 8:13 PM, Ian Hickson <ian@hixie.ch> wrote:
> > 
> > And then if you want to draw to a canvas instead of an off-screen 
> > buffer, you just use a Canvas instead of a DrawingBuffer.
> 
> So we're gonna get a document.createElement('canvas', {antialias:true, 
> alpha:false, depth:false}) ?

Well the idiomatic approach would be attributes on the element object 
(and proxy, in the case of a worker-transfered canvas proxy), but if you 
would like it to be on createElement() you'd have to ask the DOM guys.


> > I don't know why you have to specify them at all. :-)
>
> Because additional functionality that you do not need (such as alpha 
> compositing, depth buffers, anti-aliasing, stenciling etc.) #1 occupy 
> memory #2 slow things down.

In the rest of the platform, we leave these kinds of things up to the UA 
as a quality of implementation thing, typically. But I don't know enough 
about them (and nobody is explaining them in enough detail) for me to know 
if that makes sense here.


> > Why would a canvas (not context, you've explained why a context may 
> > wish to paint to different surfaces differently, e.g. to have an area 
> > with AA and an area without or something) ever need to have its 
> > settings changed?
>
> You're not drawing the same thing. You're re-using expensive resources 
> (such as vertex buffers, textures etc.) or using computed resources 
> (RTTs) to draw different aspects of your application onto different 
> surfaces.

So you have one rendering context with the vertex buffers, textures, etc, 
and you draw them to multiple canvases.

Why would you ever use different rendering contexts to draw to one canvas? 
Or why would you change the settings on a single canvas between paints 
from the same rendering context?

Or, for those proposing a DrawingBuffer model, why would you ever have 
anything but a 1:1 mapping of DrawingBuffer to canvas?

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