Nicer track rendering

One of MyTrails’ design principles has always been performance. I’m very proud of the fact that no other Android mapping application is as fast and smooth as MyTrails. This is partly because it uses OpenGL to render the map and tracks.

A big part of that is that MyTrails has to be able to display tens of tracks with thousands of track points without slowing down, and because of this, I have been hesitant to change the track rendering algorithm.

Things came to a head recently when I implemented the new Time and Distance colorizations. Suddenly (and especially in an emulator running on my low-pixel density computer display), the track looked very crude to me. And it’s always been: zoom out enough and it degenerates into a mess of horizontal and vertical hatches. Even up close, sharp edges in the track look broken. This is because OpenGL’s support for lines is very, very crude.

Also, it’s limited in terms of the thickness of lines it can draw (based on the GPU in each model of phone), and high-density screen in devices that use low-end GPUs (such as the Nexus 4) caused the tracks to be thinner than they should, and lack a border.

No more! In MyTrails 1.4.0, I’ve rewritten the track rendering algorithm, and lines are smoothly blended, can be rendered at any width, and are unbroken at any zoom level. And they’re still very fast (56 frames per second on a Galaxy S3, compared to 57fps for the previous algorithm).

New track rendering

New track rendering

During the beta period for 1.4.0, I will try to keep the hidden option ‘toggle track mode’ operational so you can compare the modes for yourself (there’s an intermediate mode that uses un-smoothed lines). If some phones are too slow for the new rendering mode, I can make it an official option for the release.

You can test the new rendering in MyTrails 2.0.0a6 and shortly in 1.4.0b1.

A few more screenshots to compare the old and new modes.

Liked this post? Follow this blog to get more.