-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iD.geo.roundCoords drops too much precision on retina #2849
Comments
Is there a difference with sub-pixel rendering and anti-aliasing on non-HiDPI devices? |
I did some digging on this today and made this codepen to understand better for myself. 2 triangles drawn with 1px stroke width. The left triangle is drawn with shape-rendering The left triangle slides around smoothly, and the right triangle jumps at device pixel boundaries. I have a retina macbook pro with a non-retina secondary monitor. So I when I run this codepen on the non-retina monitor, I see jumps at 1px, and on the retina side, I see several smallish jumps around 0.3px and 0.7px. The important takeaway is that the loss of precision is very noticeable on both the normal and the HiDPI screens, and we should really to avoid it. Benchmarks next... |
On my Windows 8.1 desktop with conventional monitors and Chrome, I see the straight lines jump, but the angled line continually progress. If I zoom in to 200% then I see the straight lines moving more frequently, and the anti-aliased version looks smoother without looking blurred. The latter confirms what I already knew from icon design - anti-aliasing can suck with 1px lines. |
Turns out there was a flaw in the original Getting Serious About SVG benchmark code. The fps buffer would fill up to 100 entries, but rather than draining the buffer like a fifo queue, new entries were being pushed/popped from the end of the buffer. (So the original fps measurement was only benchmarking whatever the code did within the first few seconds). I forked the benchmarking code and replaced Here are the very unscientific results, in each case measured after the fps settles around a value:
So my takeaway from this is that, yes, rounding to integer coordinates does speed things up a little bit (and the speedup is not from having shorter strings in the Based on this, I'm planning to either round to tenths, or eliminate the rounding completely and see how things look/perform. |
On retina screens "a pixel is not a pixel is not a pixel" so our use of
iD.geo.roundCoords
to truncate all the svg pixels to integer values should be reevaluated.I know that in the past
iD.geo.roundCoords
has been attributed to significant performance speedup, so I want re-benchmark that and decide what to do. We probably want to round to tenths instead of integers - but not sure whether to do that always or only if HiDPI detected.e.g.: rounding to integer css pixels makes square buildings look weird while zooming by single mousewheel clicks:
The text was updated successfully, but these errors were encountered: