Add a temporary ol.TileCoord in ol.renderer.canvas.TileLayer

Avoid garbage creation
This commit is contained in:
Frederic Junod
2016-04-13 17:18:27 +02:00
parent f92a38b28c
commit a2c3dfd5de

View File

@@ -43,6 +43,12 @@ ol.renderer.canvas.TileLayer = function(tileLayer) {
*/
this.tmpExtent_ = ol.extent.createEmpty();
/**
* @private
* @type {ol.TileCoord}
*/
this.tmpTileCoord_ = [0, 0, 0];
/**
* @private
* @type {!goog.vec.Mat4.Number}
@@ -125,7 +131,7 @@ ol.renderer.canvas.TileLayer.prototype.composeFrame = function(
// Calculate all insert points by tile widths from a common origin to avoid
// gaps caused by rounding
var origin = ol.extent.getBottomLeft(tileGrid.getTileCoordExtent(
tileGrid.getTileCoordForCoordAndZ(center, currentZ)));
tileGrid.getTileCoordForCoordAndZ(center, currentZ, this.tmpTileCoord_)));
var w = Math.round(ol.extent.getWidth(tileExtent) * pixelScale);
var h = Math.round(ol.extent.getHeight(tileExtent) * pixelScale);
var left = Math.round((tileExtent[0] - origin[0]) * pixelScale / w) * w +