Boost number of loading tiles when not animating or interacting
This commit is contained in:
@@ -83,18 +83,6 @@ ol.ENABLE_DOM = true;
|
||||
ol.ENABLE_WEBGL = true;
|
||||
|
||||
|
||||
/**
|
||||
* @define {number} Maximum number of simultaneously loading tiles.
|
||||
*/
|
||||
ol.MAXIMUM_TILES_LOADING = 8;
|
||||
|
||||
|
||||
/**
|
||||
* @define {number} Maximum new tile loads per frame.
|
||||
*/
|
||||
ol.MAXIMUM_NEW_TILE_LOADS_PER_FRAME = 2;
|
||||
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
@@ -587,17 +575,19 @@ ol.Map.prototype.handleMapBrowserEvent = function(mapBrowserEvent) {
|
||||
ol.Map.prototype.handlePostRender = function() {
|
||||
|
||||
// Limit the number of tile loads if animating or interacting.
|
||||
var limit = (1 << 30) - 1; // a large enough integer
|
||||
var maxTotalLoading = 16;
|
||||
var maxNewLoads = maxTotalLoading;
|
||||
var frameState = this.frameState_;
|
||||
if (!goog.isNull(frameState)) {
|
||||
var hints = frameState.viewHints;
|
||||
if (hints[ol.ViewHint.ANIMATING] || hints[ol.ViewHint.INTERACTING]) {
|
||||
limit = ol.MAXIMUM_NEW_TILE_LOADS_PER_FRAME;
|
||||
maxTotalLoading = 8;
|
||||
maxNewLoads = 2;
|
||||
}
|
||||
}
|
||||
|
||||
this.tileQueue_.reprioritize(); // FIXME only call if needed
|
||||
this.tileQueue_.loadMoreTiles(limit, ol.MAXIMUM_TILES_LOADING);
|
||||
this.tileQueue_.loadMoreTiles(maxTotalLoading, maxNewLoads);
|
||||
|
||||
var postRenderFunctions = this.postRenderFunctions_;
|
||||
var i;
|
||||
|
||||
@@ -68,19 +68,19 @@ ol.TileQueue.prototype.handleTileChange = function() {
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} limit Maximum number of new tiles to load.
|
||||
* @param {number} maxTilesLoading Maximum number tiles to load simultaneously.
|
||||
* @param {number} maxTotalLoading Maximum number tiles to load simultaneously.
|
||||
* @param {number} maxNewLoads Maximum number of new tiles to load.
|
||||
*/
|
||||
ol.TileQueue.prototype.loadMoreTiles = function(limit, maxTilesLoading) {
|
||||
ol.TileQueue.prototype.loadMoreTiles = function(maxTotalLoading, maxNewLoads) {
|
||||
var tile;
|
||||
while (limit > 0 &&
|
||||
while (maxNewLoads > 0 &&
|
||||
!this.isEmpty() &&
|
||||
this.tilesLoading_ < maxTilesLoading) {
|
||||
this.tilesLoading_ < maxTotalLoading) {
|
||||
tile = /** @type {ol.Tile} */ (this.dequeue()[0]);
|
||||
goog.events.listenOnce(tile, goog.events.EventType.CHANGE,
|
||||
this.handleTileChange, false, this);
|
||||
tile.load();
|
||||
++this.tilesLoading_;
|
||||
--limit;
|
||||
--maxNewLoads;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user