Only iterate over ready, visible layers

This commit is contained in:
Tom Payne
2012-07-27 23:35:00 +02:00
parent 6ceeac2427
commit ade0d17541
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -262,10 +262,10 @@ ol.Map.prototype.fitUserExtent = function(userExtent) {
* @param {T=} opt_obj Object. * @param {T=} opt_obj Object.
* @template T * @template T
*/ */
ol.Map.prototype.forEachVisibleLayer = function(f, opt_obj) { ol.Map.prototype.forEachReadyVisibleLayer = function(f, opt_obj) {
var layers = this.getLayers(); var layers = this.getLayers();
layers.forEach(function(layer, index) { layers.forEach(function(layer, index) {
if (layer.getVisible()) { if (layer.isReady() && layer.getVisible()) {
var layerRenderer = this.getLayerRenderer(layer); var layerRenderer = this.getLayerRenderer(layer);
f.call(opt_obj, layer, layerRenderer, index); f.call(opt_obj, layer, layerRenderer, index);
} }
@@ -677,7 +677,7 @@ ol.Map.prototype.renderInternal = function() {
var animate = false; var animate = false;
this.forEachVisibleLayer(function(layer, layerRenderer) { this.forEachReadyVisibleLayer(function(layer, layerRenderer) {
if (layerRenderer.render()) { if (layerRenderer.render()) {
animate = true; animate = true;
} }
+1 -1
View File
@@ -537,7 +537,7 @@ ol.webgl.Map.prototype.renderInternal = function() {
this.locations_.aTexCoord, 2, goog.webgl.FLOAT, false, 16, 8); this.locations_.aTexCoord, 2, goog.webgl.FLOAT, false, 16, 8);
gl.uniform1i(this.locations_.uTexture, 0); gl.uniform1i(this.locations_.uTexture, 0);
this.forEachVisibleLayer(function(layer, layerRenderer) { this.forEachReadyVisibleLayer(function(layer, layerRenderer) {
gl.uniformMatrix4fv( gl.uniformMatrix4fv(
this.locations_.uMatrix, false, layerRenderer.getMatrix()); this.locations_.uMatrix, false, layerRenderer.getMatrix());
gl.uniform1f(this.locations_.uBrightness, layer.getBrightness()); gl.uniform1f(this.locations_.uBrightness, layer.getBrightness());