-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Clear the canvas on layer extent changes #2757
Conversation
Indeed there is a bug - see #2758. Currently, we look for and conditionally render 9 child tiles instead of 4 to cover a loading parent tile when zooming out. |
Currently, renderers receive orders through the frame state. They are "frame state driven". This change is a departure from that design. With this change the canvas tile renderer is both "frame state driven" and "layer event driven". Just wanted to point this out. Also, on the code itself now: when the layer is removed from the map An alternative would be to store the "current layer extent" in the renderer instance and clear the canvas when I'd say, use the approach you like best, but if the |
Right. This is what I don't like about the "fire generic events and let all listeners reconstruct what happened" approach. |
With or without this change, rendering is "driven" by modifications to layer state. Layer events trigger rendering. The frame state doesn't "drive" anything - it represents a ton of state. Listening for layer events in the map and then calling render makes it so renderers (potentially - see below) have to store a ton of state themselves so they can decide what to do with the frame state object. I'd like to start reworking things so listeners are registered closer to where they are needed to reduce the amount of state that has to be stored for comparison. But I'm not going to do that here.
I have. I see this as an incremental change in the right direction.
Good catch. Fixed with e1ee347. By "potentially" above I mean that if we really wanted things to be efficient with the current design, layer renderers would need to store not only the previous layer state that comes with the frame state, but all layer "properties" so they could ignore changes that don't affect rendering. |
goog.events.listen( | ||
tileLayer, ol.Object.getChangeEventType(ol.layer.LayerProperty.EXTENT), | ||
this.handleLayerExtentChanged_, false, this) | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The array of listener keys could be created by ol.renderer.Layer
(the base constructor), and disposeInternal
could be implemented on that constructor's prototype
. In this way we provide a more generic way for listening to layer events. Just a comment, not requesting to do this now.
Please merge. |
Clear the canvas on layer extent changes.
Things I like about this solution:
map.render()
, as by the time we get to preparing the frame in the layer renderer, we know nothing about what changed. And we have to store extra state on the layer renderer in order to figure out what work we need to do.Things I don't like about this solution:
rendereredCanvasZ_
is a bit awkward. It would be nice to have aforgetEverythingAndStartOver
method. But I'm not sure where else this would get used yet.Input welcome.
Fixes #2731.