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

Re: [Public WebGL] How to unambiguously set canvas pixel size to be pixel-perfect?




On 6/11/14, 9:30 AM, Florian Bösch wrote:
I wasn't refering to "odd" as the fact that people zoom. I was referring
to odd that the pixel device ratio changes.

Ah.

It might or might not, depending on the zoom mode.

Browsers have two distinct zoom modes in the wild:

1) The mobile browser zoom-and-pan mode (called "pinch zoom" in the cssom-view spec): zooming doesn't change layout, and simply performs a draw-time upscale or something close to it (font rasterization here is complicated). The size of the viewport (e.g. as measured by window.innerWidth) does not actually change in this mode. Instead, the page spills out of the viewport if you zoom in and you can pan around it.

2) The desktop browser page zoom mode (called "page zoom" in the spec): zooming changes the size of a CSS pixel as measured in device pixels (and hence the size of the viewport) then redoes the page layout using the new viewport size. Effectively, this corresponds more or less (again, with some font rasterization complications) to resizing the window and then doing a paint-time upscale back to the original size. This can change where linebreaks happen and whatnot. Typically the resulting layout will not spill out of the viewport horizontally.

devicePixelRatio does not change when zoom mode #1 is used.

In zoom mode #2, the actual ratio of device to CSS pixels is in fact changing. Some browsers correspondingly change the value of devicePixelRatio. Others seem not to. Per spec at http://dev.w3.org/csswg/cssom-view/#dom-window-devicepixelratio it should change in zoom mode #2.

Because the only way to make use of that information, will require breaking the application, inevitably.

What are you trying to do with devicePixelRatio, exactly, where having it accurately reflect the ratio of CSS to device pixels won't work?


-Boris

-----------------------------------------------------------
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
-----------------------------------------------------------