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

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

On Sun, 18 Nov 2012, Gregg Tavares (社~T) wrote:
> On Sat, Nov 17, 2012 at 4:23 PM, Ian Hickson <ian@hixie.ch> wrote:
> > On Sat, 17 Nov 2012, Gregg Tavares (社ç~T¨) wrote:
> > >
> > > Why would I want to do this? Because making paths is time consuming. 
> > > Assume my path requires 1000 lines. Why would I want to have to 
> > > repeat that N times?
> >
> > This is a solved problem with the last batch of API additions:
> >
> >    var path = new Path();
> >    for (var i = 0; i < 1000; ++i) {
> >      path.moveTo(...);
> >      path.lineTo(...);
> >    }
> >
> >    c1.setContext(ctx);
> >    ctx.stroke(path);
> >    c2.setContext(ctx);
> >    ctx.stroke(path);
> >    c3.setContext(ctx);
> >    ctx.stroke(path);
> >
> > However, when do you ever just draw a single path to three bitmaps, 
> > though?
> Both Adobe Illustrator and Photoshop (which also supports vector layers) 
> allow multiple simultaneous views into a single document so you can have 
> a zoomed view and a full view at the same time.

If they're zoomed, you can't use the same backing bitmap, you have to 
repaint it at the two zoom levels. If they have different aspect ratios, 
you'd have to paint them separately. If they have different tools showing, 
again you'd have to paint them separately.

I just don't think the model you're describing here works given the 2D API 
as it stands today. I'm not saying what you're describing is a bad model, 
indeed I agree that the logical approach makes more sense, and I think 
it's great that that's what WebGL does. But it just doesn't fit the 
bitmap-centric model used by the 2D API.

> It would be nice if trying to write similar functionality as a Web app 
> wasn't twice as slow because of the APi design

Do we have any data showing that this is a bottleneck? If we're going to 
adjust the API to support this, I'd like to see real data showing that 
this is a real problem first.

> Why be different? Surely if that ability is good for WebGL it's also 
> good for Canvas2d.

Because it's several years too late to change how the 2D API works. It's 
not a scene graph, it's a bitmap. Everything about the API is designed 
that way. At any time, you can grab the pixels and push them back.

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