W3C home > Mailing lists > Public > whatwg@whatwg.org > November 2013

Re: [whatwg] High-density canvases

From: Ian Hickson <ian@hixie.ch>
Date: Mon, 25 Nov 2013 19:48:49 +0000 (UTC)
To: Rik Cabanier <cabanier@gmail.com>, Stephen White <senorblanco@chromium.org>, dino@apple.com, robert@ocallahan.org
Message-ID: <alpine.DEB.2.00.1311251933020.27766@ps20323.dreamhostps.com>
Cc: WHAT Working Group <whatwg@whatwg.org>
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.   `._.-(,_..'--(,_..'`-.;.'
Received on Monday, 25 November 2013 19:49:16 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:14 UTC