Canvas renderer optimizations #263

Merged
merged 3 commits into from Mar 4, 2013

Projects

None yet

2 participants

Contributor
twpayne commented Mar 4, 2013

This is the first of two or three optimizations for the canvas renderer. It avoids re-drawing tiles in the per-layer canvases if the canvas is known to already contain the correct tile in that part.

In addition, an opaque flag is added to all sources. If a tile can be transparent, it will be blended with the existing data in the canvas, leading to a mix of old and new data, so we must clear that area of the canvas before writing the tile [1]. However, if the tile is known to be opaque then we can avoid the clear. opaque is false by default (the slower but surer case), but is set to true for all provided tile sources that are known to return fully opaque tiles.

[1] It is possible that there may be a work around for this by setting the correct value for context.globalCompositeOperation, but I have not yet found the correct value.

@tschaub tschaub and 1 other commented on an outdated diff Mar 4, 2013
src/ol/source/stamensource.js
@@ -85,6 +85,7 @@ ol.source.Stamen = function(stamenOptions) {
goog.base(this, {
attributions: [attribution],
maxZoom: config.maxZoom,
+ opaque: true,
tschaub
tschaub Mar 4, 2013 Owner

Not all opaque here (see e.g. toner-labels):

6330

twpayne
twpayne Mar 4, 2013 Contributor

Thanks, fixed and branch updated with push --force. The Stamen source configuration is not correct, I'll open an issue for this.

Contributor
twpayne commented Mar 4, 2013

The PR has been updated since @tschaub's comment. A proper fix to the Stamen tile source will follow very shortly.

@twpayne twpayne merged commit 1bac674 into openlayers:master Mar 4, 2013
@twpayne twpayne deleted the twpayne:canvas-renderer-optimizations branch Mar 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment