On Tue, 10 Sep 2013, Ian Hickson wrote:
> On Tue, 10 Sep 2013, Ian Hickson wrote:
> > 
> > It would be nice to fix these all at once, and I think we can, by 
> > introducing a configuration option on getContext(), in the style of 
> > WebGL:
> > 
> >    getContext('2d', { density: 'autosize' });
> > 
> > This would trigger the following behaviour: When the context is 
> > created, and subsequently when the <canvas> changes size (e.g. due to 
> > being sized with CSS relative units and the element they're relative 
> > to changing), or when the display density changes size (e.g. due to 
> > page zoom), then:
> > 
> >    - the width and height of the canvas bitmaps get updated to match the
> >      new native size of the <canvas>, at native density.
> > 
> >    - the coordinate space of the canvas (context.width/context.height) 
> >      gets updated to match the size of the <canvas> in CSS pixel units.
> > 
> >    - a 'resize' event gets fired at the <canvas>.
> > 
> > We would dump the *HD versions of the methods, and make the regular 
> > ones go back to returning the actual raw pixels, since that would now 
> > work fine and still provide HD-quality content everywhere it's 
> > available.
> > 
> > What do people think?
> Rik pointed out on IRC that it's common to have out-of-DOM canvases, 
> e.g. for storing textures, which would need to track the density of the 
> one in the DOM. I'd have to think about it in more detail, but in 
> principle it seems some sort of slaving mechanism should be able to 
> handle that too.

Proposed slaving mechanism:

   var context1 = pageCanvas.getContext('2d', { density: 'autosize' });
   var context2 = hiddenCanvas.getContext('2d', { density: pageCanvas });

Assuming we go with http://wiki.whatwg.org/wiki/WorkerCanvas :

If the 'density' value isn't the string 'autosize', it has to be a canvas 
element or, if this is a worker, a WorkerCanvas object. Either way, that 
object has to have had a context already created for it, using density set 
to 'autosize'. Note that this means there's no way to have this magic 
behaviour make a worker's canvases change size to match a canvas being 
drawn on on the main thread. When using a WorkerCanvas, the browser takes 
care of forwarding density changes from the main thread to the worker (I'm 
not sure I understand the proposal properly, but I assume it autocommits 
when the worker goes idle, even if the main thread is busy).

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

Reply via email to