Skip to content

Clip layer rendering to limited extent #2937

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

Merged
merged 2 commits into from
Nov 29, 2014
Merged

Clip layer rendering to limited extent #2937

merged 2 commits into from
Nov 29, 2014

Conversation

tschaub
Copy link
Member

@tschaub tschaub commented Nov 11, 2014

For layers with limited extents, a clipping mask is set on the map canvas before drawing the layer canvas. This avoids composing unnecessary blank pixels and removes the need to clear dirty portions of the layer canvas outside the current layer extent.

FIxes #2920.

@tschaub
Copy link
Member Author

tschaub commented Nov 11, 2014

There are a few optimizations that could be made here:

  • when rotation is zero, rect could be used instead of moveTo and lineTo
  • when clipping, restoring context.globalAlpha and resetting the transform (for non-zero rotation) could be avoided, since we already have to call context.restore()
  • if the frame extent is contained within the layer extent, no clipping needs to be done

I'm not sure how much value there is in adding these optimizations. The first two in particular would make for a much bigger/clunkier composeFrame method. I'm interested to hear others' thoughts.

This doesn't change the behavior of the WebGL renderer with respect to limited layer extents (see #2434).

@tschaub
Copy link
Member Author

tschaub commented Nov 16, 2014

Any chance for a review on this? I'm happy with the changes to both the Canvas layer renderer and tile layer renderer. And it fixes the rendering issue reported in #2920.

@elemoine
Copy link
Member

Sorry Tim. Was very busy last week. I'll do the review tomorrow.

@ahocevar
Copy link
Member

At least to me this looks good. Also nice to see that pre-/postcompose handlers can still use the full extent and are not affected by the clipping.

@elemoine
Copy link
Member

Also nice to see that pre-/postcompose handlers can still use the full extent and are not affected by the clipping.

What do you mean exactly?

@ahocevar
Copy link
Member

What do you mean exactly?

Even if the layer is clipped, I can draw on the whole viewport in layer pre- and postcompose handlers using the immediate API.

@elemoine
Copy link
Member

@tschaub do vector layers get clipped as well?

Also, I regret that the WebGL renderer does not behave the same way. But that's ok.

Please merge when you think it's ready.

@tschaub
Copy link
Member Author

tschaub commented Nov 29, 2014

@tschaub do vector layers get clipped as well?

Since vector layers don't accept an extent option, I'm not going to address that here. #2972 suggests making extent a bit more consistent between vector and raster layers.

#2434 is about WebGL renderer behavior.

tschaub added a commit that referenced this pull request Nov 29, 2014
Clip layer rendering to limited extent.
@tschaub tschaub merged commit f57f0e1 into openlayers:master Nov 29, 2014
@tschaub tschaub deleted the clipped branch November 29, 2014 21:01
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.

WMTS layer rendered in canvas produces duplicated tiles
3 participants