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

Re: [Public WebGL] How to set a canvas backing store to display units?



On Thu, 14 Jun 2012, Gregg Tavares (çç~T¨) wrote:
> 
> <canvas id="foo" width="400" height="300">
> 
> That displays on the page in 400x300 CSS pixels (note at this point here 
> is no backing store)
> 
> If you do:
> 
>     canvas = document.getElementById("canvas");
>     ctx = get.getContext("2d")
> 
> the backing store for allocated any size the browser wants
> 
> If you do
> 
>     canvas = document.getElementById("canvas");
>     ctx = get.getContext("webgl")
> 
> the backing store allocated for webgl is 400x300
> 
> That's it. Nothing changes except the WebGL spec says WebGL contexts 
> must allocate a backbuffer canvas.width,canvas.height. No DPI adjusting 
> allowed.
> 
> If the user sets the width to 800x600 they'll get an 800x600 canvas and 
> an 800x600 backbuffer. If they want it HD-DPI they can set the css width 
> to 400px by 300px. That's the same as it is today.

That's a layering violation. CSS is supposed to be an optional layer, you 
shouldn't require CSS in order to get a sane rendering.

The units here:

   <canvas id="foo" width="400" height="300">

...are CSS pixels. Not device pixels. If the screen is not 
96dpi-equivalent, then the resulting backing store should be scaled 
appropriately.


On Thu, 14 Jun 2012, Gregg Tavares (çç~T¨) wrote:
> 
> The intent of the spec as written is
> 
> 1) Give the developer exactly what they ask for. If they ask for 640x480 
> they get 640x480

I agree that we should give the authors what they ask for.

If the author writes:

   <canvas id="foo" width="320" height="240">

...and the user's device is 2x-dpi, then they are asking for a 640x480 
backing store with a 320x240 coordinate space.

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