[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 Tue, Jun 10, 2014 at 6:46 PM, Jukka Jylänki <jujjyl@gmail.com> wrote:
Hi there,

I raised a discussion about the need for explicit API or spec-guaranteed mechanism for resizing a WebGL canvas size to be pixel-perfect in the WebGL issue tracker. In the interest of not retyping everything, here's a link to the details: 


The quick summary: When trying to come up the proper device pixel size for a WebGL canvas so that it properly matches the actual size displayed by the browser, fractional window.devicePixelRatio values in the wild (1.5 and 2.25 have been seen) pose problems, and to get the right result, one has to either floor, round or ceil the result depending on the devicePixelRatio and device resolution in question.

Browser zoom (= ctrl/cmd +/-) also affects DPR.
Someone from Google maps stated that 15% of all users have some level of browser zoom enabled.
 
We need to spec down a method that is guaranteed to work so that off-by-one-pixel errors cannot possibly occur. What should such a mechanism look like that can take into account arbitrarily fractional devicePixelRatios out there?

Canvas 2D is suffering from the same issue.
There was a thread on this on WhatWG: http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2013-September/252483.html
We went through the issues but it seemed too complex to solve this in the browser.