Cache coordinates for reuse on replay, not on geometry

This commit is contained in:
Andreas Hocevar
2017-08-04 21:06:22 +02:00
parent ee7795e31d
commit 67aa1a6dc9
3 changed files with 10 additions and 37 deletions

View File

@@ -88,6 +88,12 @@ ol.render.canvas.Replay = function(tolerance, maxExtent, resolution, overlaps) {
*/
this.coordinates = [];
/**
* @private
* @type {ol.Coordinate|Array.<ol.Coordinate>|Array.<Array.<ol.Coordinate>>}
*/
this.coordinateCache_ = {};
/**
* @private
* @type {!ol.Transform}
@@ -393,7 +399,10 @@ ol.render.canvas.Replay.prototype.replay_ = function(
var coords;
if (instruction.length == 6) {
var fn = instruction[5];
coords = fn(pixelCoordinates, d, dd, 2, geometry.getRenderCoordinates());
if (!(d in this.coordinateCache_)) {
this.coordinateCache_[d] = [];
}
coords = fn(pixelCoordinates, d, dd, 2, this.coordinateCache_[d]);
} else {
coords = pixelCoordinates.slice(d, dd);
}