Skip to content

Conversation

@iacovlev-pavel
Copy link
Contributor

#1

Added canvas graphic rotation support (style.rotation), at the moment works only with SVG (did not test VML).
#2

With the current implementation every time a graphic is drawn a new image is created, then the onload handler is attached and the render process is executed in this handler's success result.
This has some performance implication (flickering) - if many features have the same graphic (typical in maps), or when the graphic is redrawn often with a rotation, offset, position etc. I added a quick fix which caches the last image, it did get rid of flicking in all of my use cases.

Canvas graphic rotation support and canvas graphic redraw optimizations 
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not look like a real cache. It only stores a single graphic, and creating a new image is only avoided if the same graphic is used by subsequent features. Or am I missing something?

@iacovlev-pavel
Copy link
Contributor Author

Exactly.

My first use case was rotating a feature and on each rotation the code waits for the load event to fire. Basically if I rotate by 1 degree a full circle I had to load 360 times which caused flickering on Android.
Another use case if all the features have the same graphic or "a lot of the same graphic" in a row.
In both cases the "hack" helped (no flickering).

If you have any proposals of how to make this properly without a hack, I will gladly implement it. I can also create a separate pull request for rotation and another one for "optimization" of graphic drawing.

@ahocevar
Copy link
Member

The rotation work seems incomplete as well. Try the styles-rotation.html example with the Canvas renderer to see what I mean.

For the caching, you could keep a cache of let's say 100 images (configurable), with a LRU policy. Something like I do here for caching tile images.

Having said that, separate pull requests for caching and rotation would make sense. Thanks for your efforts so far!

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

Successfully merging this pull request may close these issues.

2 participants