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

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

On Sat, 17 Nov 2012, Rik Cabanier wrote:
> >
> > You could do that with regular canvas too, just draw the one canvas 
> > and paint it to each <canvas> you want to use it on. But the one you 
> > draw on (whether using -webkit-canvas in CSS or using <canvas>) has to 
> > be the biggest one, because in either case you're actually drawing a 
> > bitmap and not a vector.
> True, however, the backgrounds are not painted. They share the same context
> so there's no overhead off copying/pasting of bitmap data.

Sure. There's no reason the UA can't do this optimisation for the case I 
described too, as far as I can tell -- if the canvas is drawn on by a 
completely opaque image, or if an ImageData is painted onto its entirety, 
it's quite possible to do a copy-on-write sharing of the underlying 

> It's as if you say:
> var ctx = Canvas1.getContext();
> Canvas2.setContext(ctx);
> Canvas3.setContext(ctx);
> ctx.moveto/lineto/etc
> and all the drawing shows up in all three canvases.

You could make something like the above work like -webkit-canvas, but I 
don't think it'd be intuitive. Consider the case of the three canvases 
being different dimensions -- as an author I would expect the paths to be 
painted at native res on each one, not at Canvas1's res and then scaled.

But anyway, this is a somewhat academic detail. Currently, canvas isn't, 
as far as I'm aware, widely used (or even rarely used) to draw the same 
identical 2D image in multiple places at different sizes, so optimising 
for this case isn't really a high priority right now.

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

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