-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[ios] Avoid drawing view annotations across pixel boundaries #10219
Conversation
macOS doesn’t have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How the annotation's location accuracy will be affected at different zoom levels?
@fabian-guerra There are two scenarios, but in both the accuracy should remain unchanged (as this is always sub-pixel rounding of a screen point, just after it was converted from a geographic coordinate).
In both cases, the original geographic coordinate remains untouched and only the screen point at which the view annotation is placed is modified. At most, the difference introduced by the rounding will be ~0.5 pixels, which does not affect accuracy and subtly improves rendering sharpness. |
bc87592
to
23bd12e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍🏼
23bd12e
to
0e61a82
Compare
0e61a82
to
817e5c1
Compare
Fixes #10119 by rounding view anchor points so that annotation views are not being drawn across pixel boundaries. This change impacts how all view annotations are drawn, including the user location annotation, regular view annotations, and also callout views.
In most cases, the misalignment was being introduced by
-convertCoordinate:toPointToView:
, which converts from geographic coordinates to screen points, but with floating point precision. This PR leaves the precision of that method intact, but rounds the returned point value to the nearest pixel before we use it to place the view.Note that
MGLPointRounded()
will round to pixels and not necessarily points — it’s fine to draw to logical pixels on scaled displays.Also fixed is the misalignment of the scale bar labels — these should be crisper now, too.
/cc @1ec5 @frederoni @fabian-guerra @boundsj