Giter Club home page Giter Club logo

Comments (7)

p-lr avatar p-lr commented on August 17, 2024

This due to how path are drawn. MapCompose uses Canvas.drawLines which is hardware accelerated, but rendering isn't as pretty as Canvas.drawPath as your image shows.
Historically, I chose to ditch drawPath because the performance difference can clearly be felt when rendering long paths. I was ok with it since in this case I value performance more than aesthetics.
Now a few years later I gave drawPath another try. It's in the very experimental drawpath branch.

While the demo performs well, my testing on a real app shows a noticeable performance difference. Also, I've seen paths blinks under some circumstances (but this is probably unrelated to drawPath).

It would be nice to investigate this performance issue and see if there's a way to use drawPath while not hindering performance. In the end, I agree paths could look nicer. However I will be careful about performance.

from mapcompose.

p-lr avatar p-lr commented on August 17, 2024

The only idea I have for now is to implement path simplification. When zooming out, a path with 10k points can be simplified to a few dozen lines. This should have impact on performance. However this isn't easy to implement.

EDIT: I've implemented the Ramer–Douglas–Peucker algorithm. The result is amazing. Looks like this fixes the performance issue.

from mapcompose.

p-lr avatar p-lr commented on August 17, 2024

@Nohus Could you test the branch drawpath and give me your feedback? It should render path like Google Maps Compose library, plus with a path decimation algorithm to fix performance on zoom out.

from mapcompose.

Nohus avatar Nohus commented on August 17, 2024

Impressive work! I can confirm it works well.

I noticed a small issue: the paths seem to be drawn without anti-aliasing and have jagged edges, especially visible at particular angles. I tried setting isAntiAlias = true on the Paint object but it didn't seem to help.

The path simplification is really good, but I think it's a little bit too aggressive, I can see my paths jumping around as I zoom in and out. I think it may work better for you (and be more required) because you are using paths made of a lot of points. My points are not very dense already.

Updating the epsilon argument from 2.dp to 1.dp made it more sensible, at least on my path data.

val epsilon = with(LocalDensity.current) {
    (1.dp / zoomPRState.scale).toPx().toDouble()
}

from mapcompose.

p-lr avatar p-lr commented on August 17, 2024

Ok for reducing the epsilon.
I'm surprised you have an anti-aliasing issue. On my device it renders perfectly. Did you have the issue with previous paths?
I'll double check.

from mapcompose.

Nohus avatar Nohus commented on August 17, 2024

I rechecked on a physical device and the paths render correctly, it seems the anti-aliasing issue was emulator-specific, maybe the emulator I used lacks hardware acceleration. False alarm!

from mapcompose.

p-lr avatar p-lr commented on August 17, 2024

I'm relieved!

from mapcompose.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.