Merge pull request #1019 from ahocevar/chrome-optimized
Deal with recent Chrome optimizations to avoid failing TileManager and tests
This commit is contained in:
committed by
Bart van den Eijnden
parent
d020e8f666
commit
49dd5a4fd8
@@ -223,7 +223,7 @@ OpenLayers.TileManager = OpenLayers.Class({
|
||||
for (j=layer.grid[i].length-1; j>=0; --j) {
|
||||
tile = layer.grid[i][j];
|
||||
this.addTile({tile: tile});
|
||||
if (tile.url) {
|
||||
if (tile.url && !tile.imgDiv) {
|
||||
this.manageTileCache({object: tile});
|
||||
}
|
||||
}
|
||||
@@ -255,9 +255,6 @@ OpenLayers.TileManager = OpenLayers.Class({
|
||||
for (j=layer.grid[i].length-1; j>=0; --j) {
|
||||
tile = layer.grid[i][j];
|
||||
this.unloadTile({object: tile});
|
||||
if (tile.url) {
|
||||
this.manageTileCache({object: tile});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -390,25 +387,23 @@ OpenLayers.TileManager = OpenLayers.Class({
|
||||
manageTileCache: function(evt) {
|
||||
var tile = evt.object;
|
||||
var img = this.tileCache[tile.url];
|
||||
// only use image from cache if it is not on a layer already
|
||||
if (img && (!img.parentNode ||
|
||||
OpenLayers.Element.hasClass(img.parentNode, 'olBackBuffer'))) {
|
||||
if (tile.layer.backBuffer) {
|
||||
if (tile.layer.backBuffer === img.parentNode) {
|
||||
// cached image is on the target layer's backbuffer already,
|
||||
// so nothing to do here
|
||||
return;
|
||||
}
|
||||
img.style.opacity = 0;
|
||||
img.style.visibility = 'hidden';
|
||||
}
|
||||
// Only backbuffer tiles have an id, so we don't want one here
|
||||
img.id = null;
|
||||
tile.setImage(img);
|
||||
// LRU - move tile to the end of the array to mark it as the most
|
||||
// recently used
|
||||
OpenLayers.Util.removeItem(this.tileCacheIndex, tile.url);
|
||||
this.tileCacheIndex.push(tile.url);
|
||||
if (img) {
|
||||
// if image is on its layer's backbuffer, remove it from backbuffer
|
||||
if (img.parentNode &&
|
||||
OpenLayers.Element.hasClass(img.parentNode, 'olBackBuffer')) {
|
||||
img.parentNode.removeChild(img);
|
||||
img.id = null;
|
||||
}
|
||||
// only use image from cache if it is not on a layer already
|
||||
if (!img.parentNode) {
|
||||
img.style.visibility = 'hidden';
|
||||
img.style.opacity = 0;
|
||||
tile.setImage(img);
|
||||
// LRU - move tile to the end of the array to mark it as the most
|
||||
// recently used
|
||||
OpenLayers.Util.removeItem(this.tileCacheIndex, tile.url);
|
||||
this.tileCacheIndex.push(tile.url);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user