OsmSharp / ui

The UI components.
http://osmsharp.com/
GNU General Public License v2.0
139 stars 91 forks source link

MapView updates #274

Closed JoeCooper closed 8 years ago

JoeCooper commented 8 years ago

If the pinch, pan and rotate gestures engage simultaneously than NotifyMovement is called multiple times per frame, and the unnecessary workload caues points of interest to visibly lag behind the user's fingers on some devices (like iPad 2).

There appears to be a fix in there where InvokeOnMainThread is used to call NotifyMovement later, but, InvokeOnMainThread does not work the same way as SwingUtilities.InvokeLater and other similar methods; the action is performed synchronously and the caller must wait. (This can be observed by logging a warning if _triggeredNotifyMovement is false at the end of NotifyMovementByInvoke.)

I've replaced this solution. The new solution creates a CADisplayLink to call a method called OnPreRender before the painting of each frame. NotifyMovement now flips on a switch (_notifyMovementWanted) which affects the behaviour of OnPreRender. If _notifyMovementWanted is on at the start of OnPreRender, than it will be switched off, and then the notification will occur.

After this change, I no longer experience visible lag; the POIs rotate with my hand and are able to keep up.

Also: Fixed a mistake in a prior commit; LayerMBTile is supposed to use TryGet when checking for the presence of a wanted datum in the LRUCache.