Don't queue tiles multiple times.

This results in a smaller queue that we don't have to unqueue from.
This commit is contained in:
ahocevar
2012-01-31 11:55:19 +01:00
parent e77b06dbc4
commit cc749a7967

View File

@@ -414,7 +414,11 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
* evt - {Object} Listener argument of the tile's beforedraw event
*/
queueTileDraw: function(evt) {
this.tileQueue.push(evt.object);
var tile = evt.object;
if (!~OpenLayers.Util.indexOf(this.tileQueue, tile)) {
// queue only if not in queue already
this.tileQueue.push(tile);
}
if (!this.tileQueueId) {
this.tileQueueId = OpenLayers.Animation.start(
OpenLayers.Function.bind(this.drawTileFromQueue, this),
@@ -433,26 +437,10 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
this.clearTileQueue();
} else {
var tile = this.tileQueue.shift();
this.unqueueTile(tile);
tile.draw(true);
}
},
/**
* Method: unqueueTile
* Removes all occurrences of a tile from the <tileQueue>.
*
* Parameters:
* tile - {<OpenLayers.Tile>} The tile to remove from the queue
*/
unqueueTile: function(tile) {
for (var i=this.tileQueue.length-1; i>=0; --i) {
if (this.tileQueue[i] === tile) {
this.tileQueue.splice(i, 1);
}
}
},
/**
* Method: clearTileQueue
* Clears the animation queue
@@ -470,7 +458,6 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
* tile - {<OpenLayers.Tile>}
*/
destroyTile: function(tile) {
this.unqueueTile(tile);
this.removeTileMonitoringHooks(tile);
tile.destroy();
},