Skip to content
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

Improve RasterStyle #2627

Open
pauldendulk opened this issue May 10, 2024 · 2 comments
Open

Improve RasterStyle #2627

pauldendulk opened this issue May 10, 2024 · 2 comments

Comments

@pauldendulk
Copy link
Member

pauldendulk commented May 10, 2024

The problem
At some point we decided that a renderer is always tied to a style, so a feature with no style will not be rendered. To apply this consistently we also introduced a RasterStyle, which was a bit weird at that point because we did not use the information in the style renderer.

There are however quite a few things that we could add as is demonstrated here by @taublast.

The proposed solution
Investigate the options added by Nick and add them to the RasterStyle (I have not looked into the code myself so don't have thoughts about the details). Personally I am also interested in an outline which I use for debugging tile layers and can be useful for highlighting a specific raster overlay.

@taublast
Copy link

Hi Paul!
What kind of improvement/look would you have in mind? Some presets/properties for ISkiaStyle, or maybe more ways to hook custom code that would affect the rendering result?
A quick guess is that we could plug almost any functionality inside a custom ISkiaStyleRenderer. In the mentioned demo I didn't do it because the goal was to create a map control for drawnUi but if I were to use plain Maui, for example, I would add hardware acceleration support for Maui and then create a custom RasterStyleRenderer to achieve the same result. At the same time if we need fast rendering and we have a static result we want to achieve we could custom-render received tiles upon loading and save the final result to cache.
Ways i was considering when thinking about customizing raw tiles, I used the option B:

  • A. The Tile is rasterized with custom effects just once and cached, to be fast drawn from an existing image later. Would use for production app when you already know your final static modifications. With actual implementation would need to hook inside the loader.
  • B. Customization code is dynamically applied to rendering operation at display/browse time, for heavy stuff better have hardware acceleration. Nice for tryouts and affecting any element that supports IRasterStyle, not only tiles.

@pauldendulk
Copy link
Member Author

Hi Nick!

Sorry for my late reply.

What I had in mind is not too ambitious. In your sample you created a custom renderer which can render the tile in certain styles. My idea was to add those (or some of those) options to the existing RasterStyle so that our users can use it without having to use skia.

I did not intent to add more ways to make Mapsui more pluggable. I hope a custom ISkiaStyleRenderer is enough for all scenarios.

but if I were to use plain Maui, for example, I would add hardware acceleration support for Maui and then create a custom RasterStyleRenderer to achieve the same result.

I don't fully understand this. In Mapsui we use skia and skia has options for GPU support in some of their views and some of their platforms. We don't do anything else but turn it on if available. I don't see how we could make use of Maui hardware acceleration.

  • A. The Tile is rasterized with custom effects just once and cached, to be fast drawn from an existing image later. Would use for production app when you already know your final static modifications. With actual implementation would need to hook inside the loader.
  • B. Customization code is dynamically applied to rendering operation at display/browse time, for heavy stuff better have hardware acceleration. Nice for tryouts and affecting any element that supports IRasterStyle, not only tiles.

I have a similar thing in the case of SVGs. We currently create a SKPicture which contains the colors as well. If we want a custom color we need to create an altered copy of the SKPicture. The upside is that this is fast. The downside is that you could need many colors and the cache will grow. In the case of SVGs this is a big problem because you could have continuous color values leading to a cache item very every feature (and there could be 10.000 features). The alternative is to use SKPaths and SKPaints.

For tiles it is less likely to be different for every tile. So there a SKPicture per tile might not be a problem. The downside will be that you can not easily change this without clearing the cache. So a slider which changes the darkness of a tile will not transition smoother. Still I think an SKImage and SKPaint might be the best option for us.

Then again, this is a complicate problem for which I don't expect a perfect solution. We are currently working on changes to the cache so this is not something to change things to in the current code base.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants